2023-03-09 11:23:45 +00:00
|
|
|
import std/json
|
|
|
|
import pkg/chronos
|
[marketplace] Add Reservations Module (#340)
* [marketplace] reservations module
- add de/serialization for Availability
- add markUsed/markUnused in persisted availability
- add query for unused
- add reserve/release
- reservation module tests
- split ContractInteractions into client contracts and host contracts
- remove reservations start/stop as the repo start/stop is being managed by the node
- remove dedicated reservations metadata store and use the metadata store from the repo instead
- Split ContractInteractions into:
- ClientInteractions (with purchasing)
- HostInteractions (with sales and proving)
- compilation fix for nim 1.2
[repostore] fix started flag, add tests
[marketplace] persist slot index
For loading the sales state from chain, the slot index was not previously persisted in the contract. Will retrieve the slot index from the contract when the sales state is loaded.
* Revert repostore changes
In favour of separate PR https://github.com/status-im/nim-codex/pull/374.
* remove warnings
* clean up
* tests: stop repostore during teardown
* change constructor type identifier
Change Contracts constructor to accept Contracts type instead of ContractInteractions.
* change constructor return type to Result instead of Option
* fix and split interactions tests
* clean up, fix tests
* find availability by slot id
* remove duplication in host/client interactions
* add test for finding availability by slotId
* log instead of raiseAssert when failed to mark availability as unused
* move to SaleErrored state instead of raiseAssert
* remove unneeded reverse
It appears that order is not preserved in the repostore, so reversing does not have the intended effect here.
* update open api spec for potential rest endpoint errors
* move functions about available bytes to repostore
* WIP: reserve and release availabilities as needed
WIP: not tested yet
Availabilities are marked as used when matched (just before downloading starts) so that future matching logic does not match an availability currently in use.
As the download progresses, batches of blocks are written to disk, and the equivalent bytes are released from the reservation module. The size of the availability is reduced as well.
During a reserve or release operation, availability updates occur after the repo is manipulated. If the availability update operation fails, the reserve or release is rolled back to maintain correct accounting of bytes.
Finally, once download completes, or if an error occurs, the availability is marked as unused so future matching can occur.
* delete availability when all bytes released
* fix tests + cleanup
* remove availability from SalesContext callbacks
Availability is no longer used past the SaleDownloading state in the state machine. Cleanup of Availability (marking unused) is handled directly in the SaleDownloading state, and no longer in SaleErrored or SaleFinished. Likewise, Availabilities shouldn’t need to be handled on node restart.
Additionally, Availability was being passed in SalesContext callbacks, and now that Availability is only used temporarily in the SaleDownloading state, Availability is contextually irrelevant to the callbacks, except in OnStore possibly, though it was not being consumed.
* test clean up
* - remove availability from callbacks and constructors from previous commit that needed to be removed (oopsie)
- fix integration test that checks availabilities
- there was a bug fixed that crashed the node due to a missing `return success` in onStore
- the test was fixed by ensuring that availabilities are remaining on the node, and the size has been reduced
- change Availability back to non-ref object and constructor back to init
- add trace logging of all state transitions in state machine
- add generally useful trace logging
* fixes after rebase
1. Fix onProve callbacks
2. Use Slot type instead of tuple for retrieving active slot.
3. Bump codex-contracts-eth that exposes getActivceSlot call.
* swap contracts branch to not support slot collateral
Slot collateral changes in the contracts require further changes in the client code, so we’ll skip those changes for now and add in a separate commit.
* modify Interactions and Deployment constructors
- `HostInteractions` and `ClientInteractions` constructors were simplified to take a contract address and no overloads
- `Interactions` prepared simplified so there are no overloads
- `Deployment` constructor updated so that it takes an optional string parameter, instead `Option[string]`
* Move `batchProc` declaration
`batchProc` needs to be consumed by both `node` and `salescontext`, and they can’t reference each other as it creates a circular dependency.
* [reservations] rename `available` to `hasAvailable`
* [reservations] default error message to inner error msg
* add SaleIngored state
When a storage request is handled but the request does match availabilities, the sales agent machine is sent to the SaleIgnored state. In addition, the agent is constructed in a way that if the request is ignored, the sales agent is removed from the list of active agents being tracked in the sales module.
2023-04-04 07:05:16 +00:00
|
|
|
import pkg/stint
|
2023-05-15 07:02:57 +00:00
|
|
|
import pkg/ethers/erc20
|
2023-06-21 05:46:18 +00:00
|
|
|
import pkg/codex/contracts
|
|
|
|
import pkg/codex/utils/stintutils
|
2023-03-09 11:23:45 +00:00
|
|
|
import ../contracts/time
|
2023-05-15 07:02:57 +00:00
|
|
|
import ../contracts/deployment
|
2023-03-09 11:23:45 +00:00
|
|
|
import ../codex/helpers/eventually
|
2023-03-27 13:47:25 +00:00
|
|
|
import ./twonodes
|
2023-03-09 11:23:45 +00:00
|
|
|
|
2023-05-15 07:02:57 +00:00
|
|
|
# For debugging you can enable logging output with debugX = true
|
|
|
|
# You can also pass a string in same format like for the `--log-level` parameter
|
|
|
|
# to enable custom logging levels for specific topics like: debug2 = "INFO; TRACE: marketplace"
|
|
|
|
|
2023-03-27 13:47:25 +00:00
|
|
|
twonodessuite "Integration tests", debug1 = false, debug2 = false:
|
2023-03-09 11:23:45 +00:00
|
|
|
setup:
|
2023-04-14 09:04:17 +00:00
|
|
|
# Our Hardhat configuration does use automine, which means that time tracked by `provider.currentTime()` is not
|
|
|
|
# advanced until blocks are mined and that happens only when transaction is submitted.
|
|
|
|
# As we use in tests provider.currentTime() which uses block timestamp this can lead to synchronization issues.
|
|
|
|
await provider.advanceTime(1.u256)
|
2023-03-09 11:23:45 +00:00
|
|
|
|
|
|
|
test "nodes can print their peer information":
|
2023-03-27 13:47:25 +00:00
|
|
|
check client1.info() != client2.info()
|
2023-03-09 11:23:45 +00:00
|
|
|
|
2023-03-27 13:47:25 +00:00
|
|
|
test "nodes can set chronicles log level":
|
|
|
|
client1.setLogLevel("DEBUG;TRACE:codex")
|
2023-03-09 11:23:45 +00:00
|
|
|
|
|
|
|
test "node accepts file uploads":
|
2023-03-27 13:47:25 +00:00
|
|
|
let cid1 = client1.upload("some file contents")
|
|
|
|
let cid2 = client1.upload("some other contents")
|
|
|
|
check cid1 != cid2
|
2023-03-09 11:23:45 +00:00
|
|
|
|
|
|
|
test "node handles new storage availability":
|
2023-04-14 09:04:17 +00:00
|
|
|
let availability1 = client1.postAvailability(size=1, duration=2, minPrice=3, maxCollateral=4)
|
|
|
|
let availability2 = client1.postAvailability(size=4, duration=5, minPrice=6, maxCollateral=7)
|
2023-03-27 13:47:25 +00:00
|
|
|
check availability1 != availability2
|
2023-03-09 11:23:45 +00:00
|
|
|
|
|
|
|
test "node lists storage that is for sale":
|
2023-04-14 09:04:17 +00:00
|
|
|
let availability = client1.postAvailability(size=1, duration=2, minPrice=3, maxCollateral=4)
|
2023-03-27 13:47:25 +00:00
|
|
|
check availability in client1.getAvailabilities()
|
2023-03-09 11:23:45 +00:00
|
|
|
|
|
|
|
test "node handles storage request":
|
2023-03-27 13:47:25 +00:00
|
|
|
let expiry = (await provider.currentTime()) + 30
|
|
|
|
let cid = client1.upload("some file contents")
|
2023-04-14 09:04:17 +00:00
|
|
|
let id1 = client1.requestStorage(cid, duration=1, reward=2, proofProbability=3, expiry=expiry, collateral=200)
|
|
|
|
let id2 = client1.requestStorage(cid, duration=4, reward=5, proofProbability=6, expiry=expiry, collateral=201)
|
2023-03-27 13:47:25 +00:00
|
|
|
check id1 != id2
|
2023-03-09 11:23:45 +00:00
|
|
|
|
|
|
|
test "node retrieves purchase status":
|
2023-03-27 13:47:25 +00:00
|
|
|
let expiry = (await provider.currentTime()) + 30
|
|
|
|
let cid = client1.upload("some file contents")
|
2023-04-14 09:04:17 +00:00
|
|
|
let id = client1.requestStorage(cid, duration=1, reward=2, proofProbability=3, expiry=expiry, collateral=200)
|
2023-03-27 13:47:25 +00:00
|
|
|
let purchase = client1.getPurchase(id)
|
2023-06-21 05:46:18 +00:00
|
|
|
check purchase{"request"}{"ask"}{"duration"} == %"1"
|
|
|
|
check purchase{"request"}{"ask"}{"reward"} == %"2"
|
|
|
|
check purchase{"request"}{"ask"}{"proofProbability"} == %"3"
|
2023-03-09 11:23:45 +00:00
|
|
|
|
|
|
|
test "node remembers purchase status after restart":
|
2023-03-27 13:47:25 +00:00
|
|
|
let expiry = (await provider.currentTime()) + 30
|
|
|
|
let cid = client1.upload("some file contents")
|
2023-04-14 09:04:17 +00:00
|
|
|
let id = client1.requestStorage(cid, duration=1, reward=2, proofProbability=3, expiry=expiry, collateral=200)
|
2023-03-27 13:47:25 +00:00
|
|
|
check eventually client1.getPurchase(id){"state"}.getStr() == "submitted"
|
2023-03-09 11:23:45 +00:00
|
|
|
|
|
|
|
node1.restart()
|
2023-03-27 13:47:25 +00:00
|
|
|
client1.restart()
|
2023-03-09 11:23:45 +00:00
|
|
|
|
2023-03-27 13:47:25 +00:00
|
|
|
check eventually (not isNil client1.getPurchase(id){"request"}{"ask"})
|
2023-06-21 05:46:18 +00:00
|
|
|
check client1.getPurchase(id){"request"}{"ask"}{"duration"} == %"1"
|
|
|
|
check client1.getPurchase(id){"request"}{"ask"}{"reward"} == %"2"
|
2023-03-09 11:23:45 +00:00
|
|
|
|
|
|
|
test "nodes negotiate contracts on the marketplace":
|
[marketplace] Add Reservations Module (#340)
* [marketplace] reservations module
- add de/serialization for Availability
- add markUsed/markUnused in persisted availability
- add query for unused
- add reserve/release
- reservation module tests
- split ContractInteractions into client contracts and host contracts
- remove reservations start/stop as the repo start/stop is being managed by the node
- remove dedicated reservations metadata store and use the metadata store from the repo instead
- Split ContractInteractions into:
- ClientInteractions (with purchasing)
- HostInteractions (with sales and proving)
- compilation fix for nim 1.2
[repostore] fix started flag, add tests
[marketplace] persist slot index
For loading the sales state from chain, the slot index was not previously persisted in the contract. Will retrieve the slot index from the contract when the sales state is loaded.
* Revert repostore changes
In favour of separate PR https://github.com/status-im/nim-codex/pull/374.
* remove warnings
* clean up
* tests: stop repostore during teardown
* change constructor type identifier
Change Contracts constructor to accept Contracts type instead of ContractInteractions.
* change constructor return type to Result instead of Option
* fix and split interactions tests
* clean up, fix tests
* find availability by slot id
* remove duplication in host/client interactions
* add test for finding availability by slotId
* log instead of raiseAssert when failed to mark availability as unused
* move to SaleErrored state instead of raiseAssert
* remove unneeded reverse
It appears that order is not preserved in the repostore, so reversing does not have the intended effect here.
* update open api spec for potential rest endpoint errors
* move functions about available bytes to repostore
* WIP: reserve and release availabilities as needed
WIP: not tested yet
Availabilities are marked as used when matched (just before downloading starts) so that future matching logic does not match an availability currently in use.
As the download progresses, batches of blocks are written to disk, and the equivalent bytes are released from the reservation module. The size of the availability is reduced as well.
During a reserve or release operation, availability updates occur after the repo is manipulated. If the availability update operation fails, the reserve or release is rolled back to maintain correct accounting of bytes.
Finally, once download completes, or if an error occurs, the availability is marked as unused so future matching can occur.
* delete availability when all bytes released
* fix tests + cleanup
* remove availability from SalesContext callbacks
Availability is no longer used past the SaleDownloading state in the state machine. Cleanup of Availability (marking unused) is handled directly in the SaleDownloading state, and no longer in SaleErrored or SaleFinished. Likewise, Availabilities shouldn’t need to be handled on node restart.
Additionally, Availability was being passed in SalesContext callbacks, and now that Availability is only used temporarily in the SaleDownloading state, Availability is contextually irrelevant to the callbacks, except in OnStore possibly, though it was not being consumed.
* test clean up
* - remove availability from callbacks and constructors from previous commit that needed to be removed (oopsie)
- fix integration test that checks availabilities
- there was a bug fixed that crashed the node due to a missing `return success` in onStore
- the test was fixed by ensuring that availabilities are remaining on the node, and the size has been reduced
- change Availability back to non-ref object and constructor back to init
- add trace logging of all state transitions in state machine
- add generally useful trace logging
* fixes after rebase
1. Fix onProve callbacks
2. Use Slot type instead of tuple for retrieving active slot.
3. Bump codex-contracts-eth that exposes getActivceSlot call.
* swap contracts branch to not support slot collateral
Slot collateral changes in the contracts require further changes in the client code, so we’ll skip those changes for now and add in a separate commit.
* modify Interactions and Deployment constructors
- `HostInteractions` and `ClientInteractions` constructors were simplified to take a contract address and no overloads
- `Interactions` prepared simplified so there are no overloads
- `Deployment` constructor updated so that it takes an optional string parameter, instead `Option[string]`
* Move `batchProc` declaration
`batchProc` needs to be consumed by both `node` and `salescontext`, and they can’t reference each other as it creates a circular dependency.
* [reservations] rename `available` to `hasAvailable`
* [reservations] default error message to inner error msg
* add SaleIngored state
When a storage request is handled but the request does match availabilities, the sales agent machine is sent to the SaleIgnored state. In addition, the agent is constructed in a way that if the request is ignored, the sales agent is removed from the list of active agents being tracked in the sales module.
2023-04-04 07:05:16 +00:00
|
|
|
let size: uint64 = 0xFFFFF
|
2023-03-27 13:47:25 +00:00
|
|
|
# client 2 makes storage available
|
2023-04-14 09:04:17 +00:00
|
|
|
discard client2.postAvailability(size=size, duration=200, minPrice=300, maxCollateral=300)
|
2023-03-09 11:23:45 +00:00
|
|
|
|
2023-03-27 13:47:25 +00:00
|
|
|
# client 1 requests storage
|
|
|
|
let expiry = (await provider.currentTime()) + 30
|
|
|
|
let cid = client1.upload("some file contents")
|
2023-04-14 09:04:17 +00:00
|
|
|
let purchase = client1.requestStorage(cid, duration=100, reward=400, proofProbability=3, expiry=expiry, collateral=200)
|
2023-03-09 11:23:45 +00:00
|
|
|
|
2023-03-27 13:47:25 +00:00
|
|
|
check eventually client1.getPurchase(purchase){"state"} == %"started"
|
|
|
|
check client1.getPurchase(purchase){"error"} == newJNull()
|
[marketplace] Add Reservations Module (#340)
* [marketplace] reservations module
- add de/serialization for Availability
- add markUsed/markUnused in persisted availability
- add query for unused
- add reserve/release
- reservation module tests
- split ContractInteractions into client contracts and host contracts
- remove reservations start/stop as the repo start/stop is being managed by the node
- remove dedicated reservations metadata store and use the metadata store from the repo instead
- Split ContractInteractions into:
- ClientInteractions (with purchasing)
- HostInteractions (with sales and proving)
- compilation fix for nim 1.2
[repostore] fix started flag, add tests
[marketplace] persist slot index
For loading the sales state from chain, the slot index was not previously persisted in the contract. Will retrieve the slot index from the contract when the sales state is loaded.
* Revert repostore changes
In favour of separate PR https://github.com/status-im/nim-codex/pull/374.
* remove warnings
* clean up
* tests: stop repostore during teardown
* change constructor type identifier
Change Contracts constructor to accept Contracts type instead of ContractInteractions.
* change constructor return type to Result instead of Option
* fix and split interactions tests
* clean up, fix tests
* find availability by slot id
* remove duplication in host/client interactions
* add test for finding availability by slotId
* log instead of raiseAssert when failed to mark availability as unused
* move to SaleErrored state instead of raiseAssert
* remove unneeded reverse
It appears that order is not preserved in the repostore, so reversing does not have the intended effect here.
* update open api spec for potential rest endpoint errors
* move functions about available bytes to repostore
* WIP: reserve and release availabilities as needed
WIP: not tested yet
Availabilities are marked as used when matched (just before downloading starts) so that future matching logic does not match an availability currently in use.
As the download progresses, batches of blocks are written to disk, and the equivalent bytes are released from the reservation module. The size of the availability is reduced as well.
During a reserve or release operation, availability updates occur after the repo is manipulated. If the availability update operation fails, the reserve or release is rolled back to maintain correct accounting of bytes.
Finally, once download completes, or if an error occurs, the availability is marked as unused so future matching can occur.
* delete availability when all bytes released
* fix tests + cleanup
* remove availability from SalesContext callbacks
Availability is no longer used past the SaleDownloading state in the state machine. Cleanup of Availability (marking unused) is handled directly in the SaleDownloading state, and no longer in SaleErrored or SaleFinished. Likewise, Availabilities shouldn’t need to be handled on node restart.
Additionally, Availability was being passed in SalesContext callbacks, and now that Availability is only used temporarily in the SaleDownloading state, Availability is contextually irrelevant to the callbacks, except in OnStore possibly, though it was not being consumed.
* test clean up
* - remove availability from callbacks and constructors from previous commit that needed to be removed (oopsie)
- fix integration test that checks availabilities
- there was a bug fixed that crashed the node due to a missing `return success` in onStore
- the test was fixed by ensuring that availabilities are remaining on the node, and the size has been reduced
- change Availability back to non-ref object and constructor back to init
- add trace logging of all state transitions in state machine
- add generally useful trace logging
* fixes after rebase
1. Fix onProve callbacks
2. Use Slot type instead of tuple for retrieving active slot.
3. Bump codex-contracts-eth that exposes getActivceSlot call.
* swap contracts branch to not support slot collateral
Slot collateral changes in the contracts require further changes in the client code, so we’ll skip those changes for now and add in a separate commit.
* modify Interactions and Deployment constructors
- `HostInteractions` and `ClientInteractions` constructors were simplified to take a contract address and no overloads
- `Interactions` prepared simplified so there are no overloads
- `Deployment` constructor updated so that it takes an optional string parameter, instead `Option[string]`
* Move `batchProc` declaration
`batchProc` needs to be consumed by both `node` and `salescontext`, and they can’t reference each other as it creates a circular dependency.
* [reservations] rename `available` to `hasAvailable`
* [reservations] default error message to inner error msg
* add SaleIngored state
When a storage request is handled but the request does match availabilities, the sales agent machine is sent to the SaleIgnored state. In addition, the agent is constructed in a way that if the request is ignored, the sales agent is removed from the list of active agents being tracked in the sales module.
2023-04-04 07:05:16 +00:00
|
|
|
let availabilities = client2.getAvailabilities()
|
|
|
|
check availabilities.len == 1
|
2023-06-21 05:46:18 +00:00
|
|
|
let newSize = UInt256.fromDecimal(availabilities[0]{"size"}.getStr)
|
[marketplace] Add Reservations Module (#340)
* [marketplace] reservations module
- add de/serialization for Availability
- add markUsed/markUnused in persisted availability
- add query for unused
- add reserve/release
- reservation module tests
- split ContractInteractions into client contracts and host contracts
- remove reservations start/stop as the repo start/stop is being managed by the node
- remove dedicated reservations metadata store and use the metadata store from the repo instead
- Split ContractInteractions into:
- ClientInteractions (with purchasing)
- HostInteractions (with sales and proving)
- compilation fix for nim 1.2
[repostore] fix started flag, add tests
[marketplace] persist slot index
For loading the sales state from chain, the slot index was not previously persisted in the contract. Will retrieve the slot index from the contract when the sales state is loaded.
* Revert repostore changes
In favour of separate PR https://github.com/status-im/nim-codex/pull/374.
* remove warnings
* clean up
* tests: stop repostore during teardown
* change constructor type identifier
Change Contracts constructor to accept Contracts type instead of ContractInteractions.
* change constructor return type to Result instead of Option
* fix and split interactions tests
* clean up, fix tests
* find availability by slot id
* remove duplication in host/client interactions
* add test for finding availability by slotId
* log instead of raiseAssert when failed to mark availability as unused
* move to SaleErrored state instead of raiseAssert
* remove unneeded reverse
It appears that order is not preserved in the repostore, so reversing does not have the intended effect here.
* update open api spec for potential rest endpoint errors
* move functions about available bytes to repostore
* WIP: reserve and release availabilities as needed
WIP: not tested yet
Availabilities are marked as used when matched (just before downloading starts) so that future matching logic does not match an availability currently in use.
As the download progresses, batches of blocks are written to disk, and the equivalent bytes are released from the reservation module. The size of the availability is reduced as well.
During a reserve or release operation, availability updates occur after the repo is manipulated. If the availability update operation fails, the reserve or release is rolled back to maintain correct accounting of bytes.
Finally, once download completes, or if an error occurs, the availability is marked as unused so future matching can occur.
* delete availability when all bytes released
* fix tests + cleanup
* remove availability from SalesContext callbacks
Availability is no longer used past the SaleDownloading state in the state machine. Cleanup of Availability (marking unused) is handled directly in the SaleDownloading state, and no longer in SaleErrored or SaleFinished. Likewise, Availabilities shouldn’t need to be handled on node restart.
Additionally, Availability was being passed in SalesContext callbacks, and now that Availability is only used temporarily in the SaleDownloading state, Availability is contextually irrelevant to the callbacks, except in OnStore possibly, though it was not being consumed.
* test clean up
* - remove availability from callbacks and constructors from previous commit that needed to be removed (oopsie)
- fix integration test that checks availabilities
- there was a bug fixed that crashed the node due to a missing `return success` in onStore
- the test was fixed by ensuring that availabilities are remaining on the node, and the size has been reduced
- change Availability back to non-ref object and constructor back to init
- add trace logging of all state transitions in state machine
- add generally useful trace logging
* fixes after rebase
1. Fix onProve callbacks
2. Use Slot type instead of tuple for retrieving active slot.
3. Bump codex-contracts-eth that exposes getActivceSlot call.
* swap contracts branch to not support slot collateral
Slot collateral changes in the contracts require further changes in the client code, so we’ll skip those changes for now and add in a separate commit.
* modify Interactions and Deployment constructors
- `HostInteractions` and `ClientInteractions` constructors were simplified to take a contract address and no overloads
- `Interactions` prepared simplified so there are no overloads
- `Deployment` constructor updated so that it takes an optional string parameter, instead `Option[string]`
* Move `batchProc` declaration
`batchProc` needs to be consumed by both `node` and `salescontext`, and they can’t reference each other as it creates a circular dependency.
* [reservations] rename `available` to `hasAvailable`
* [reservations] default error message to inner error msg
* add SaleIngored state
When a storage request is handled but the request does match availabilities, the sales agent machine is sent to the SaleIgnored state. In addition, the agent is constructed in a way that if the request is ignored, the sales agent is removed from the list of active agents being tracked in the sales module.
2023-04-04 07:05:16 +00:00
|
|
|
check newSize > 0 and newSize < size.u256
|
2023-05-15 07:02:57 +00:00
|
|
|
|
|
|
|
test "node slots gets paid out":
|
|
|
|
let marketplace = Marketplace.new(Marketplace.address, provider.getSigner())
|
|
|
|
let tokenAddress = await marketplace.token()
|
|
|
|
let token = Erc20Token.new(tokenAddress, provider.getSigner())
|
|
|
|
let reward: uint64 = 400
|
|
|
|
let duration: uint64 = 100
|
|
|
|
|
|
|
|
# client 2 makes storage available
|
|
|
|
let startBalance = await token.balanceOf(account2)
|
|
|
|
discard client2.postAvailability(size=0xFFFFF, duration=200, minPrice=300, maxCollateral=300)
|
|
|
|
|
|
|
|
# client 1 requests storage
|
|
|
|
let expiry = (await provider.currentTime()) + 30
|
|
|
|
let cid = client1.upload("some file contents")
|
|
|
|
let purchase = client1.requestStorage(cid, duration=duration, reward=reward, proofProbability=3, expiry=expiry, collateral=200)
|
|
|
|
|
|
|
|
check eventually client1.getPurchase(purchase){"state"} == %"started"
|
|
|
|
check client1.getPurchase(purchase){"error"} == newJNull()
|
|
|
|
|
|
|
|
# Proving mechanism uses blockchain clock to do proving/collect/cleanup round
|
|
|
|
# hence we must use `advanceTime` over `sleepAsync` as Hardhat does mine new blocks
|
|
|
|
# only with new transaction
|
|
|
|
await provider.advanceTime(duration.u256)
|
|
|
|
|
|
|
|
check eventually (await token.balanceOf(account2)) - startBalance == duration.u256*reward.u256
|