Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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"
toReturn += "hash: " + String(describing: self.hash?.toHexString().addHexPrefix()) + "\n"
return toReturn
}
Expand Down
12 changes: 11 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,14 @@ class EthereumAddressTest: XCTestCase {
XCTAssertNil(ethereumAddress)
}

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

let sut = String(describing: ethereumAddress)

XCTAssertTrue(sut.contains("EthereumAddress\n"))
XCTAssertTrue(sut.contains("type: normal\n"))
XCTAssertTrue(sut.contains("address: 0x200EB5cCdA1c35B0F5Bf82552FDD65a8AEe98E79"))
}
}
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: Optional(EthereumAddress\ntype: normal\naddress: 0x9d8A62f656a8d1615C1294fd71e9CFb3E4855A4F\n)\n"))
XCTAssertTrue(sut.contains(#"hash: Optional("0x41dc0cd9b133e0d4e47e269988b0109c966db5220d57e2a7f3cdc6c2f8de6a72")"#))
}

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

Expand Down