diff --git a/tests/integration/testmarketplace.nim b/tests/integration/testmarketplace.nim index 3fff77e2..86b67c05 100644 --- a/tests/integration/testmarketplace.nim +++ b/tests/integration/testmarketplace.nim @@ -107,6 +107,14 @@ marketplacesuite "Marketplace": # client requests storage let cid = (await client.upload(data)).get + + var requestStartedFut = Future[void].Raising([CancelledError]).init() + proc onRequestStarted(eventResult: ?!RequestFulfilled) {.raises: [].} = + requestStartedFut.complete() + + let startedSubscription = + await marketplace.subscribe(RequestFulfilled, onRequestStarted) + let id = await client.requestStorage( cid, duration = duration, @@ -118,9 +126,8 @@ marketplacesuite "Marketplace": tolerance = ecTolerance, ) - check eventuallySafe( - await client.purchaseStateIs(id, "started"), timeout = 10 * 60 * 1000 - ) + await requestStartedFut + let purchase = (await client.getPurchase(id)).get check purchase.error == none string @@ -142,6 +149,7 @@ marketplacesuite "Marketplace": (await token.balanceOf(clientAccount)) - clientBalanceBeforeFinished > 0, timeout = 10 * 1000, # give client a bit of time to withdraw its funds ) + await startedSubscription.unsubscribe() test "SP are able to process slots after workers were busy with other slots and ignored them", NodeConfigs( diff --git a/tests/integration/testproofs.nim b/tests/integration/testproofs.nim index 19965d4b..6fc42a49 100644 --- a/tests/integration/testproofs.nim +++ b/tests/integration/testproofs.nim @@ -77,7 +77,8 @@ marketplacesuite "Hosts submit regular proofs": proc onProofSubmitted(event: ?!ProofSubmitted) = proofWasSubmitted = event.isOk - let proofSubmittedSubscription = await marketplace.subscribe(ProofSubmitted, onProofSubmitted) + let proofSubmittedSubscription = + await marketplace.subscribe(ProofSubmitted, onProofSubmitted) check eventually(proofWasSubmitted, timeout = (duration - expiry).int * 1000) @@ -119,7 +120,7 @@ marketplacesuite "Simulate invalid proofs": .some, ): let client0 = clients()[0].client - let expiry = 10.periods + let expiry = 15.periods let duration = expiry + 10.periods let data = await RandomChunker.example(blocks = blocks) diff --git a/tests/integration/testsales.nim b/tests/integration/testsales.nim index 1c102610..5e406e81 100644 --- a/tests/integration/testsales.nim +++ b/tests/integration/testsales.nim @@ -129,6 +129,14 @@ marketplacesuite "Sales": # Lets create storage request that will utilize some of the availability's space let cid = (await client.upload(data)).get + + var requestStartedFut = Future[void].Raising([CancelledError]).init() + proc onRequestStarted(eventResult: ?!RequestFulfilled) {.raises: [].} = + requestStartedFut.complete() + + let startedSubscription = + await marketplace.subscribe(RequestFulfilled, onRequestStarted) + let id = await client.requestStorage( cid, duration = 20 * 60.uint64, @@ -140,9 +148,8 @@ marketplacesuite "Sales": tolerance = 1, ) - check eventuallySafe( - await client.purchaseStateIs(id, "started"), timeout = 10 * 60 * 1000 - ) + await requestStartedFut + let updatedAvailability = ((await host.getAvailabilities()).get).findItem(availability).get check updatedAvailability.totalSize != updatedAvailability.freeSize @@ -164,6 +171,7 @@ marketplacesuite "Sales": ((await host.getAvailabilities()).get).findItem(availability).get check newUpdatedAvailability.totalSize == originalSize + 20000 check newUpdatedAvailability.freeSize - updatedAvailability.freeSize == 20000 + await startedSubscription.unsubscribe() test "updating availability fails with until negative", salesConfig: let availability = (