Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: description of transaction doesn't return from #783

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Sources/Web3Core/EthereumAddress/EthereumAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,16 @@ extension EthereumAddress: Codable {
extension EthereumAddress: Hashable { }

extension EthereumAddress: APIResultType { }

// MARK: - CustomStringConvertible

extension EthereumAddress: CustomStringConvertible {
/// Used when converting an instance to a string
public var description: String {
var toReturn = ""
toReturn += "EthereumAddress" + "\n"
toReturn += "type: " + String(describing: type) + "\n"
toReturn += "address: " + String(describing: address) + "\n"
return toReturn
}
}
2 changes: 1 addition & 1 deletion Sources/Web3Core/Transaction/CodableTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ extension CodableTransaction: CustomStringConvertible {
var toReturn = ""
toReturn += "Transaction" + "\n"
toReturn += String(describing: self.envelope)
toReturn += "from: " + String(describing: self.sender?.address) + "\n"
toReturn += "from: " + String(describing: self.sender) + "\n"
albertopeam marked this conversation as resolved.
Show resolved Hide resolved
toReturn += "hash: " + String(describing: self.hash?.toHexString().addHexPrefix()) + "\n"
return toReturn
}
Expand Down
13 changes: 12 additions & 1 deletion Tests/web3swiftTests/localTests/EthereumAddressTest.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// EthereumAddressTest.swift
//
//
//
// Created by JeneaVranceanu on 03.02.2023.
//
Expand Down Expand Up @@ -35,4 +35,15 @@ class EthereumAddressTest: XCTestCase {
XCTAssertNil(ethereumAddress)
}

func testDescription() async throws {
let rawAddress = "0x200eb5ccda1c35b0f5bf82552fdd65a8aee98e79"
let ethereumAddress = EthereumAddress(rawAddress)

let sut = String(describing: ethereumAddress)
print(sut)
albertopeam marked this conversation as resolved.
Show resolved Hide resolved

XCTAssertTrue(sut.contains("EthereumAddress\n"))
XCTAssertTrue(sut.contains("type: normal\n"))
XCTAssertTrue(sut.contains("address: 0x"))
albertopeam marked this conversation as resolved.
Show resolved Hide resolved
}
}
12 changes: 12 additions & 0 deletions Tests/web3swiftTests/localTests/TransactionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,18 @@ class TransactionsTests: XCTestCase {
}
}

func testDescription() async throws {
let vector = testVector[TestCase.eip1559.rawValue]
let jsonData = try XCTUnwrap(vector.JSON.data(using: .utf8))
let txn = try JSONDecoder().decode(CodableTransaction.self, from: jsonData)

let sut = String(describing: txn)

XCTAssertTrue(sut.contains("Transaction"))
XCTAssertTrue(sut.contains("from: "))
XCTAssertTrue(sut.contains("hash: "))
albertopeam marked this conversation as resolved.
Show resolved Hide resolved
}

// ***** Legacy Tests *****
// TODO: Replace `XCTAssert` with more explicit `XCTAssertEqual`, where Applicable

Expand Down