refactors a bit to get the tests back to work
This commit is contained in:
parent
8186842784
commit
c089000033
|
@ -481,11 +481,9 @@ proc blockNumberForEpoch(epochTime: int64, provider: Provider): Future[UInt256]
|
|||
except ValueError as e:
|
||||
raise newException(EthersError, fmt"Conversion error: {e.msg}")
|
||||
|
||||
method queryPastEvents*[T: MarketplaceEvent](
|
||||
method queryPastSlotFilledEvents*(
|
||||
market: OnChainMarket,
|
||||
_: type T,
|
||||
fromTime: int64): Future[seq[T]] {.async.} =
|
||||
|
||||
fromTime: int64): Future[seq[SlotFilled]] {.async.} =
|
||||
convertEthersError:
|
||||
let contract = market.contract
|
||||
let provider = contract.provider
|
||||
|
@ -494,6 +492,6 @@ method queryPastEvents*[T: MarketplaceEvent](
|
|||
|
||||
let fromBlock = BlockTag.init(blockNumberForEpoch)
|
||||
|
||||
return await contract.queryFilter(T,
|
||||
return await contract.queryFilter(SlotFilled,
|
||||
fromBlock,
|
||||
BlockTag.latest)
|
||||
|
|
|
@ -249,8 +249,7 @@ method queryPastEvents*[T: MarketplaceEvent](
|
|||
blocksAgo: int): Future[seq[T]] {.base, async.} =
|
||||
raiseAssert("not implemented")
|
||||
|
||||
method queryPastEvents*[T: MarketplaceEvent](
|
||||
method queryPastSlotFilledEvents*(
|
||||
market: Market,
|
||||
_: type T,
|
||||
fromTime: int64): Future[seq[T]] {.base, async.} =
|
||||
fromTime: int64): Future[seq[SlotFilled]] {.base, async.} =
|
||||
raiseAssert("not implemented")
|
||||
|
|
|
@ -129,7 +129,7 @@ proc epochForDurationBackFromNow(duration: times.Duration): int64 =
|
|||
|
||||
proc restoreHistoricalState(validation: Validation) {.async} =
|
||||
let startTimeEpoch = epochForDurationBackFromNow(MaxStorageRequestDuration)
|
||||
let slotFilledEvents = await validation.market.queryPastEvents(SlotFilled,
|
||||
let slotFilledEvents = await validation.market.queryPastSlotFilledEvents(
|
||||
fromTime = startTimeEpoch)
|
||||
for event in slotFilledEvents:
|
||||
let slotId = slotId(event.requestId, event.slotIndex)
|
||||
|
|
|
@ -485,6 +485,13 @@ method queryPastEvents*[T: MarketplaceEvent](
|
|||
SlotFilled(requestId: slot.requestId, slotIndex: slot.slotIndex)
|
||||
)
|
||||
|
||||
method queryPastSlotFilledEvents*(
|
||||
market: MockMarket,
|
||||
fromTime: int64): Future[seq[SlotFilled]] {.async.} =
|
||||
return market.filled.map(slot =>
|
||||
SlotFilled(requestId: slot.requestId, slotIndex: slot.slotIndex)
|
||||
)
|
||||
|
||||
method unsubscribe*(subscription: RequestSubscription) {.async.} =
|
||||
subscription.market.subscriptions.onRequest.keepItIf(it != subscription)
|
||||
|
||||
|
|
Loading…
Reference in New Issue