@@ -12,26 +12,24 @@ import Core
1212class InfuraTests : XCTestCase {
1313
1414 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)
2420 }
2521
2622 func testGetBlockByHash( ) async throws {
2723 let web3 = await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
2824 let result = try await web3. eth. block ( by: " 0x6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695 " , fullTransactions: false )
25+ XCTAssertEqual ( result. number, 5184323 )
2926 }
3027
3128 func testGetBlockByHash_hashAsData( ) async throws {
3229 let blockHash = Data . fromHex ( " 6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695 " ) !
3330 let web3 = await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
3431 let result = try await web3. eth. block ( by: blockHash, fullTransactions: false )
32+ XCTAssertEqual ( result. number, 5184323 )
3533 }
3634
3735 func testGetBlockByNumber1( ) async throws {
@@ -50,8 +48,7 @@ class InfuraTests: XCTestCase {
5048 let _ = try await web3. eth. block ( by: . exact( 10000000000000 ) , fullTransactions: true )
5149 XCTFail ( " The expression above must throw DecodingError. " )
5250 } 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
5552 XCTAssert ( error is DecodingError )
5653 }
5754 }
0 commit comments