Skip to content

Commit ac05664

Browse files
chore: implemented EthereumAddress tests
1 parent 42bb154 commit ac05664

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,38 @@
11
//
2-
// File.swift
2+
// EthereumAddressTest.swift
33
//
44
//
55
// Created by JeneaVranceanu on 03.02.2023.
66
//
77

88
import Foundation
9+
import XCTest
10+
11+
@testable import Web3Core
12+
13+
class EthereumAddressTest: XCTestCase {
14+
15+
func testZeroAddress() {
16+
XCTAssertNotNil(EthereumAddress(Data(count: 20)))
17+
}
18+
19+
func testAddress() {
20+
let rawAddress = "0x200eb5ccda1c35b0f5bf82552fdd65a8aee98e79"
21+
let ethereumAddress = EthereumAddress(rawAddress)
22+
XCTAssertNotNil(ethereumAddress)
23+
XCTAssertEqual(ethereumAddress?.address.lowercased(), rawAddress)
24+
}
25+
26+
func testInvalidAddress() {
27+
var rawAddress = "0x200eb5ccda1c35b0f5bf82552e98e79"
28+
var ethereumAddress = EthereumAddress(rawAddress)
29+
XCTAssertNil(ethereumAddress)
30+
rawAddress = "0x200eb5ccDA1c35b0f5bf82552fdd65a8aeeabcde"
31+
ethereumAddress = EthereumAddress(rawAddress)
32+
XCTAssertNil(ethereumAddress)
33+
rawAddress = "0x200eb5ccda1c35b0f5bf82552fdd65a8aeeabcdef"
34+
ethereumAddress = EthereumAddress(rawAddress)
35+
XCTAssertNil(ethereumAddress)
36+
}
37+
38+
}

0 commit comments

Comments
 (0)