@@ -8,37 +8,38 @@ import web3swift
88// while this class does show up in the navigator, it has no associated tests
99class LocalTestCase : XCTestCase {
1010 static let url = URL . init ( string: " http://127.0.0.1:8545 " ) !
11- let ganache = try ! Web3 . new ( LocalTestCase . url)
1211 static var isSetUp = false
1312
1413 override class func setUp( ) {
1514 super. setUp ( )
1615
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
2020
21- let web3 = try ! Web3 . new ( LocalTestCase . url)
21+ let web3 = try ! await Web3 . new ( LocalTestCase . url)
2222
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 }
2525
26- print ( " \n ****** Preloading Ganache ( \( 25 - block) blocks) ***** \n " )
26+ print ( " \n ****** Preloading Ganache ( \( 25 - block) blocks) ***** \n " )
2727
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)
3232
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 )
3939
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+ }
4243 }
4344 }
4445}
0 commit comments