Skip to content

Commit e629ee9

Browse files
fix: updated test to use XCTAssert and XCTFail
1 parent c6e418e commit e629ee9

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,26 @@ class BasicLocalNodeTests: LocalTestCase {
2222
let contract = web3.contract(abiString, at: nil, abiVersion: 2)!
2323

2424
let parameters = [] as [AnyObject]
25-
// MARK: Writing Data flow
25+
2626
let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)!
2727
deployTx.transaction.from = allAddresses[0]
2828
deployTx.transaction.gasLimitPolicy = .manual(3000000)
2929

3030
let result = try await deployTx.writeToChain(password: "web3swift")
3131
let txHash = result.hash.stripHexPrefix()
3232

33-
Thread.sleep(forTimeInterval: 1.0)
34-
35-
let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!)
36-
print(receipt)
37-
38-
switch receipt.status {
39-
case .notYetProcessed:
40-
return
41-
default:
42-
break
33+
while true {
34+
let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!)
35+
switch receipt.status {
36+
case .notYetProcessed:
37+
continue
38+
case .failed:
39+
XCTFail("Failed to deploy a contract!")
40+
case .ok:
41+
XCTAssertNotNil(receipt.contractAddress)
42+
return
43+
}
4344
}
44-
45-
let details = try await web3.eth.transactionDetails(Data.fromHex(txHash)!)
46-
print(details)
4745
}
4846

4947
func testEthSendExampleWithRemoteSigning() async throws {

0 commit comments

Comments
 (0)