2022-03-23 12:57:48 +00:00
|
|
|
import std/times
|
2024-01-10 21:25:57 +00:00
|
|
|
import pkg/asynctest/chronos/unittest
|
2022-03-23 12:57:48 +00:00
|
|
|
import pkg/chronos
|
|
|
|
import pkg/stint
|
2022-05-19 19:56:03 +00:00
|
|
|
import pkg/codex/purchasing
|
2023-06-05 08:48:06 +00:00
|
|
|
import pkg/codex/purchasing/states/finished
|
|
|
|
import pkg/codex/purchasing/states/started
|
|
|
|
import pkg/codex/purchasing/states/submitted
|
|
|
|
import pkg/codex/purchasing/states/unknown
|
|
|
|
import pkg/codex/purchasing/states/cancelled
|
|
|
|
import pkg/codex/purchasing/states/failed
|
2022-03-23 12:57:48 +00:00
|
|
|
import ./helpers/mockmarket
|
2022-05-17 14:51:29 +00:00
|
|
|
import ./helpers/mockclock
|
2022-03-23 12:57:48 +00:00
|
|
|
import ./examples
|
2023-06-22 18:01:21 +00:00
|
|
|
import ./helpers
|
2022-03-23 12:57:48 +00:00
|
|
|
|
2023-06-22 18:01:21 +00:00
|
|
|
asyncchecksuite "Purchasing":
|
2022-03-23 12:57:48 +00:00
|
|
|
var purchasing: Purchasing
|
|
|
|
var market: MockMarket
|
2022-05-17 14:51:29 +00:00
|
|
|
var clock: MockClock
|
2022-03-24 09:00:40 +00:00
|
|
|
var request: StorageRequest
|
2022-03-23 12:57:48 +00:00
|
|
|
|
|
|
|
setup:
|
|
|
|
market = MockMarket.new()
|
2022-05-17 14:51:29 +00:00
|
|
|
clock = MockClock.new()
|
|
|
|
purchasing = Purchasing.new(market, clock)
|
2022-03-24 09:00:40 +00:00
|
|
|
request = StorageRequest(
|
2022-04-11 18:03:55 +00:00
|
|
|
ask: StorageAsk(
|
2022-08-02 12:21:12 +00:00
|
|
|
slots: uint8.example.uint64,
|
|
|
|
slotSize: uint32.example.u256,
|
2022-04-11 18:03:55 +00:00
|
|
|
duration: uint16.example.u256,
|
2022-08-02 12:21:12 +00:00
|
|
|
reward: uint8.example.u256
|
2022-04-11 18:03:55 +00:00
|
|
|
)
|
2022-03-24 09:00:40 +00:00
|
|
|
)
|
2022-03-23 12:57:48 +00:00
|
|
|
|
|
|
|
test "submits a storage request when asked":
|
2022-11-08 07:10:17 +00:00
|
|
|
discard await purchasing.purchase(request)
|
2023-06-05 08:48:06 +00:00
|
|
|
check eventually market.requested.len > 0
|
|
|
|
check market.requested[0].ask.slots == request.ask.slots
|
|
|
|
check market.requested[0].ask.slotSize == request.ask.slotSize
|
|
|
|
check market.requested[0].ask.duration == request.ask.duration
|
|
|
|
check market.requested[0].ask.reward == request.ask.reward
|
2022-03-23 12:57:48 +00:00
|
|
|
|
2022-05-11 07:14:43 +00:00
|
|
|
test "remembers purchases":
|
2022-11-08 07:10:17 +00:00
|
|
|
let purchase1 = await purchasing.purchase(request)
|
|
|
|
let purchase2 = await purchasing.purchase(request)
|
2022-05-11 07:14:43 +00:00
|
|
|
check purchasing.getPurchase(purchase1.id) == some purchase1
|
|
|
|
check purchasing.getPurchase(purchase2.id) == some purchase2
|
|
|
|
|
2022-03-23 12:57:48 +00:00
|
|
|
test "has a default value for proof probability":
|
|
|
|
check purchasing.proofProbability != 0.u256
|
|
|
|
|
|
|
|
test "can change default value for proof probability":
|
|
|
|
purchasing.proofProbability = 42.u256
|
2022-11-08 07:10:17 +00:00
|
|
|
discard await purchasing.purchase(request)
|
2023-06-05 08:48:06 +00:00
|
|
|
check eventually market.requested.len > 0
|
2022-04-11 18:03:55 +00:00
|
|
|
check market.requested[0].ask.proofProbability == 42.u256
|
2022-03-23 12:57:48 +00:00
|
|
|
|
|
|
|
test "can override proof probability per request":
|
2022-04-11 18:03:55 +00:00
|
|
|
request.ask.proofProbability = 42.u256
|
2022-11-08 07:10:17 +00:00
|
|
|
discard await purchasing.purchase(request)
|
2023-06-05 08:48:06 +00:00
|
|
|
check eventually market.requested.len > 0
|
2022-04-11 18:03:55 +00:00
|
|
|
check market.requested[0].ask.proofProbability == 42.u256
|
2022-03-23 12:57:48 +00:00
|
|
|
|
|
|
|
test "has a default value for request expiration interval":
|
|
|
|
check purchasing.requestExpiryInterval != 0.u256
|
|
|
|
|
|
|
|
test "can change default value for request expiration interval":
|
|
|
|
purchasing.requestExpiryInterval = 42.u256
|
|
|
|
let start = getTime().toUnix()
|
2022-11-08 07:10:17 +00:00
|
|
|
discard await purchasing.purchase(request)
|
2023-06-05 08:48:06 +00:00
|
|
|
check eventually market.requested.len > 0
|
2022-03-24 12:48:18 +00:00
|
|
|
check market.requested[0].expiry == (start + 42).u256
|
2022-03-23 12:57:48 +00:00
|
|
|
|
|
|
|
test "can override expiry time per request":
|
|
|
|
let expiry = (getTime().toUnix() + 42).u256
|
2022-03-24 09:00:40 +00:00
|
|
|
request.expiry = expiry
|
2022-11-08 07:10:17 +00:00
|
|
|
discard await purchasing.purchase(request)
|
2023-06-05 08:48:06 +00:00
|
|
|
check eventually market.requested.len > 0
|
2022-03-24 12:48:18 +00:00
|
|
|
check market.requested[0].expiry == expiry
|
2022-03-23 12:57:48 +00:00
|
|
|
|
|
|
|
test "includes a random nonce in every storage request":
|
2022-11-08 07:10:17 +00:00
|
|
|
discard await purchasing.purchase(request)
|
|
|
|
discard await purchasing.purchase(request)
|
2023-06-05 08:48:06 +00:00
|
|
|
check eventually market.requested.len > 0
|
2022-03-24 12:48:18 +00:00
|
|
|
check market.requested[0].nonce != market.requested[1].nonce
|
2022-03-28 10:28:22 +00:00
|
|
|
|
2022-11-08 07:10:17 +00:00
|
|
|
test "sets client address in request":
|
|
|
|
discard await purchasing.purchase(request)
|
2023-06-05 08:48:06 +00:00
|
|
|
check eventually market.requested.len > 0
|
2022-11-08 07:10:17 +00:00
|
|
|
check market.requested[0].client == await market.getSigner()
|
|
|
|
|
|
|
|
test "succeeds when request is finished":
|
|
|
|
let purchase = await purchasing.purchase(request)
|
2023-06-05 08:48:06 +00:00
|
|
|
check eventually market.requested.len > 0
|
2022-03-28 10:28:22 +00:00
|
|
|
let request = market.requested[0]
|
2022-11-08 07:10:17 +00:00
|
|
|
let requestEnd = getTime().toUnix() + 42
|
|
|
|
market.requestEnds[request.id] = requestEnd
|
2022-07-21 12:48:35 +00:00
|
|
|
market.emitRequestFulfilled(request.id)
|
2022-11-08 07:10:17 +00:00
|
|
|
clock.set(requestEnd)
|
2022-03-28 10:28:22 +00:00
|
|
|
await purchase.wait()
|
2022-06-14 13:25:48 +00:00
|
|
|
check purchase.error.isNone
|
2022-03-28 12:40:41 +00:00
|
|
|
|
2022-06-14 13:25:48 +00:00
|
|
|
test "fails when request times out":
|
2022-11-08 07:10:17 +00:00
|
|
|
let purchase = await purchasing.purchase(request)
|
2023-06-05 08:48:06 +00:00
|
|
|
check eventually market.requested.len > 0
|
2022-03-28 12:40:41 +00:00
|
|
|
let request = market.requested[0]
|
2023-10-24 10:12:54 +00:00
|
|
|
clock.set(request.expiry.truncate(int64) + 1)
|
2022-06-14 13:25:48 +00:00
|
|
|
expect PurchaseTimeout:
|
|
|
|
await purchase.wait()
|
2022-08-18 06:01:47 +00:00
|
|
|
|
2022-09-07 11:02:00 +00:00
|
|
|
test "checks that funds were withdrawn when purchase times out":
|
2022-11-08 07:10:17 +00:00
|
|
|
let purchase = await purchasing.purchase(request)
|
2023-06-05 08:48:06 +00:00
|
|
|
check eventually market.requested.len > 0
|
2022-08-18 06:01:47 +00:00
|
|
|
let request = market.requested[0]
|
2023-10-24 10:12:54 +00:00
|
|
|
clock.set(request.expiry.truncate(int64) + 1)
|
2022-11-08 07:10:17 +00:00
|
|
|
expect PurchaseTimeout:
|
|
|
|
await purchase.wait()
|
|
|
|
check market.withdrawn == @[request.id]
|
2022-09-07 11:02:00 +00:00
|
|
|
|
2023-06-22 18:01:21 +00:00
|
|
|
checksuite "Purchasing state machine":
|
2022-09-07 11:02:00 +00:00
|
|
|
|
2022-11-08 07:10:17 +00:00
|
|
|
var purchasing: Purchasing
|
|
|
|
var market: MockMarket
|
|
|
|
var clock: MockClock
|
|
|
|
var request: StorageRequest
|
|
|
|
|
|
|
|
setup:
|
|
|
|
market = MockMarket.new()
|
|
|
|
clock = MockClock.new()
|
|
|
|
purchasing = Purchasing.new(market, clock)
|
|
|
|
request = StorageRequest(
|
|
|
|
ask: StorageAsk(
|
|
|
|
slots: uint8.example.uint64,
|
|
|
|
slotSize: uint32.example.u256,
|
|
|
|
duration: uint16.example.u256,
|
|
|
|
reward: uint8.example.u256
|
|
|
|
)
|
|
|
|
)
|
2022-09-07 11:02:00 +00:00
|
|
|
|
2022-11-08 07:10:17 +00:00
|
|
|
test "loads active purchases from market":
|
|
|
|
let me = await market.getSigner()
|
|
|
|
let request1, request2, request3 = StorageRequest.example
|
|
|
|
market.requested = @[request1, request2, request3]
|
|
|
|
market.activeRequests[me] = @[request1.id, request2.id]
|
|
|
|
await purchasing.load()
|
|
|
|
check isSome purchasing.getPurchase(PurchaseId(request1.id))
|
|
|
|
check isSome purchasing.getPurchase(PurchaseId(request2.id))
|
|
|
|
check isNone purchasing.getPurchase(PurchaseId(request3.id))
|
|
|
|
|
|
|
|
test "loads correct purchase.future state for purchases from market":
|
|
|
|
let me = await market.getSigner()
|
|
|
|
let request1, request2, request3, request4, request5 = StorageRequest.example
|
|
|
|
market.requested = @[request1, request2, request3, request4, request5]
|
|
|
|
market.activeRequests[me] = @[request1.id, request2.id, request3.id, request4.id, request5.id]
|
[marketplace] Load sales state from chain (#306)
* [marketplace] get active slots from chain
# Conflicts:
# codex/contracts/market.nim
* [marketplace] make on chain event callbacks async
# Conflicts:
# tests/codex/helpers/mockmarket.nim
* [marketplace] make availability optional for node restart
# Conflicts:
# tests/codex/testsales.nim
* [marketplace] add async state machine
Allows for `enterAsync` to be cancelled.
* [marketplace] move sale process to async state machine
* [marketplace] sales state machine tests
* bump dagger-contracts
* [marketplace] fix ci issue with chronicles output
* PR comments
- add slotIndex to `SalesAgent` constructor
- remove `SalesAgent.init`
- rename `SalesAgent.init` to `start` and `SalesAgent.deinit` to `stop`.
- rename `SalesAgent. populateRequest` to `SalesAgent.retreiveRequest`.
- move availability removal to the downloading state. once availability is persisted to disk, it should survive node restarts.
-
* [marketplace] handle slot filled by other host
Handle the case when in the downloading, proving, or filling states, that another host fills the slot.
* [marketplace] use requestId for mySlots
* [marketplace] infer slot index from slotid
prevents reassigning a random slot index when restoring state from chain
* [marketplace] update to work with latest contracts
* [marketplace] clean up
* [marketplace] align with contract changes
- getState / state > requestState
- getSlot > getRequestFromSlotId
- support MarketplaceConfig
- support slotState, remove unneeded Slot type
- collateral > config.collateral.initialAmount
- remove proofPeriod contract call
- Revert reason “Slot empty” > “Slot is free”
- getProofEnd > read SlotState
Tests for changes
* [marketplace] add missing file
* [marketplace] bump codex-contracts-eth
* [config] remove unused imports
* [sales] cleanup
* [sales] fix: do not crash when fetching state fails
* [sales] make slotIndex non-optional
* Rebase and update NBS commit
Rebase on top of main and update NBS commit to the CI fix.
* [marketplace] use async subscription event handlers
* [marketplace] support slotIndex no longer optional
Previously, SalesAgent.slotIndex had been moved to not optional. However, there were still many places where optionality was assumed. This commit removes those assumuptions.
* [marketplace] sales state machine: use slotState
Use `slotState` instead of `requestState` for sales state machine.
* [marketplace] clean up
* [statemachine] adds a statemachine for async workflows
Allows events to be scheduled synchronously.
See https://github.com/status-im/nim-codex/pull/344
Co-Authored-By: Ben Bierens <thatbenbierens@gmail.com>
Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
* [market] make market callbacks synchronous
* [statemachine] export Event
* [statemachine] ensure that no errors are raised
* [statemachine] add machine parameter to run method
* [statemachine] initialize queue on start
* [statemachine] check futures before cancelling them
* [sales] use new async state machine
- states use new run() method and event mechanism
- StartState starts subscriptions and loads request
* [statemachine] fix unsusbscribe before subscribe
* [sales] replace old state transition tests
* [sales] separate state machine from sales data
* [sales] remove reference from SalesData to Sales
* [sales] separate sales context from sales
* [sales] move decoupled types into their own modules
* [sales] move retrieveRequest to SalesData
* [sales] move subscription logic into SalesAgent
* [sales] unsubscribe when finished or errored
* [build] revert back to released version of nim-ethers
* [sales] remove SaleStart state
* [sales] add missing base method
* [sales] move asyncSpawn helper to utils
* [sales] fix imports
* [sales] remove unused variables
* [sales statemachine] add async state machine error handling (#349)
* [statemachine] add error handling to asyncstatemachine
- add error handling to catch errors during state.run
- Sales: add ErrorState to identify which state to transition to during an error. This had to be added to SalesAgent constructor due to circular dependency issues, otherwise it would have been added directly to SalesAgent.
- Sales: when an error during run is encountered, the SaleErrorState is constructed with the error, and by default (base impl) will return the error state, so the machine can transition to it. This can be overridden by individual states if needed.
* [sales] rename onSaleFailed to onSaleErrored
Because there is already a state named SaleFailed which is meant to react to an onchain RequestFailed event and also because this callback is called from SaleErrored, renaming to onSaleErrored prevents ambiguity and confusion as to what has happened at the callback callsite.
* [statemachine] forward error to state directly
without going through a machine method first
* [statemachine] remove unnecessary error handling
AsyncQueueFullError is already handled in schedule()
* [statemachine] test that cancellation ignores onError
* [sales] simplify error handling in states
Rely on the state machine error handling instead
of catching errors in the state run method
---------
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
* [statemachine] prevent memory leaks
prevent memory leaks and nil access defects by:
- allowing multiple subscribe/unsubscribes of salesagent
- disallowing individual salesagent subscription calls to be made externally (requires the .subscribed check)
- allowing mutiple start/stops of asyncstatemachine
- disregard asyncstatemachine schedules if machine not yet started
* [salesagent] add salesagent-specific tests
1. test multiple subscribe/unsubscribes
2. test scheduling machine without being started
3. test subscriptions are working correctly with external events
4. test errors can be overridden at the state level for ErrorHandlingStates.
---------
Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
Co-authored-by: Ben Bierens <thatbenbierens@gmail.com>
2023-03-08 13:34:26 +00:00
|
|
|
market.requestState[request1.id] = RequestState.New
|
|
|
|
market.requestState[request2.id] = RequestState.Started
|
|
|
|
market.requestState[request3.id] = RequestState.Cancelled
|
|
|
|
market.requestState[request4.id] = RequestState.Finished
|
|
|
|
market.requestState[request5.id] = RequestState.Failed
|
2022-11-08 07:10:17 +00:00
|
|
|
|
|
|
|
# ensure the started state doesn't error, giving a false positive test result
|
|
|
|
market.requestEnds[request2.id] = clock.now() - 1
|
|
|
|
|
|
|
|
await purchasing.load()
|
2023-06-05 08:48:06 +00:00
|
|
|
check eventually purchasing.getPurchase(PurchaseId(request1.id)).?finished == false.some
|
|
|
|
check eventually purchasing.getPurchase(PurchaseId(request2.id)).?finished == true.some
|
|
|
|
check eventually purchasing.getPurchase(PurchaseId(request3.id)).?finished == true.some
|
|
|
|
check eventually purchasing.getPurchase(PurchaseId(request4.id)).?finished == true.some
|
|
|
|
check eventually purchasing.getPurchase(PurchaseId(request5.id)).?finished == true.some
|
|
|
|
check eventually purchasing.getPurchase(PurchaseId(request5.id)).?error.isSome
|
2022-11-08 07:10:17 +00:00
|
|
|
|
|
|
|
test "moves to PurchaseSubmitted when request state is New":
|
|
|
|
let request = StorageRequest.example
|
|
|
|
let purchase = Purchase.new(request, market, clock)
|
|
|
|
market.requested = @[request]
|
[marketplace] Load sales state from chain (#306)
* [marketplace] get active slots from chain
# Conflicts:
# codex/contracts/market.nim
* [marketplace] make on chain event callbacks async
# Conflicts:
# tests/codex/helpers/mockmarket.nim
* [marketplace] make availability optional for node restart
# Conflicts:
# tests/codex/testsales.nim
* [marketplace] add async state machine
Allows for `enterAsync` to be cancelled.
* [marketplace] move sale process to async state machine
* [marketplace] sales state machine tests
* bump dagger-contracts
* [marketplace] fix ci issue with chronicles output
* PR comments
- add slotIndex to `SalesAgent` constructor
- remove `SalesAgent.init`
- rename `SalesAgent.init` to `start` and `SalesAgent.deinit` to `stop`.
- rename `SalesAgent. populateRequest` to `SalesAgent.retreiveRequest`.
- move availability removal to the downloading state. once availability is persisted to disk, it should survive node restarts.
-
* [marketplace] handle slot filled by other host
Handle the case when in the downloading, proving, or filling states, that another host fills the slot.
* [marketplace] use requestId for mySlots
* [marketplace] infer slot index from slotid
prevents reassigning a random slot index when restoring state from chain
* [marketplace] update to work with latest contracts
* [marketplace] clean up
* [marketplace] align with contract changes
- getState / state > requestState
- getSlot > getRequestFromSlotId
- support MarketplaceConfig
- support slotState, remove unneeded Slot type
- collateral > config.collateral.initialAmount
- remove proofPeriod contract call
- Revert reason “Slot empty” > “Slot is free”
- getProofEnd > read SlotState
Tests for changes
* [marketplace] add missing file
* [marketplace] bump codex-contracts-eth
* [config] remove unused imports
* [sales] cleanup
* [sales] fix: do not crash when fetching state fails
* [sales] make slotIndex non-optional
* Rebase and update NBS commit
Rebase on top of main and update NBS commit to the CI fix.
* [marketplace] use async subscription event handlers
* [marketplace] support slotIndex no longer optional
Previously, SalesAgent.slotIndex had been moved to not optional. However, there were still many places where optionality was assumed. This commit removes those assumuptions.
* [marketplace] sales state machine: use slotState
Use `slotState` instead of `requestState` for sales state machine.
* [marketplace] clean up
* [statemachine] adds a statemachine for async workflows
Allows events to be scheduled synchronously.
See https://github.com/status-im/nim-codex/pull/344
Co-Authored-By: Ben Bierens <thatbenbierens@gmail.com>
Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
* [market] make market callbacks synchronous
* [statemachine] export Event
* [statemachine] ensure that no errors are raised
* [statemachine] add machine parameter to run method
* [statemachine] initialize queue on start
* [statemachine] check futures before cancelling them
* [sales] use new async state machine
- states use new run() method and event mechanism
- StartState starts subscriptions and loads request
* [statemachine] fix unsusbscribe before subscribe
* [sales] replace old state transition tests
* [sales] separate state machine from sales data
* [sales] remove reference from SalesData to Sales
* [sales] separate sales context from sales
* [sales] move decoupled types into their own modules
* [sales] move retrieveRequest to SalesData
* [sales] move subscription logic into SalesAgent
* [sales] unsubscribe when finished or errored
* [build] revert back to released version of nim-ethers
* [sales] remove SaleStart state
* [sales] add missing base method
* [sales] move asyncSpawn helper to utils
* [sales] fix imports
* [sales] remove unused variables
* [sales statemachine] add async state machine error handling (#349)
* [statemachine] add error handling to asyncstatemachine
- add error handling to catch errors during state.run
- Sales: add ErrorState to identify which state to transition to during an error. This had to be added to SalesAgent constructor due to circular dependency issues, otherwise it would have been added directly to SalesAgent.
- Sales: when an error during run is encountered, the SaleErrorState is constructed with the error, and by default (base impl) will return the error state, so the machine can transition to it. This can be overridden by individual states if needed.
* [sales] rename onSaleFailed to onSaleErrored
Because there is already a state named SaleFailed which is meant to react to an onchain RequestFailed event and also because this callback is called from SaleErrored, renaming to onSaleErrored prevents ambiguity and confusion as to what has happened at the callback callsite.
* [statemachine] forward error to state directly
without going through a machine method first
* [statemachine] remove unnecessary error handling
AsyncQueueFullError is already handled in schedule()
* [statemachine] test that cancellation ignores onError
* [sales] simplify error handling in states
Rely on the state machine error handling instead
of catching errors in the state run method
---------
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
* [statemachine] prevent memory leaks
prevent memory leaks and nil access defects by:
- allowing multiple subscribe/unsubscribes of salesagent
- disallowing individual salesagent subscription calls to be made externally (requires the .subscribed check)
- allowing mutiple start/stops of asyncstatemachine
- disregard asyncstatemachine schedules if machine not yet started
* [salesagent] add salesagent-specific tests
1. test multiple subscribe/unsubscribes
2. test scheduling machine without being started
3. test subscriptions are working correctly with external events
4. test errors can be overridden at the state level for ErrorHandlingStates.
---------
Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
Co-authored-by: Ben Bierens <thatbenbierens@gmail.com>
2023-03-08 13:34:26 +00:00
|
|
|
market.requestState[request.id] = RequestState.New
|
2023-06-05 08:48:06 +00:00
|
|
|
let next = await PurchaseUnknown().run(purchase)
|
|
|
|
check !next of PurchaseSubmitted
|
2022-11-08 07:10:17 +00:00
|
|
|
|
|
|
|
test "moves to PurchaseStarted when request state is Started":
|
|
|
|
let request = StorageRequest.example
|
|
|
|
let purchase = Purchase.new(request, market, clock)
|
|
|
|
market.requestEnds[request.id] = clock.now() + request.ask.duration.truncate(int64)
|
|
|
|
market.requested = @[request]
|
[marketplace] Load sales state from chain (#306)
* [marketplace] get active slots from chain
# Conflicts:
# codex/contracts/market.nim
* [marketplace] make on chain event callbacks async
# Conflicts:
# tests/codex/helpers/mockmarket.nim
* [marketplace] make availability optional for node restart
# Conflicts:
# tests/codex/testsales.nim
* [marketplace] add async state machine
Allows for `enterAsync` to be cancelled.
* [marketplace] move sale process to async state machine
* [marketplace] sales state machine tests
* bump dagger-contracts
* [marketplace] fix ci issue with chronicles output
* PR comments
- add slotIndex to `SalesAgent` constructor
- remove `SalesAgent.init`
- rename `SalesAgent.init` to `start` and `SalesAgent.deinit` to `stop`.
- rename `SalesAgent. populateRequest` to `SalesAgent.retreiveRequest`.
- move availability removal to the downloading state. once availability is persisted to disk, it should survive node restarts.
-
* [marketplace] handle slot filled by other host
Handle the case when in the downloading, proving, or filling states, that another host fills the slot.
* [marketplace] use requestId for mySlots
* [marketplace] infer slot index from slotid
prevents reassigning a random slot index when restoring state from chain
* [marketplace] update to work with latest contracts
* [marketplace] clean up
* [marketplace] align with contract changes
- getState / state > requestState
- getSlot > getRequestFromSlotId
- support MarketplaceConfig
- support slotState, remove unneeded Slot type
- collateral > config.collateral.initialAmount
- remove proofPeriod contract call
- Revert reason “Slot empty” > “Slot is free”
- getProofEnd > read SlotState
Tests for changes
* [marketplace] add missing file
* [marketplace] bump codex-contracts-eth
* [config] remove unused imports
* [sales] cleanup
* [sales] fix: do not crash when fetching state fails
* [sales] make slotIndex non-optional
* Rebase and update NBS commit
Rebase on top of main and update NBS commit to the CI fix.
* [marketplace] use async subscription event handlers
* [marketplace] support slotIndex no longer optional
Previously, SalesAgent.slotIndex had been moved to not optional. However, there were still many places where optionality was assumed. This commit removes those assumuptions.
* [marketplace] sales state machine: use slotState
Use `slotState` instead of `requestState` for sales state machine.
* [marketplace] clean up
* [statemachine] adds a statemachine for async workflows
Allows events to be scheduled synchronously.
See https://github.com/status-im/nim-codex/pull/344
Co-Authored-By: Ben Bierens <thatbenbierens@gmail.com>
Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
* [market] make market callbacks synchronous
* [statemachine] export Event
* [statemachine] ensure that no errors are raised
* [statemachine] add machine parameter to run method
* [statemachine] initialize queue on start
* [statemachine] check futures before cancelling them
* [sales] use new async state machine
- states use new run() method and event mechanism
- StartState starts subscriptions and loads request
* [statemachine] fix unsusbscribe before subscribe
* [sales] replace old state transition tests
* [sales] separate state machine from sales data
* [sales] remove reference from SalesData to Sales
* [sales] separate sales context from sales
* [sales] move decoupled types into their own modules
* [sales] move retrieveRequest to SalesData
* [sales] move subscription logic into SalesAgent
* [sales] unsubscribe when finished or errored
* [build] revert back to released version of nim-ethers
* [sales] remove SaleStart state
* [sales] add missing base method
* [sales] move asyncSpawn helper to utils
* [sales] fix imports
* [sales] remove unused variables
* [sales statemachine] add async state machine error handling (#349)
* [statemachine] add error handling to asyncstatemachine
- add error handling to catch errors during state.run
- Sales: add ErrorState to identify which state to transition to during an error. This had to be added to SalesAgent constructor due to circular dependency issues, otherwise it would have been added directly to SalesAgent.
- Sales: when an error during run is encountered, the SaleErrorState is constructed with the error, and by default (base impl) will return the error state, so the machine can transition to it. This can be overridden by individual states if needed.
* [sales] rename onSaleFailed to onSaleErrored
Because there is already a state named SaleFailed which is meant to react to an onchain RequestFailed event and also because this callback is called from SaleErrored, renaming to onSaleErrored prevents ambiguity and confusion as to what has happened at the callback callsite.
* [statemachine] forward error to state directly
without going through a machine method first
* [statemachine] remove unnecessary error handling
AsyncQueueFullError is already handled in schedule()
* [statemachine] test that cancellation ignores onError
* [sales] simplify error handling in states
Rely on the state machine error handling instead
of catching errors in the state run method
---------
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
* [statemachine] prevent memory leaks
prevent memory leaks and nil access defects by:
- allowing multiple subscribe/unsubscribes of salesagent
- disallowing individual salesagent subscription calls to be made externally (requires the .subscribed check)
- allowing mutiple start/stops of asyncstatemachine
- disregard asyncstatemachine schedules if machine not yet started
* [salesagent] add salesagent-specific tests
1. test multiple subscribe/unsubscribes
2. test scheduling machine without being started
3. test subscriptions are working correctly with external events
4. test errors can be overridden at the state level for ErrorHandlingStates.
---------
Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
Co-authored-by: Ben Bierens <thatbenbierens@gmail.com>
2023-03-08 13:34:26 +00:00
|
|
|
market.requestState[request.id] = RequestState.Started
|
2023-06-05 08:48:06 +00:00
|
|
|
let next = await PurchaseUnknown().run(purchase)
|
|
|
|
check !next of PurchaseStarted
|
2022-11-08 07:10:17 +00:00
|
|
|
|
2023-06-05 08:48:06 +00:00
|
|
|
test "moves to PurchaseCancelled when request state is Cancelled":
|
2022-11-08 07:10:17 +00:00
|
|
|
let request = StorageRequest.example
|
|
|
|
let purchase = Purchase.new(request, market, clock)
|
|
|
|
market.requested = @[request]
|
[marketplace] Load sales state from chain (#306)
* [marketplace] get active slots from chain
# Conflicts:
# codex/contracts/market.nim
* [marketplace] make on chain event callbacks async
# Conflicts:
# tests/codex/helpers/mockmarket.nim
* [marketplace] make availability optional for node restart
# Conflicts:
# tests/codex/testsales.nim
* [marketplace] add async state machine
Allows for `enterAsync` to be cancelled.
* [marketplace] move sale process to async state machine
* [marketplace] sales state machine tests
* bump dagger-contracts
* [marketplace] fix ci issue with chronicles output
* PR comments
- add slotIndex to `SalesAgent` constructor
- remove `SalesAgent.init`
- rename `SalesAgent.init` to `start` and `SalesAgent.deinit` to `stop`.
- rename `SalesAgent. populateRequest` to `SalesAgent.retreiveRequest`.
- move availability removal to the downloading state. once availability is persisted to disk, it should survive node restarts.
-
* [marketplace] handle slot filled by other host
Handle the case when in the downloading, proving, or filling states, that another host fills the slot.
* [marketplace] use requestId for mySlots
* [marketplace] infer slot index from slotid
prevents reassigning a random slot index when restoring state from chain
* [marketplace] update to work with latest contracts
* [marketplace] clean up
* [marketplace] align with contract changes
- getState / state > requestState
- getSlot > getRequestFromSlotId
- support MarketplaceConfig
- support slotState, remove unneeded Slot type
- collateral > config.collateral.initialAmount
- remove proofPeriod contract call
- Revert reason “Slot empty” > “Slot is free”
- getProofEnd > read SlotState
Tests for changes
* [marketplace] add missing file
* [marketplace] bump codex-contracts-eth
* [config] remove unused imports
* [sales] cleanup
* [sales] fix: do not crash when fetching state fails
* [sales] make slotIndex non-optional
* Rebase and update NBS commit
Rebase on top of main and update NBS commit to the CI fix.
* [marketplace] use async subscription event handlers
* [marketplace] support slotIndex no longer optional
Previously, SalesAgent.slotIndex had been moved to not optional. However, there were still many places where optionality was assumed. This commit removes those assumuptions.
* [marketplace] sales state machine: use slotState
Use `slotState` instead of `requestState` for sales state machine.
* [marketplace] clean up
* [statemachine] adds a statemachine for async workflows
Allows events to be scheduled synchronously.
See https://github.com/status-im/nim-codex/pull/344
Co-Authored-By: Ben Bierens <thatbenbierens@gmail.com>
Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
* [market] make market callbacks synchronous
* [statemachine] export Event
* [statemachine] ensure that no errors are raised
* [statemachine] add machine parameter to run method
* [statemachine] initialize queue on start
* [statemachine] check futures before cancelling them
* [sales] use new async state machine
- states use new run() method and event mechanism
- StartState starts subscriptions and loads request
* [statemachine] fix unsusbscribe before subscribe
* [sales] replace old state transition tests
* [sales] separate state machine from sales data
* [sales] remove reference from SalesData to Sales
* [sales] separate sales context from sales
* [sales] move decoupled types into their own modules
* [sales] move retrieveRequest to SalesData
* [sales] move subscription logic into SalesAgent
* [sales] unsubscribe when finished or errored
* [build] revert back to released version of nim-ethers
* [sales] remove SaleStart state
* [sales] add missing base method
* [sales] move asyncSpawn helper to utils
* [sales] fix imports
* [sales] remove unused variables
* [sales statemachine] add async state machine error handling (#349)
* [statemachine] add error handling to asyncstatemachine
- add error handling to catch errors during state.run
- Sales: add ErrorState to identify which state to transition to during an error. This had to be added to SalesAgent constructor due to circular dependency issues, otherwise it would have been added directly to SalesAgent.
- Sales: when an error during run is encountered, the SaleErrorState is constructed with the error, and by default (base impl) will return the error state, so the machine can transition to it. This can be overridden by individual states if needed.
* [sales] rename onSaleFailed to onSaleErrored
Because there is already a state named SaleFailed which is meant to react to an onchain RequestFailed event and also because this callback is called from SaleErrored, renaming to onSaleErrored prevents ambiguity and confusion as to what has happened at the callback callsite.
* [statemachine] forward error to state directly
without going through a machine method first
* [statemachine] remove unnecessary error handling
AsyncQueueFullError is already handled in schedule()
* [statemachine] test that cancellation ignores onError
* [sales] simplify error handling in states
Rely on the state machine error handling instead
of catching errors in the state run method
---------
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
* [statemachine] prevent memory leaks
prevent memory leaks and nil access defects by:
- allowing multiple subscribe/unsubscribes of salesagent
- disallowing individual salesagent subscription calls to be made externally (requires the .subscribed check)
- allowing mutiple start/stops of asyncstatemachine
- disregard asyncstatemachine schedules if machine not yet started
* [salesagent] add salesagent-specific tests
1. test multiple subscribe/unsubscribes
2. test scheduling machine without being started
3. test subscriptions are working correctly with external events
4. test errors can be overridden at the state level for ErrorHandlingStates.
---------
Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
Co-authored-by: Ben Bierens <thatbenbierens@gmail.com>
2023-03-08 13:34:26 +00:00
|
|
|
market.requestState[request.id] = RequestState.Cancelled
|
2023-06-05 08:48:06 +00:00
|
|
|
let next = await PurchaseUnknown().run(purchase)
|
|
|
|
check !next of PurchaseCancelled
|
2022-11-08 07:10:17 +00:00
|
|
|
|
|
|
|
test "moves to PurchaseFinished when request state is Finished":
|
|
|
|
let request = StorageRequest.example
|
|
|
|
let purchase = Purchase.new(request, market, clock)
|
|
|
|
market.requested = @[request]
|
[marketplace] Load sales state from chain (#306)
* [marketplace] get active slots from chain
# Conflicts:
# codex/contracts/market.nim
* [marketplace] make on chain event callbacks async
# Conflicts:
# tests/codex/helpers/mockmarket.nim
* [marketplace] make availability optional for node restart
# Conflicts:
# tests/codex/testsales.nim
* [marketplace] add async state machine
Allows for `enterAsync` to be cancelled.
* [marketplace] move sale process to async state machine
* [marketplace] sales state machine tests
* bump dagger-contracts
* [marketplace] fix ci issue with chronicles output
* PR comments
- add slotIndex to `SalesAgent` constructor
- remove `SalesAgent.init`
- rename `SalesAgent.init` to `start` and `SalesAgent.deinit` to `stop`.
- rename `SalesAgent. populateRequest` to `SalesAgent.retreiveRequest`.
- move availability removal to the downloading state. once availability is persisted to disk, it should survive node restarts.
-
* [marketplace] handle slot filled by other host
Handle the case when in the downloading, proving, or filling states, that another host fills the slot.
* [marketplace] use requestId for mySlots
* [marketplace] infer slot index from slotid
prevents reassigning a random slot index when restoring state from chain
* [marketplace] update to work with latest contracts
* [marketplace] clean up
* [marketplace] align with contract changes
- getState / state > requestState
- getSlot > getRequestFromSlotId
- support MarketplaceConfig
- support slotState, remove unneeded Slot type
- collateral > config.collateral.initialAmount
- remove proofPeriod contract call
- Revert reason “Slot empty” > “Slot is free”
- getProofEnd > read SlotState
Tests for changes
* [marketplace] add missing file
* [marketplace] bump codex-contracts-eth
* [config] remove unused imports
* [sales] cleanup
* [sales] fix: do not crash when fetching state fails
* [sales] make slotIndex non-optional
* Rebase and update NBS commit
Rebase on top of main and update NBS commit to the CI fix.
* [marketplace] use async subscription event handlers
* [marketplace] support slotIndex no longer optional
Previously, SalesAgent.slotIndex had been moved to not optional. However, there were still many places where optionality was assumed. This commit removes those assumuptions.
* [marketplace] sales state machine: use slotState
Use `slotState` instead of `requestState` for sales state machine.
* [marketplace] clean up
* [statemachine] adds a statemachine for async workflows
Allows events to be scheduled synchronously.
See https://github.com/status-im/nim-codex/pull/344
Co-Authored-By: Ben Bierens <thatbenbierens@gmail.com>
Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
* [market] make market callbacks synchronous
* [statemachine] export Event
* [statemachine] ensure that no errors are raised
* [statemachine] add machine parameter to run method
* [statemachine] initialize queue on start
* [statemachine] check futures before cancelling them
* [sales] use new async state machine
- states use new run() method and event mechanism
- StartState starts subscriptions and loads request
* [statemachine] fix unsusbscribe before subscribe
* [sales] replace old state transition tests
* [sales] separate state machine from sales data
* [sales] remove reference from SalesData to Sales
* [sales] separate sales context from sales
* [sales] move decoupled types into their own modules
* [sales] move retrieveRequest to SalesData
* [sales] move subscription logic into SalesAgent
* [sales] unsubscribe when finished or errored
* [build] revert back to released version of nim-ethers
* [sales] remove SaleStart state
* [sales] add missing base method
* [sales] move asyncSpawn helper to utils
* [sales] fix imports
* [sales] remove unused variables
* [sales statemachine] add async state machine error handling (#349)
* [statemachine] add error handling to asyncstatemachine
- add error handling to catch errors during state.run
- Sales: add ErrorState to identify which state to transition to during an error. This had to be added to SalesAgent constructor due to circular dependency issues, otherwise it would have been added directly to SalesAgent.
- Sales: when an error during run is encountered, the SaleErrorState is constructed with the error, and by default (base impl) will return the error state, so the machine can transition to it. This can be overridden by individual states if needed.
* [sales] rename onSaleFailed to onSaleErrored
Because there is already a state named SaleFailed which is meant to react to an onchain RequestFailed event and also because this callback is called from SaleErrored, renaming to onSaleErrored prevents ambiguity and confusion as to what has happened at the callback callsite.
* [statemachine] forward error to state directly
without going through a machine method first
* [statemachine] remove unnecessary error handling
AsyncQueueFullError is already handled in schedule()
* [statemachine] test that cancellation ignores onError
* [sales] simplify error handling in states
Rely on the state machine error handling instead
of catching errors in the state run method
---------
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
* [statemachine] prevent memory leaks
prevent memory leaks and nil access defects by:
- allowing multiple subscribe/unsubscribes of salesagent
- disallowing individual salesagent subscription calls to be made externally (requires the .subscribed check)
- allowing mutiple start/stops of asyncstatemachine
- disregard asyncstatemachine schedules if machine not yet started
* [salesagent] add salesagent-specific tests
1. test multiple subscribe/unsubscribes
2. test scheduling machine without being started
3. test subscriptions are working correctly with external events
4. test errors can be overridden at the state level for ErrorHandlingStates.
---------
Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
Co-authored-by: Ben Bierens <thatbenbierens@gmail.com>
2023-03-08 13:34:26 +00:00
|
|
|
market.requestState[request.id] = RequestState.Finished
|
2023-06-05 08:48:06 +00:00
|
|
|
let next = await PurchaseUnknown().run(purchase)
|
|
|
|
check !next of PurchaseFinished
|
2022-11-08 07:10:17 +00:00
|
|
|
|
2023-06-05 08:48:06 +00:00
|
|
|
test "moves to PurchaseFailed when request state is Failed":
|
2022-11-08 07:10:17 +00:00
|
|
|
let request = StorageRequest.example
|
|
|
|
let purchase = Purchase.new(request, market, clock)
|
|
|
|
market.requested = @[request]
|
[marketplace] Load sales state from chain (#306)
* [marketplace] get active slots from chain
# Conflicts:
# codex/contracts/market.nim
* [marketplace] make on chain event callbacks async
# Conflicts:
# tests/codex/helpers/mockmarket.nim
* [marketplace] make availability optional for node restart
# Conflicts:
# tests/codex/testsales.nim
* [marketplace] add async state machine
Allows for `enterAsync` to be cancelled.
* [marketplace] move sale process to async state machine
* [marketplace] sales state machine tests
* bump dagger-contracts
* [marketplace] fix ci issue with chronicles output
* PR comments
- add slotIndex to `SalesAgent` constructor
- remove `SalesAgent.init`
- rename `SalesAgent.init` to `start` and `SalesAgent.deinit` to `stop`.
- rename `SalesAgent. populateRequest` to `SalesAgent.retreiveRequest`.
- move availability removal to the downloading state. once availability is persisted to disk, it should survive node restarts.
-
* [marketplace] handle slot filled by other host
Handle the case when in the downloading, proving, or filling states, that another host fills the slot.
* [marketplace] use requestId for mySlots
* [marketplace] infer slot index from slotid
prevents reassigning a random slot index when restoring state from chain
* [marketplace] update to work with latest contracts
* [marketplace] clean up
* [marketplace] align with contract changes
- getState / state > requestState
- getSlot > getRequestFromSlotId
- support MarketplaceConfig
- support slotState, remove unneeded Slot type
- collateral > config.collateral.initialAmount
- remove proofPeriod contract call
- Revert reason “Slot empty” > “Slot is free”
- getProofEnd > read SlotState
Tests for changes
* [marketplace] add missing file
* [marketplace] bump codex-contracts-eth
* [config] remove unused imports
* [sales] cleanup
* [sales] fix: do not crash when fetching state fails
* [sales] make slotIndex non-optional
* Rebase and update NBS commit
Rebase on top of main and update NBS commit to the CI fix.
* [marketplace] use async subscription event handlers
* [marketplace] support slotIndex no longer optional
Previously, SalesAgent.slotIndex had been moved to not optional. However, there were still many places where optionality was assumed. This commit removes those assumuptions.
* [marketplace] sales state machine: use slotState
Use `slotState` instead of `requestState` for sales state machine.
* [marketplace] clean up
* [statemachine] adds a statemachine for async workflows
Allows events to be scheduled synchronously.
See https://github.com/status-im/nim-codex/pull/344
Co-Authored-By: Ben Bierens <thatbenbierens@gmail.com>
Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
* [market] make market callbacks synchronous
* [statemachine] export Event
* [statemachine] ensure that no errors are raised
* [statemachine] add machine parameter to run method
* [statemachine] initialize queue on start
* [statemachine] check futures before cancelling them
* [sales] use new async state machine
- states use new run() method and event mechanism
- StartState starts subscriptions and loads request
* [statemachine] fix unsusbscribe before subscribe
* [sales] replace old state transition tests
* [sales] separate state machine from sales data
* [sales] remove reference from SalesData to Sales
* [sales] separate sales context from sales
* [sales] move decoupled types into their own modules
* [sales] move retrieveRequest to SalesData
* [sales] move subscription logic into SalesAgent
* [sales] unsubscribe when finished or errored
* [build] revert back to released version of nim-ethers
* [sales] remove SaleStart state
* [sales] add missing base method
* [sales] move asyncSpawn helper to utils
* [sales] fix imports
* [sales] remove unused variables
* [sales statemachine] add async state machine error handling (#349)
* [statemachine] add error handling to asyncstatemachine
- add error handling to catch errors during state.run
- Sales: add ErrorState to identify which state to transition to during an error. This had to be added to SalesAgent constructor due to circular dependency issues, otherwise it would have been added directly to SalesAgent.
- Sales: when an error during run is encountered, the SaleErrorState is constructed with the error, and by default (base impl) will return the error state, so the machine can transition to it. This can be overridden by individual states if needed.
* [sales] rename onSaleFailed to onSaleErrored
Because there is already a state named SaleFailed which is meant to react to an onchain RequestFailed event and also because this callback is called from SaleErrored, renaming to onSaleErrored prevents ambiguity and confusion as to what has happened at the callback callsite.
* [statemachine] forward error to state directly
without going through a machine method first
* [statemachine] remove unnecessary error handling
AsyncQueueFullError is already handled in schedule()
* [statemachine] test that cancellation ignores onError
* [sales] simplify error handling in states
Rely on the state machine error handling instead
of catching errors in the state run method
---------
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
* [statemachine] prevent memory leaks
prevent memory leaks and nil access defects by:
- allowing multiple subscribe/unsubscribes of salesagent
- disallowing individual salesagent subscription calls to be made externally (requires the .subscribed check)
- allowing mutiple start/stops of asyncstatemachine
- disregard asyncstatemachine schedules if machine not yet started
* [salesagent] add salesagent-specific tests
1. test multiple subscribe/unsubscribes
2. test scheduling machine without being started
3. test subscriptions are working correctly with external events
4. test errors can be overridden at the state level for ErrorHandlingStates.
---------
Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
Co-authored-by: Ben Bierens <thatbenbierens@gmail.com>
2023-03-08 13:34:26 +00:00
|
|
|
market.requestState[request.id] = RequestState.Failed
|
2023-06-05 08:48:06 +00:00
|
|
|
let next = await PurchaseUnknown().run(purchase)
|
|
|
|
check !next of PurchaseFailed
|
2022-11-08 07:10:17 +00:00
|
|
|
|
2023-06-05 08:48:06 +00:00
|
|
|
test "moves to PurchaseFailed state once RequestFailed emitted":
|
2022-11-08 07:10:17 +00:00
|
|
|
let request = StorageRequest.example
|
2023-06-05 08:48:06 +00:00
|
|
|
let purchase = Purchase.new(request, market, clock)
|
2022-11-08 07:10:17 +00:00
|
|
|
market.requestEnds[request.id] = clock.now() + request.ask.duration.truncate(int64)
|
2023-06-05 08:48:06 +00:00
|
|
|
let future = PurchaseStarted().run(purchase)
|
2022-11-08 07:10:17 +00:00
|
|
|
|
|
|
|
market.emitRequestFailed(request.id)
|
|
|
|
|
2023-06-05 08:48:06 +00:00
|
|
|
let next = await future
|
|
|
|
check !next of PurchaseFailed
|
2022-11-08 07:10:17 +00:00
|
|
|
|
|
|
|
test "moves to PurchaseFinished state once request finishes":
|
|
|
|
let request = StorageRequest.example
|
2023-06-05 08:48:06 +00:00
|
|
|
let purchase = Purchase.new(request, market, clock)
|
2022-11-08 07:10:17 +00:00
|
|
|
market.requestEnds[request.id] = clock.now() + request.ask.duration.truncate(int64)
|
2023-06-05 08:48:06 +00:00
|
|
|
let future = PurchaseStarted().run(purchase)
|
2022-11-08 07:10:17 +00:00
|
|
|
|
|
|
|
clock.advance(request.ask.duration.truncate(int64))
|
|
|
|
|
2023-06-05 08:48:06 +00:00
|
|
|
let next = await future
|
|
|
|
check !next of PurchaseFinished
|