[market] Add Market.getTime()
This commit is contained in:
parent
061b32296a
commit
dd89a55351
|
@ -40,7 +40,7 @@ method offerStorage(market: OnChainMarket, offer: StorageOffer) {.async.} =
|
|||
method selectOffer(market: OnChainMarket, offerId: array[32, byte]) {.async.} =
|
||||
await market.contract.selectOffer(offerId)
|
||||
|
||||
proc getTime(market: OnChainMarket): Future[UInt256] {.async.} =
|
||||
method getTime(market: OnChainMarket): Future[UInt256] {.async.} =
|
||||
let provider = market.contract.provider
|
||||
let blck = !await provider.getBlock(BlockTag.latest)
|
||||
return blck.timestamp
|
||||
|
|
|
@ -23,6 +23,9 @@ method offerStorage*(market: Market, offer: StorageOffer) {.base, async.} =
|
|||
method selectOffer*(market: Market, id: array[32, byte]) {.base, async.} =
|
||||
raiseAssert("not implemented")
|
||||
|
||||
method getTime*(market: Market): Future[UInt256] {.base, async.} =
|
||||
raiseAssert("not implemented")
|
||||
|
||||
method waitUntil*(market: Market, expiry: UInt256) {.base, async.} =
|
||||
raiseAssert("not implemented")
|
||||
|
||||
|
|
|
@ -165,6 +165,10 @@ ethersuite "On-Chain Market":
|
|||
|
||||
await subscription.unsubscribe()
|
||||
|
||||
test "can retrieve current block time":
|
||||
let latestBlock = !await provider.getBlock(BlockTag.latest)
|
||||
check (await market.getTime()) == latestBlock.timestamp
|
||||
|
||||
test "supports waiting for expiry of a request or offer":
|
||||
let pollInterval = 100.milliseconds
|
||||
market.pollInterval = pollInterval
|
||||
|
|
|
@ -71,6 +71,9 @@ method unsubscribe*(subscription: OfferSubscription) {.async.} =
|
|||
func `<`(a, b: Expiry): bool =
|
||||
a.expiry < b.expiry
|
||||
|
||||
method getTime*(market: MockMarket): Future[UInt256] {.async.} =
|
||||
return market.time
|
||||
|
||||
method waitUntil*(market: MockMarket, expiry: UInt256): Future[void] =
|
||||
let future = Future[void]()
|
||||
if expiry > market.time:
|
||||
|
|
Loading…
Reference in New Issue