fix intermittent error in contract tests
currentTime() doesn't always correctly reflect the time of the next transaction
This commit is contained in:
parent
044ceea946
commit
bf183f9521
|
@ -50,8 +50,8 @@ ethersuite "Marketplace contracts":
|
|||
switchAccount(host)
|
||||
discard await token.approve(marketplace.address, request.ask.collateral).confirm(1)
|
||||
discard await marketplace.reserveSlot(request.id, 0.u256).confirm(1)
|
||||
filledAt = await ethProvider.currentTime()
|
||||
discard await marketplace.fillSlot(request.id, 0.u256, proof).confirm(1)
|
||||
let receipt = await marketplace.fillSlot(request.id, 0.u256, proof).confirm(1)
|
||||
filledAt = await ethProvider.blockTime(BlockTag.init(!receipt.blockNumber))
|
||||
slotId = request.slotId(0.u256)
|
||||
|
||||
proc waitUntilProofRequired(slotId: SlotId) {.async.} =
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import pkg/ethers
|
||||
import pkg/serde/json
|
||||
|
||||
proc blockTime*(provider: Provider, tag: BlockTag): Future[UInt256] {.async.} =
|
||||
return (!await provider.getBlock(tag)).timestamp
|
||||
|
||||
proc currentTime*(provider: Provider): Future[UInt256] {.async.} =
|
||||
return (!await provider.getBlock(BlockTag.pending)).timestamp
|
||||
return await provider.blockTime(BlockTag.pending)
|
||||
|
||||
proc advanceTime*(provider: JsonRpcProvider, seconds: UInt256) {.async.} =
|
||||
discard await provider.send("evm_increaseTime", @[%("0x" & seconds.toHex)])
|
||||
|
|
Loading…
Reference in New Issue