mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-10 04:55:40 +00:00
d1658d7b77
* market: use `pending` blocktag when querying onchain state * clock: use wall clock in integration tests reason: we'll need to wait for the next period in integration tests, and we can't do that if the time doesn't advance * clock: remove unused field * integration: use pending block time to get current time * clock: fix on-chain clock for hardhat Only use 'latest' block for updates Only update the first time you see a block * integration: do not start tests with a very outdated block * integration: allow for longer expiry period
14 lines
611 B
Nim
14 lines
611 B
Nim
import pkg/ethers
|
|
|
|
proc currentTime*(provider: Provider): Future[UInt256] {.async.} =
|
|
return (!await provider.getBlock(BlockTag.pending)).timestamp
|
|
|
|
proc advanceTime*(provider: JsonRpcProvider, seconds: UInt256) {.async.} =
|
|
discard await provider.send("evm_increaseTime", @[%("0x" & seconds.toHex)])
|
|
discard await provider.send("evm_mine")
|
|
|
|
proc advanceTimeTo*(provider: JsonRpcProvider, timestamp: UInt256) {.async.} =
|
|
if (await provider.currentTime()) != timestamp:
|
|
discard await provider.send("evm_setNextBlockTimestamp", @[%("0x" & timestamp.toHex)])
|
|
discard await provider.send("evm_mine")
|