mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-10 01:13:10 +00:00
fix(integration): Use RequestFulfilled events instead of querying the purchase state
This commit is contained in:
parent
38d8692515
commit
c04eee72a3
@ -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(
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 = (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user