File tree Expand file tree Collapse file tree 4 files changed +36
-1
lines changed
Tests/web3swiftTests/localTests Expand file tree Collapse file tree 4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -155,3 +155,16 @@ extension EthereumAddress: Codable {
155155extension EthereumAddress : Hashable { }
156156
157157extension EthereumAddress : APIResultType { }
158+
159+ // MARK: - CustomStringConvertible
160+
161+ extension EthereumAddress : CustomStringConvertible {
162+ /// Used when converting an instance to a string
163+ public var description : String {
164+ var toReturn = " "
165+ toReturn += " EthereumAddress " + " \n "
166+ toReturn += " type: " + String( describing: type) + " \n "
167+ toReturn += " address: " + String( describing: address) + " \n "
168+ return toReturn
169+ }
170+ }
Original file line number Diff line number Diff line change @@ -271,7 +271,7 @@ extension CodableTransaction: CustomStringConvertible {
271271 var toReturn = " "
272272 toReturn += " Transaction " + " \n "
273273 toReturn += String ( describing: self . envelope)
274- toReturn += " from: " + String( describing: self . sender? . address ) + " \n "
274+ toReturn += " from: " + String( describing: self . sender) + " \n "
275275 toReturn += " hash: " + String( describing: self . hash? . toHexString ( ) . addHexPrefix ( ) ) + " \n "
276276 return toReturn
277277 }
Original file line number Diff line number Diff line change @@ -35,4 +35,14 @@ class EthereumAddressTest: XCTestCase {
3535 XCTAssertNil ( ethereumAddress)
3636 }
3737
38+ func testDescription( ) async throws {
39+ let rawAddress = " 0x200eb5ccda1c35b0f5bf82552fdd65a8aee98e79 "
40+ let ethereumAddress = EthereumAddress ( rawAddress)
41+
42+ let sut = String ( describing: ethereumAddress)
43+
44+ XCTAssertTrue ( sut. contains ( " EthereumAddress \n " ) )
45+ XCTAssertTrue ( sut. contains ( " type: normal \n " ) )
46+ XCTAssertTrue ( sut. contains ( " address: 0x200EB5cCdA1c35B0F5Bf82552FDD65a8AEe98E79 " ) )
47+ }
3848}
Original file line number Diff line number Diff line change @@ -592,6 +592,18 @@ class TransactionsTests: XCTestCase {
592592 }
593593 }
594594
595+ func testDescription( ) async throws {
596+ let vector = testVector [ TestCase . eip1559. rawValue]
597+ let jsonData = try XCTUnwrap ( vector. JSON. data ( using: . utf8) )
598+ let txn = try JSONDecoder ( ) . decode ( CodableTransaction . self, from: jsonData)
599+
600+ let sut = String ( describing: txn)
601+
602+ XCTAssertTrue ( sut. contains ( " Transaction " ) )
603+ XCTAssertTrue ( sut. contains ( " from: Optional(EthereumAddress \n type: normal \n address: 0x9d8A62f656a8d1615C1294fd71e9CFb3E4855A4F \n ) \n " ) )
604+ XCTAssertTrue ( sut. contains ( #"hash: Optional("0x41dc0cd9b133e0d4e47e269988b0109c966db5220d57e2a7f3cdc6c2f8de6a72")"# ) )
605+ }
606+
595607 // ***** Legacy Tests *****
596608 // TODO: Replace `XCTAssert` with more explicit `XCTAssertEqual`, where Applicable
597609
You can’t perform that action at this time.
0 commit comments