Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions Tests/Web3Tests/Web3Tests/Web3HttpTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Web3HttpTests: QuickSpec {
describe("http rpc requests") {

let web3 = Web3(rpcURL: infuraUrl)

context("web3 client version") {

waitUntil(timeout: 2.0) { done in
Expand Down Expand Up @@ -243,19 +242,26 @@ class Web3HttpTests: QuickSpec {
}

waitUntil(timeout: 2.0) { done in
web3.eth.getBalance(address: ethereumAddress, block: .block(4000000)) { response in
it("should be status ok") {
expect(response.status.isSuccess) == true
}
it("should not be nil") {
expect(response.result).toNot(beNil())
}
it("should be a quantity response") {
expect(response.result?.quantity) == BigUInt("1ea7ab3de3c2f1dc75", radix: 16)
}

// Infura only works on 128 most recent blocks, dynmaically get the latest block to test.
web3.eth.blockNumber { blockResponse in

expect(blockResponse.result).toNot(beNil())

web3.eth.getBalance(address: ethereumAddress, block: .block(blockResponse.result!.quantity)) { response in
it("should be status ok") {
expect(response.status.isSuccess) == true
}
it("should not be nil") {
expect(response.result).toNot(beNil())
}
it("should be a quantity response") {
expect(response.result?.quantity) == BigUInt("1ea7ab3de3c2f1dc75", radix: 16)
}

// Tests done
done()
// Tests done
done()
}
}
}
}
Expand Down Expand Up @@ -397,7 +403,7 @@ class Web3HttpTests: QuickSpec {
}

context("eth get code") {
waitUntil(timeout: 2.0) { done in
waitUntil(timeout: 5.0) { done in
firstly {
try web3.eth.getCode(address: EthereumAddress(hex: "0x2e704bF506b96adaC7aD1df0db461344146a4657", eip55: true), block: .block(5397525))
}.done { code in
Expand Down