@@ -50,7 +50,6 @@ marketplacesuite "Marketplace":
5050
5151 # client requests storage
5252 let cid = (await client.upload (data)).get
53-
5453 let id = await client.requestStorage (
5554 cid,
5655 duration = 20 * 60 .uint64 ,
@@ -123,10 +122,9 @@ marketplacesuite "Marketplace":
123122 # Checking that the hosting node received reward for at least the time between <expiry;end>
124123 let slotSize = slotSize (blocks, ecNodes, ecTolerance)
125124 let pricePerSlotPerSecond = minPricePerBytePerSecond * slotSize
126- check eventually (
127- (await token.balanceOf (hostAccount)) - startBalanceHost >=
128- (duration - 5 * 60 ).u256 * pricePerSlotPerSecond * ecNodes.u256
129- )
125+ check eventually (await token.balanceOf (hostAccount)) - startBalanceHost >=
126+ (duration - 5 * 60 ).u256 * pricePerSlotPerSecond * ecNodes.u256
127+
130128 # Checking that client node receives some funds back that were not used for the host nodes
131129 check eventually (
132130 (await token.balanceOf (clientAccount)) - clientBalanceBeforeFinished > 0 ,
@@ -259,18 +257,16 @@ marketplacesuite "Marketplace payouts":
259257 let cid = (await clientApi.upload (data)).get
260258
261259 var slotIdxFilled = none uint64
262- var slotFilledFut = Future [void ].Raising ([CancelledError ]).init ()
263260 proc onSlotFilled (eventResult: ?! SlotFilled ) =
264261 assert not eventResult.isErr
265262 slotIdxFilled = some (! eventResult).slotIndex
266- slotFilledFut.complete ()
267263
268264 let slotFilledSubscription = await marketplace.subscribe (SlotFilled , onSlotFilled)
269265
270- var requestCancelledFut = Future [ void ]. Raising ([ CancelledError ]). init ()
266+ var requestCancelledEvent = newAsyncEvent ()
271267 proc onRequestCancelled (eventResult: ?! RequestCancelled ) =
272268 assert not eventResult.isErr
273- requestCancelledFut. complete ()
269+ requestCancelledEvent. fire ()
274270
275271 let requestCancelledSubscription =
276272 await marketplace.subscribe (RequestCancelled , onRequestCancelled)
@@ -287,35 +283,35 @@ marketplacesuite "Marketplace payouts":
287283 )
288284
289285 # wait until one slot is filled
290- await slotFilledFut. wait ( timeout = chronos. seconds ( expiry.int ) )
286+ check eventually (slotIdxFilled.isSome, timeout = expiry.int * 1000 )
291287
292288 let slotId = slotId (! (await clientApi.requestId (id)), ! slotIdxFilled)
293289
294290 # wait until sale is cancelled
295291 await ethProvider.advanceTime (expiry.u256)
296292
297- await requestCancelledFut .wait (timeout = chronos.seconds (5 ))
293+ await requestCancelledEvent. wait () .wait (timeout = chronos.seconds (5 ))
298294
299295 await advanceToNextPeriod ()
300296
301297 let slotSize = slotSize (blocks, ecNodes, ecTolerance)
302298 let pricePerSlotPerSecond = minPricePerBytePerSecond * slotSize
303299
304- check eventually (
305- block :
306- let endBalanceClient = (await token.balanceOf (client.ethAccount))
307- let endBalanceProvider = (await token.balanceOf (provider.ethAccount))
308- (startBalanceClient - endBalanceClient) ==
309- (endBalanceProvider - startBalanceProvider)
300+ check eventually (
301+ let endBalanceClient = (await token.balanceOf (client.ethAccount))
302+ let endBalanceProvider = (await token.balanceOf (provider.ethAccount))
303+ (startBalanceClient - endBalanceClient) ==
304+ (endBalanceProvider - startBalanceProvider)
310305 )
311306
312307 check eventually (
313- block :
308+ (
314309 let endBalanceClient = (await token.balanceOf (client.ethAccount))
315310 let endBalanceProvider = (await token.balanceOf (provider.ethAccount))
316311 (startBalanceClient - endBalanceClient) ==
317- (endBalanceProvider - startBalanceProvider),
318- timeout = 10 * 1000 ,
312+ (endBalanceProvider - startBalanceProvider)
313+ ),
314+ timeout = 10 * 1000 , # give client a bit of time to withdraw its funds
319315 )
320316
321317 await slotFilledSubscription.unsubscribe ()
0 commit comments