mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-01-27 15:05:47 +00:00
fix proof integration test
there were two logic errors in this test: - a slot is freed anyway at the end of the contract - when starting the request takes a long time, the first slot can already be freed because there were too many missing proofs
This commit is contained in:
parent
3cfa205f2f
commit
9a2e5478a5
@ -158,8 +158,7 @@ marketplacesuite "Simulate invalid proofs":
|
||||
):
|
||||
let client0 = clients()[0].client
|
||||
let expiry = 10.periods
|
||||
# In 2 periods you cannot have enough invalid proofs submitted:
|
||||
let duration = expiry + 2.periods
|
||||
let duration = expiry + 10.periods
|
||||
|
||||
let data = await RandomChunker.example(blocks=8)
|
||||
createAvailabilities(data.len * 2, duration) # TODO: better value for data.len
|
||||
@ -176,20 +175,27 @@ marketplacesuite "Simulate invalid proofs":
|
||||
)
|
||||
let requestId = client0.requestId(purchaseId).get
|
||||
|
||||
check eventually(client0.purchaseStateIs(purchaseId, "started"), timeout = expiry.int * 1000)
|
||||
var slotWasFilled = false
|
||||
proc onSlotFilled(event: SlotFilled) =
|
||||
if event.requestId == requestId:
|
||||
slotWasFilled = true
|
||||
let filledSubscription = await marketplace.subscribe(SlotFilled, onSlotFilled)
|
||||
|
||||
# wait for the first slot to be filled
|
||||
check eventually(slotWasFilled, timeout = expiry.int * 1000)
|
||||
|
||||
var slotWasFreed = false
|
||||
proc onSlotFreed(event: SlotFreed) =
|
||||
if event.requestId == requestId:
|
||||
slotWasFreed = true
|
||||
let freedSubscription = await marketplace.subscribe(SlotFreed, onSlotFreed)
|
||||
|
||||
let subscription = await marketplace.subscribe(SlotFreed, onSlotFreed)
|
||||
|
||||
# check not freed
|
||||
await sleepAsync((duration - expiry).int.seconds)
|
||||
# In 2 periods you cannot have enough invalid proofs submitted:
|
||||
await sleepAsync(2.periods.int.seconds)
|
||||
check not slotWasFreed
|
||||
|
||||
await subscription.unsubscribe()
|
||||
await filledSubscription.unsubscribe()
|
||||
await freedSubscription.unsubscribe()
|
||||
|
||||
# TODO: uncomment once fixed
|
||||
# test "host that submits invalid proofs is paid out less", NodeConfigs(
|
||||
|
Loading…
x
Reference in New Issue
Block a user