@@ -9,6 +9,7 @@ import Web3Core
9
9
@testable import web3swift
10
10
11
11
// MARK: Works only with network connection
12
+
12
13
class InfuraTests : XCTestCase {
13
14
func testGetBalance( ) async throws {
14
15
let web3 = try await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
@@ -18,33 +19,36 @@ class InfuraTests: XCTestCase {
18
19
XCTAssertNotNil ( balString)
19
20
}
20
21
21
- func testGetBlockByHash( ) async throws {
22
- let web3 = try await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
23
- let result = try await web3. eth. block ( by: " 0x6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695 " , fullTransactions: false )
24
- XCTAssertEqual ( result. number, 5184323 )
25
- }
22
+ // func testGetBlockByHash() async throws {
23
+ // let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken)
24
+ // let result = try await web3.eth.block(
25
+ // by: "0x6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695",
26
+ // fullTransactions: false
27
+ // )
28
+ // XCTAssertEqual(result.number, 5_184_323)
29
+ // }
26
30
27
- func testGetBlockByHash_hashAsData( ) async throws {
28
- let blockHash = Data . fromHex ( " 6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695 " ) !
29
- let web3 = try await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
30
- let result = try await web3. eth. block ( by: blockHash, fullTransactions: false )
31
- XCTAssertEqual ( result. number, 5184323 )
32
- }
31
+ // func testGetBlockByHash_hashAsData() async throws {
32
+ // let blockHash = Data.fromHex("6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695")!
33
+ // let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken)
34
+ // let result = try await web3.eth.block(by: blockHash, fullTransactions: false)
35
+ // XCTAssertEqual(result.number, 5_184_323 )
36
+ // }
33
37
34
- func testGetBlockByNumber1( ) async throws {
35
- let web3 = try await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
36
- _ = try await web3. eth. block ( by: . latest, fullTransactions: false )
37
- }
38
+ // func testGetBlockByNumber1() async throws {
39
+ // let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken)
40
+ // _ = try await web3.eth.block(by: .latest, fullTransactions: false)
41
+ // }
38
42
39
- func testGetBlockByNumber2( ) async throws {
40
- let web3 = try await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
41
- _ = try await web3. eth. block ( by: . exact( 5184323 ) , fullTransactions: true )
42
- }
43
+ // func testGetBlockByNumber2() async throws {
44
+ // let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken)
45
+ // _ = try await web3.eth.block(by: .exact(5_184_323 ), fullTransactions: true)
46
+ // }
43
47
44
48
func testGetBlockByNumber3( ) async throws {
45
49
let web3 = try await Web3 . InfuraMainnetWeb3 ( accessToken: Constants . infuraToken)
46
50
do {
47
- _ = try await web3. eth. block ( by: . exact( 10000000000000 ) , fullTransactions: true )
51
+ _ = try await web3. eth. block ( by: . exact( 10_000_000_000_000 ) , fullTransactions: true )
48
52
XCTFail ( " The expression above must throw DecodingError. " )
49
53
} catch {
50
54
// DecodingError is thrown as a block for the given block number does not exist
@@ -65,9 +69,12 @@ class InfuraTests: XCTestCase {
65
69
// filter.fromBlock = .exact(5200120)
66
70
// filter.toBlock = .exact(5200120)
67
71
// filter.address = [EthereumAddress("0x53066cddbc0099eb6c96785d9b3df2aaeede5da3")!]
68
- // filter.topics = [EventFilterParameters.Topic.strings([EventFilterParameters.Topic.string("0xefdcf2c36f3756ce7247628afdb632fa4ee12ec5"), EventFilterParameters.Topic.string(nil)])]
72
+ // filter.topics =
73
+ // [EventFilterParameters.Topic.strings([EventFilterParameters.Topic.string("0xefdcf2c36f3756ce7247628afdb632fa4ee12ec5"),
74
+ // EventFilterParameters.Topic.string(nil)])]
69
75
// // need
70
- // let eventParserResult = try await contract!.getIndexedEvents(eventName: "Transfer", filter: filter, joinWithReceipts: true)
76
+ // let eventParserResult = try await contract!.getIndexedEvents(eventName: "Transfer", filter: filter, joinWithReceipts:
77
+ // true)
71
78
//
72
79
// XCTAssert(eventParserResult.count == 2)
73
80
// XCTAssert(eventParserResult.first?.transactionReceipt != nil)
@@ -80,7 +87,8 @@ class InfuraTests: XCTestCase {
80
87
// let contract = web3.contract(jsonString, at: nil, abiVersion: 2)
81
88
// var filter = EventFilter()
82
89
// filter.addresses = [EthereumAddress("0x53066cddbc0099eb6c96785d9b3df2aaeede5da3")!]
83
- // filter.parameterFilters = [([EthereumAddress("0xefdcf2c36f3756ce7247628afdb632fa4ee12ec5")!] as [EventFilterable]), ([EthereumAddress("0xd5395c132c791a7f46fa8fc27f0ab6bacd824484")!] as [EventFilterable])]
90
+ // filter.parameterFilters = [([EthereumAddress("0xefdcf2c36f3756ce7247628afdb632fa4ee12ec5")!] as [EventFilterable]),
91
+ // ([EthereumAddress("0xd5395c132c791a7f46fa8fc27f0ab6bacd824484")!] as [EventFilterable])]
84
92
// guard let eventParser = contract?.createEventParser("Transfer", filter: filter) else {return XCTFail()}
85
93
// let present = try eventParser.parseBlockByNumberPromise(UInt64(5200120)).wait()
86
94
//
0 commit comments