@@ -12,26 +12,24 @@ import Core
12
12
class InfuraTests : XCTestCase {
13
13
14
14
func testGetBalance( ) async throws {
15
- do {
16
- let web3 = await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
17
- let address = EthereumAddress ( " 0xd61b5ca425F8C8775882d4defefC68A6979DBbce " ) !
18
- let balance = try await web3. eth. getBalance ( for: address)
19
- let balString = Utilities . formatToPrecision ( balance, numberDecimals: Utilities . Units. eth. decimals, formattingDecimals: 3 )
20
- XCTAssertNotNil ( balString)
21
- } catch {
22
- XCTFail ( )
23
- }
15
+ let web3 = await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
16
+ let address = EthereumAddress ( " 0xd61b5ca425F8C8775882d4defefC68A6979DBbce " ) !
17
+ let balance = try await web3. eth. getBalance ( for: address)
18
+ let balString = Utilities . formatToPrecision ( balance, numberDecimals: Utilities . Units. eth. decimals, formattingDecimals: 3 )
19
+ XCTAssertNotNil ( balString)
24
20
}
25
21
26
22
func testGetBlockByHash( ) async throws {
27
23
let web3 = await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
28
24
let result = try await web3. eth. block ( by: " 0x6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695 " , fullTransactions: false )
25
+ XCTAssertEqual ( result. number, 5184323 )
29
26
}
30
27
31
28
func testGetBlockByHash_hashAsData( ) async throws {
32
29
let blockHash = Data . fromHex ( " 6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695 " ) !
33
30
let web3 = await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
34
31
let result = try await web3. eth. block ( by: blockHash, fullTransactions: false )
32
+ XCTAssertEqual ( result. number, 5184323 )
35
33
}
36
34
37
35
func testGetBlockByNumber1( ) async throws {
@@ -50,8 +48,7 @@ class InfuraTests: XCTestCase {
50
48
let _ = try await web3. eth. block ( by: . exact( 10000000000000 ) , fullTransactions: true )
51
49
XCTFail ( " The expression above must throw DecodingError. " )
52
50
} catch {
53
- // DecodingError is throws as a block for the given block number is
54
- //
51
+ // DecodingError is thrown as a block for the given block number does not exist
55
52
XCTAssert ( error is DecodingError )
56
53
}
57
54
}
0 commit comments