@@ -8,37 +8,38 @@ import web3swift
8
8
// while this class does show up in the navigator, it has no associated tests
9
9
class LocalTestCase : XCTestCase {
10
10
static let url = URL . init ( string: " http://127.0.0.1:8545 " ) !
11
- let ganache = try ! Web3 . new ( LocalTestCase . url)
12
11
static var isSetUp = false
13
12
14
13
override class func setUp( ) {
15
14
super. setUp ( )
16
15
17
- // check to see if we need to run the one-time setup
18
- if isSetUp { return }
19
- isSetUp = true
16
+ Task {
17
+ // check to see if we need to run the one-time setup
18
+ if isSetUp { return }
19
+ isSetUp = true
20
20
21
- let web3 = try ! Web3 . new ( LocalTestCase . url)
21
+ let web3 = try ! await Web3 . new ( LocalTestCase . url)
22
22
23
- let block = try ! web3. eth. getBlockNumber ( )
24
- if block >= 25 { return }
23
+ let block = try ! await web3. eth. getBlockNumber ( )
24
+ if block >= 25 { return }
25
25
26
- print ( " \n ****** Preloading Ganache ( \( 25 - block) blocks) ***** \n " )
26
+ print ( " \n ****** Preloading Ganache ( \( 25 - block) blocks) ***** \n " )
27
27
28
- let allAddresses = try ! web3. eth. getAccounts ( )
29
- let sendToAddress = allAddresses [ 0 ]
30
- let contract = web3. contract ( Web3 . Utils. coldWalletABI, at: sendToAddress, abiVersion: 2 )
31
- let value = Web3 . Utils. parseToBigUInt ( " 1.0 " , units: . eth)
28
+ let allAddresses = try ! await web3. eth. getAccounts ( )
29
+ let sendToAddress = allAddresses [ 0 ]
30
+ let contract = web3. contract ( Web3 . Utils. coldWalletABI, at: sendToAddress, abiVersion: 2 )
31
+ let value = Web3 . Utils. parseToBigUInt ( " 1.0 " , units: . eth)
32
32
33
- let from = allAddresses [ 0 ]
34
- let writeTX = contract!. write ( " fallback " ) !
35
- writeTX. transactionOptions. from = from
36
- writeTX. transactionOptions. value = value
37
- writeTX. transactionOptions. gasLimit = . manual( 78423 )
38
- writeTX. transactionOptions. gasPrice = . manual( 20000000000 )
33
+ let from = allAddresses [ 0 ]
34
+ let writeTX = contract!. write ( " fallback " ) !
35
+ writeTX. transactionOptions. from = from
36
+ writeTX. transactionOptions. value = value
37
+ writeTX. transactionOptions. gasLimit = . manual( 78423 )
38
+ writeTX. transactionOptions. gasPrice = . manual( 20000000000 )
39
39
40
- for _ in block..< 25 {
41
- let _ = try ! writeTX. sendPromise ( password: " " ) . wait ( )
40
+ for _ in block..< 25 {
41
+ let _ = try ! await writeTX. send ( password: " " )
42
+ }
42
43
}
43
44
}
44
45
}
0 commit comments