2025-03-26 12:45:22 +01:00
|
|
|
import std/times
|
|
|
|
|
import std/httpclient
|
2024-05-23 17:29:30 +02:00
|
|
|
import ../examples
|
|
|
|
|
import ../contracts/time
|
|
|
|
|
import ../contracts/deployment
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
import ./marketplacesuite
|
2024-05-23 17:29:30 +02:00
|
|
|
import ./twonodes
|
2024-03-12 10:57:13 +01:00
|
|
|
import ./nodeconfigs
|
2024-05-23 17:29:30 +02:00
|
|
|
|
2025-06-19 08:36:10 +02:00
|
|
|
marketplacesuite(name = "Marketplace", stopOnRequestFail = true):
|
2024-12-17 14:01:41 +01:00
|
|
|
let marketplaceConfig = NodeConfigs(
|
|
|
|
|
clients: CodexConfigs.init(nodes = 1).some,
|
|
|
|
|
providers: CodexConfigs.init(nodes = 1).some,
|
|
|
|
|
)
|
2025-01-21 21:54:46 +01:00
|
|
|
|
2024-12-17 14:01:41 +01:00
|
|
|
var host: CodexClient
|
|
|
|
|
var hostAccount: Address
|
|
|
|
|
var client: CodexClient
|
|
|
|
|
var clientAccount: Address
|
|
|
|
|
|
2025-01-24 18:18:00 +01:00
|
|
|
const minPricePerBytePerSecond = 1.u256
|
|
|
|
|
const collateralPerByte = 1.u256
|
|
|
|
|
const blocks = 8
|
|
|
|
|
const ecNodes = 3
|
|
|
|
|
const ecTolerance = 1
|
|
|
|
|
|
2024-05-23 17:29:30 +02:00
|
|
|
setup:
|
2024-12-17 14:01:41 +01:00
|
|
|
host = providers()[0].client
|
|
|
|
|
hostAccount = providers()[0].ethAccount
|
|
|
|
|
client = clients()[0].client
|
|
|
|
|
clientAccount = clients()[0].ethAccount
|
|
|
|
|
|
2024-05-23 17:29:30 +02:00
|
|
|
# Our Hardhat configuration does use automine, which means that time tracked by `ethProvider.currentTime()` is not
|
|
|
|
|
# advanced until blocks are mined and that happens only when transaction is submitted.
|
|
|
|
|
# As we use in tests ethProvider.currentTime() which uses block timestamp this can lead to synchronization issues.
|
|
|
|
|
await ethProvider.advanceTime(1.u256)
|
|
|
|
|
|
2024-12-17 14:01:41 +01:00
|
|
|
test "nodes negotiate contracts on the marketplace", marketplaceConfig:
|
2025-02-20 08:11:06 +01:00
|
|
|
let size = 0xFFFFFF.uint64
|
2025-01-24 18:18:00 +01:00
|
|
|
let data = await RandomChunker.example(blocks = blocks)
|
2024-12-17 14:01:41 +01:00
|
|
|
# host makes storage available
|
2025-03-17 17:08:24 -03:00
|
|
|
let availability = (
|
|
|
|
|
await host.postAvailability(
|
|
|
|
|
totalSize = size,
|
|
|
|
|
duration = 20 * 60.uint64,
|
|
|
|
|
minPricePerBytePerSecond = minPricePerBytePerSecond,
|
|
|
|
|
totalCollateral = size.u256 * minPricePerBytePerSecond,
|
|
|
|
|
)
|
2024-12-17 14:01:41 +01:00
|
|
|
).get
|
2024-05-23 17:29:30 +02:00
|
|
|
|
2024-12-17 14:01:41 +01:00
|
|
|
# client requests storage
|
2025-03-17 17:08:24 -03:00
|
|
|
let cid = (await client.upload(data)).get
|
2025-02-20 08:11:06 +01:00
|
|
|
let id = await client.requestStorage(
|
2024-05-23 17:29:30 +02:00
|
|
|
cid,
|
2025-02-20 08:11:06 +01:00
|
|
|
duration = 20 * 60.uint64,
|
2025-01-24 18:18:00 +01:00
|
|
|
pricePerBytePerSecond = minPricePerBytePerSecond,
|
2024-05-23 17:29:30 +02:00
|
|
|
proofProbability = 3.u256,
|
2025-02-20 08:11:06 +01:00
|
|
|
expiry = 10 * 60.uint64,
|
2025-01-24 18:18:00 +01:00
|
|
|
collateralPerByte = collateralPerByte,
|
|
|
|
|
nodes = ecNodes,
|
|
|
|
|
tolerance = ecTolerance,
|
2025-02-20 08:11:06 +01:00
|
|
|
)
|
2024-05-23 17:29:30 +02:00
|
|
|
|
2025-06-19 08:36:10 +02:00
|
|
|
discard await waitForRequestToStart()
|
|
|
|
|
|
2025-03-17 17:08:24 -03:00
|
|
|
let purchase = (await client.getPurchase(id)).get
|
2024-05-23 17:29:30 +02:00
|
|
|
check purchase.error == none string
|
2025-03-17 17:08:24 -03:00
|
|
|
let availabilities = (await host.getAvailabilities()).get
|
2024-05-23 17:29:30 +02:00
|
|
|
check availabilities.len == 1
|
|
|
|
|
let newSize = availabilities[0].freeSize
|
|
|
|
|
check newSize > 0 and newSize < size
|
|
|
|
|
|
2025-03-17 17:08:24 -03:00
|
|
|
let reservations = (await host.getAvailabilityReservations(availability.id)).get
|
2024-11-25 12:23:04 +01:00
|
|
|
check reservations.len == 3
|
2024-05-23 17:29:30 +02:00
|
|
|
check reservations[0].requestId == purchase.requestId
|
|
|
|
|
|
2024-12-17 14:01:41 +01:00
|
|
|
test "node slots gets paid out and rest of tokens are returned to client",
|
|
|
|
|
marketplaceConfig:
|
2025-02-20 08:11:06 +01:00
|
|
|
let size = 0xFFFFFF.uint64
|
2025-01-24 18:18:00 +01:00
|
|
|
let data = await RandomChunker.example(blocks = blocks)
|
2024-05-23 17:29:30 +02:00
|
|
|
let marketplace = Marketplace.new(Marketplace.address, ethProvider.getSigner())
|
|
|
|
|
let tokenAddress = await marketplace.token()
|
|
|
|
|
let token = Erc20Token.new(tokenAddress, ethProvider.getSigner())
|
2025-02-20 08:11:06 +01:00
|
|
|
let duration = 20 * 60.uint64
|
2024-05-23 17:29:30 +02:00
|
|
|
|
2024-12-17 14:01:41 +01:00
|
|
|
# host makes storage available
|
|
|
|
|
let startBalanceHost = await token.balanceOf(hostAccount)
|
2025-03-17 17:08:24 -03:00
|
|
|
discard (
|
|
|
|
|
await host.postAvailability(
|
|
|
|
|
totalSize = size,
|
|
|
|
|
duration = 20 * 60.uint64,
|
|
|
|
|
minPricePerBytePerSecond = minPricePerBytePerSecond,
|
|
|
|
|
totalCollateral = size.u256 * minPricePerBytePerSecond,
|
|
|
|
|
)
|
2024-12-17 14:01:41 +01:00
|
|
|
).get
|
2024-05-23 17:29:30 +02:00
|
|
|
|
2024-12-17 14:01:41 +01:00
|
|
|
# client requests storage
|
2025-03-17 17:08:24 -03:00
|
|
|
let cid = (await client.upload(data)).get
|
2025-02-20 08:11:06 +01:00
|
|
|
let id = await client.requestStorage(
|
2024-05-23 17:29:30 +02:00
|
|
|
cid,
|
|
|
|
|
duration = duration,
|
2025-01-24 18:18:00 +01:00
|
|
|
pricePerBytePerSecond = minPricePerBytePerSecond,
|
2024-05-23 17:29:30 +02:00
|
|
|
proofProbability = 3.u256,
|
2025-02-20 08:11:06 +01:00
|
|
|
expiry = 10 * 60.uint64,
|
2025-01-24 18:18:00 +01:00
|
|
|
collateralPerByte = collateralPerByte,
|
|
|
|
|
nodes = ecNodes,
|
|
|
|
|
tolerance = ecTolerance,
|
2025-02-20 08:11:06 +01:00
|
|
|
)
|
2024-05-23 17:29:30 +02:00
|
|
|
|
2025-06-19 08:36:10 +02:00
|
|
|
discard await waitForRequestToStart()
|
|
|
|
|
|
2025-03-17 17:08:24 -03:00
|
|
|
let purchase = (await client.getPurchase(id)).get
|
2024-05-23 17:29:30 +02:00
|
|
|
check purchase.error == none string
|
|
|
|
|
|
2024-12-17 14:01:41 +01:00
|
|
|
let clientBalanceBeforeFinished = await token.balanceOf(clientAccount)
|
2024-10-10 13:53:33 +02:00
|
|
|
|
2024-05-23 17:29:30 +02:00
|
|
|
# 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
|
2025-02-20 08:11:06 +01:00
|
|
|
await ethProvider.advanceTime(duration.u256)
|
2024-05-23 17:29:30 +02:00
|
|
|
|
2024-10-10 13:53:33 +02:00
|
|
|
# Checking that the hosting node received reward for at least the time between <expiry;end>
|
2025-02-06 16:21:12 +01:00
|
|
|
let slotSize = slotSize(blocks, ecNodes, ecTolerance)
|
2025-01-24 18:18:00 +01:00
|
|
|
let pricePerSlotPerSecond = minPricePerBytePerSecond * slotSize
|
2024-12-17 14:01:41 +01:00
|
|
|
check eventually (await token.balanceOf(hostAccount)) - startBalanceHost >=
|
2025-02-20 08:11:06 +01:00
|
|
|
(duration - 5 * 60).u256 * pricePerSlotPerSecond * ecNodes.u256
|
2024-10-10 13:53:33 +02:00
|
|
|
|
|
|
|
|
# Checking that client node receives some funds back that were not used for the host nodes
|
2024-11-25 12:23:04 +01:00
|
|
|
check eventually(
|
2024-12-17 14:01:41 +01:00
|
|
|
(await token.balanceOf(clientAccount)) - clientBalanceBeforeFinished > 0,
|
2024-11-25 12:23:04 +01:00
|
|
|
timeout = 10 * 1000, # give client a bit of time to withdraw its funds
|
|
|
|
|
)
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
2025-05-29 08:57:05 +02:00
|
|
|
test "SP are able to process slots after workers were busy with other slots and ignored them",
|
|
|
|
|
NodeConfigs(
|
|
|
|
|
clients: CodexConfigs.init(nodes = 1)
|
|
|
|
|
# .debug()
|
|
|
|
|
.some,
|
|
|
|
|
providers: CodexConfigs.init(nodes = 2)
|
|
|
|
|
# .debug()
|
|
|
|
|
# .withLogFile()
|
|
|
|
|
# .withLogTopics("marketplace", "sales", "statemachine","slotqueue", "reservations")
|
|
|
|
|
.some,
|
|
|
|
|
):
|
|
|
|
|
let client0 = clients()[0]
|
|
|
|
|
let provider0 = providers()[0]
|
|
|
|
|
let provider1 = providers()[1]
|
|
|
|
|
let duration = 20 * 60.uint64
|
|
|
|
|
|
|
|
|
|
let data = await RandomChunker.example(blocks = blocks)
|
|
|
|
|
let slotSize = slotSize(blocks, ecNodes, ecTolerance)
|
|
|
|
|
|
|
|
|
|
# We create an avavilability allowing the first SP to host the 3 slots.
|
|
|
|
|
# So the second SP will not have any availability so it will just process
|
|
|
|
|
# the slots and ignore them.
|
|
|
|
|
discard await provider0.client.postAvailability(
|
|
|
|
|
totalSize = 3 * slotSize.truncate(uint64),
|
|
|
|
|
duration = duration,
|
|
|
|
|
minPricePerBytePerSecond = minPricePerBytePerSecond,
|
|
|
|
|
totalCollateral = 3 * slotSize * minPricePerBytePerSecond,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
let cid = (await client0.client.upload(data)).get
|
|
|
|
|
|
|
|
|
|
let purchaseId = await client0.client.requestStorage(
|
|
|
|
|
cid,
|
|
|
|
|
duration = duration,
|
|
|
|
|
pricePerBytePerSecond = minPricePerBytePerSecond,
|
|
|
|
|
proofProbability = 1.u256,
|
|
|
|
|
expiry = 10 * 60.uint64,
|
|
|
|
|
collateralPerByte = collateralPerByte,
|
|
|
|
|
nodes = ecNodes,
|
|
|
|
|
tolerance = ecTolerance,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
let requestId = (await client0.client.requestId(purchaseId)).get
|
|
|
|
|
|
|
|
|
|
# We wait that the 3 slots are filled by the first SP
|
2025-06-19 08:36:10 +02:00
|
|
|
discard await waitForRequestToStart()
|
2025-05-29 08:57:05 +02:00
|
|
|
|
|
|
|
|
# Here we create the same availability as previously but for the second SP.
|
|
|
|
|
# Meaning that, after ignoring all the slots for the first request, the second SP will process
|
|
|
|
|
# and host the slots for the second request.
|
|
|
|
|
discard await provider1.client.postAvailability(
|
|
|
|
|
totalSize = 3 * slotSize.truncate(uint64),
|
|
|
|
|
duration = duration,
|
|
|
|
|
minPricePerBytePerSecond = minPricePerBytePerSecond,
|
|
|
|
|
totalCollateral = 3 * slotSize * collateralPerByte,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
let purchaseId2 = await client0.client.requestStorage(
|
|
|
|
|
cid,
|
|
|
|
|
duration = duration,
|
|
|
|
|
pricePerBytePerSecond = minPricePerBytePerSecond,
|
|
|
|
|
proofProbability = 3.u256,
|
|
|
|
|
expiry = 10 * 60.uint64,
|
|
|
|
|
collateralPerByte = collateralPerByte,
|
|
|
|
|
nodes = ecNodes,
|
|
|
|
|
tolerance = ecTolerance,
|
|
|
|
|
)
|
|
|
|
|
let requestId2 = (await client0.client.requestId(purchaseId2)).get
|
|
|
|
|
|
|
|
|
|
# Wait that the slots of the second request are filled
|
2025-06-19 08:36:10 +02:00
|
|
|
discard await waitForRequestToStart()
|
2025-05-29 08:57:05 +02:00
|
|
|
|
|
|
|
|
# Double check, verify that our second SP hosts the 3 slots
|
2025-06-19 08:36:10 +02:00
|
|
|
check ((await provider1.client.getSlots()).get).len == 3
|
2025-05-29 08:57:05 +02:00
|
|
|
|
2025-06-19 08:36:10 +02:00
|
|
|
marketplacesuite(name = "Marketplace payouts", stopOnRequestFail = true):
|
2025-01-24 18:18:00 +01:00
|
|
|
const minPricePerBytePerSecond = 1.u256
|
|
|
|
|
const collateralPerByte = 1.u256
|
|
|
|
|
const blocks = 8
|
|
|
|
|
const ecNodes = 3
|
|
|
|
|
const ecTolerance = 1
|
|
|
|
|
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
test "expired request partially pays out for stored time",
|
|
|
|
|
NodeConfigs(
|
|
|
|
|
# Uncomment to start Hardhat automatically, typically so logs can be inspected locally
|
2024-03-12 10:57:13 +01:00
|
|
|
hardhat: HardhatConfig.none,
|
|
|
|
|
clients: CodexConfigs.init(nodes = 1)
|
2025-05-29 08:57:05 +02:00
|
|
|
# .debug() # uncomment to enable console log output.debug()
|
|
|
|
|
# .withLogFile()
|
|
|
|
|
# # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
2024-03-12 10:57:13 +01:00
|
|
|
# .withLogTopics("node", "erasure")
|
|
|
|
|
.some,
|
|
|
|
|
providers: CodexConfigs.init(nodes = 1)
|
2025-05-29 08:57:05 +02:00
|
|
|
# .debug() # uncomment to enable console log output
|
|
|
|
|
# .withLogFile()
|
|
|
|
|
# # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
|
|
|
|
# .withLogTopics(
|
|
|
|
|
# "node", "marketplace", "sales", "reservations", "node", "statemachine"
|
|
|
|
|
# )
|
2024-03-12 10:57:13 +01:00
|
|
|
.some,
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
):
|
2024-11-25 12:23:04 +01:00
|
|
|
let duration = 20.periods
|
|
|
|
|
let expiry = 10.periods
|
2025-01-24 18:18:00 +01:00
|
|
|
let data = await RandomChunker.example(blocks = blocks)
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
let client = clients()[0]
|
|
|
|
|
let provider = providers()[0]
|
|
|
|
|
let clientApi = client.client
|
|
|
|
|
let providerApi = provider.client
|
|
|
|
|
let startBalanceProvider = await token.balanceOf(provider.ethAccount)
|
|
|
|
|
let startBalanceClient = await token.balanceOf(client.ethAccount)
|
|
|
|
|
|
|
|
|
|
# provider makes storage available
|
2025-01-24 18:18:00 +01:00
|
|
|
let datasetSize = datasetSize(blocks, ecNodes, ecTolerance)
|
2025-02-20 08:11:06 +01:00
|
|
|
let totalAvailabilitySize = (datasetSize div 2).truncate(uint64)
|
2025-03-17 17:08:24 -03:00
|
|
|
discard await providerApi.postAvailability(
|
2024-03-12 09:18:25 +01:00
|
|
|
# make availability size small enough that we can't fill all the slots,
|
|
|
|
|
# thus causing a cancellation
|
2025-01-24 18:18:00 +01:00
|
|
|
totalSize = totalAvailabilitySize,
|
2025-02-20 08:11:06 +01:00
|
|
|
duration = duration.uint64,
|
2025-01-24 18:18:00 +01:00
|
|
|
minPricePerBytePerSecond = minPricePerBytePerSecond,
|
2025-02-20 08:11:06 +01:00
|
|
|
totalCollateral = collateralPerByte * totalAvailabilitySize.u256,
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
)
|
|
|
|
|
|
2025-03-17 17:08:24 -03:00
|
|
|
let cid = (await clientApi.upload(data)).get
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
2025-02-20 08:11:06 +01:00
|
|
|
var slotIdxFilled = none uint64
|
2024-12-03 12:16:24 +01:00
|
|
|
proc onSlotFilled(eventResult: ?!SlotFilled) =
|
|
|
|
|
assert not eventResult.isErr
|
|
|
|
|
slotIdxFilled = some (!eventResult).slotIndex
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
2025-06-19 08:36:10 +02:00
|
|
|
let slotFilledSubscription = await marketplace.subscribe(SlotFilled, onSlotFilled)
|
|
|
|
|
|
|
|
|
|
var requestCancelledEvent = newAsyncEvent()
|
|
|
|
|
proc onRequestCancelled(eventResult: ?!RequestCancelled) =
|
|
|
|
|
assert not eventResult.isErr
|
|
|
|
|
requestCancelledEvent.fire()
|
|
|
|
|
|
|
|
|
|
let requestCancelledSubscription =
|
|
|
|
|
await marketplace.subscribe(RequestCancelled, onRequestCancelled)
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
2024-03-12 09:18:25 +01:00
|
|
|
# client requests storage but requires multiple slots to host the content
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
let id = await clientApi.requestStorage(
|
|
|
|
|
cid,
|
|
|
|
|
duration = duration,
|
2025-01-24 18:18:00 +01:00
|
|
|
pricePerBytePerSecond = minPricePerBytePerSecond,
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
expiry = expiry,
|
2025-01-24 18:18:00 +01:00
|
|
|
collateralPerByte = collateralPerByte,
|
|
|
|
|
nodes = ecNodes,
|
|
|
|
|
tolerance = ecTolerance,
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# wait until one slot is filled
|
2024-03-12 09:18:25 +01:00
|
|
|
check eventually(slotIdxFilled.isSome, timeout = expiry.int * 1000)
|
2025-03-17 17:08:24 -03:00
|
|
|
let slotId = slotId(!(await clientApi.requestId(id)), !slotIdxFilled)
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
|
|
|
|
# wait until sale is cancelled
|
2024-11-25 12:23:04 +01:00
|
|
|
await ethProvider.advanceTime(expiry.u256)
|
2025-05-29 08:57:05 +02:00
|
|
|
|
2025-06-19 08:36:10 +02:00
|
|
|
await requestCancelledEvent.wait().wait(timeout = chronos.seconds(5))
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
2024-12-17 14:01:41 +01:00
|
|
|
await advanceToNextPeriod()
|
|
|
|
|
|
2025-02-06 16:21:12 +01:00
|
|
|
let slotSize = slotSize(blocks, ecNodes, ecTolerance)
|
2025-01-24 18:18:00 +01:00
|
|
|
let pricePerSlotPerSecond = minPricePerBytePerSecond * slotSize
|
|
|
|
|
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
check eventually (
|
|
|
|
|
let endBalanceProvider = (await token.balanceOf(provider.ethAccount))
|
2024-05-23 17:29:30 +02:00
|
|
|
endBalanceProvider > startBalanceProvider and
|
2025-01-24 18:18:00 +01:00
|
|
|
endBalanceProvider < startBalanceProvider + expiry.u256 * pricePerSlotPerSecond
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
)
|
2024-11-25 12:23:04 +01:00
|
|
|
check eventually(
|
|
|
|
|
(
|
|
|
|
|
let endBalanceClient = (await token.balanceOf(client.ethAccount))
|
|
|
|
|
let endBalanceProvider = (await token.balanceOf(provider.ethAccount))
|
|
|
|
|
(startBalanceClient - endBalanceClient) ==
|
|
|
|
|
(endBalanceProvider - startBalanceProvider)
|
|
|
|
|
),
|
|
|
|
|
timeout = 10 * 1000, # give client a bit of time to withdraw its funds
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
)
|
|
|
|
|
|
2025-06-19 08:36:10 +02:00
|
|
|
await slotFilledSubscription.unsubscribe()
|
|
|
|
|
await requestCancelledSubscription.unsubscribe()
|
2025-05-29 16:47:37 +02:00
|
|
|
|
|
|
|
|
test "the collateral is returned after a sale is ignored",
|
|
|
|
|
NodeConfigs(
|
|
|
|
|
hardhat: HardhatConfig.none,
|
|
|
|
|
clients: CodexConfigs.init(nodes = 1).some,
|
|
|
|
|
providers: CodexConfigs.init(nodes = 3)
|
|
|
|
|
# .debug()
|
|
|
|
|
# uncomment to enable console log output
|
|
|
|
|
# .withLogFile()
|
|
|
|
|
# uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
|
|
|
|
# .withLogTopics(
|
|
|
|
|
# "node", "marketplace", "sales", "reservations", "statemachine"
|
|
|
|
|
# )
|
|
|
|
|
.some,
|
|
|
|
|
):
|
|
|
|
|
let data = await RandomChunker.example(blocks = blocks)
|
|
|
|
|
let client0 = clients()[0]
|
|
|
|
|
let provider0 = providers()[0]
|
|
|
|
|
let provider1 = providers()[1]
|
|
|
|
|
let provider2 = providers()[2]
|
|
|
|
|
let duration = 20 * 60.uint64
|
|
|
|
|
let slotSize = slotSize(blocks, ecNodes, ecTolerance)
|
|
|
|
|
|
|
|
|
|
# Here we create 3 SP which can host 3 slot.
|
|
|
|
|
# While they will process the slot, each SP will
|
|
|
|
|
# create a reservation for each slot.
|
|
|
|
|
# Likely we will have 1 slot by SP and the other reservations
|
|
|
|
|
# will be ignored. In that case, the collateral assigned for
|
|
|
|
|
# the reservation should return to the availability.
|
|
|
|
|
discard await provider0.client.postAvailability(
|
|
|
|
|
totalSize = 3 * slotSize.truncate(uint64),
|
|
|
|
|
duration = duration,
|
|
|
|
|
minPricePerBytePerSecond = minPricePerBytePerSecond,
|
|
|
|
|
totalCollateral = 3 * slotSize * minPricePerBytePerSecond,
|
|
|
|
|
)
|
|
|
|
|
discard await provider1.client.postAvailability(
|
|
|
|
|
totalSize = 3 * slotSize.truncate(uint64),
|
|
|
|
|
duration = duration,
|
|
|
|
|
minPricePerBytePerSecond = minPricePerBytePerSecond,
|
|
|
|
|
totalCollateral = 3 * slotSize * minPricePerBytePerSecond,
|
|
|
|
|
)
|
|
|
|
|
discard await provider2.client.postAvailability(
|
|
|
|
|
totalSize = 3 * slotSize.truncate(uint64),
|
|
|
|
|
duration = duration,
|
|
|
|
|
minPricePerBytePerSecond = minPricePerBytePerSecond,
|
|
|
|
|
totalCollateral = 3 * slotSize * minPricePerBytePerSecond,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
let cid = (await client0.client.upload(data)).get
|
|
|
|
|
|
|
|
|
|
let purchaseId = await client0.client.requestStorage(
|
|
|
|
|
cid,
|
|
|
|
|
duration = duration,
|
|
|
|
|
pricePerBytePerSecond = minPricePerBytePerSecond,
|
|
|
|
|
proofProbability = 1.u256,
|
|
|
|
|
expiry = 10 * 60.uint64,
|
|
|
|
|
collateralPerByte = collateralPerByte,
|
|
|
|
|
nodes = ecNodes,
|
|
|
|
|
tolerance = ecTolerance,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
let requestId = (await client0.client.requestId(purchaseId)).get
|
|
|
|
|
|
2025-06-19 08:36:10 +02:00
|
|
|
discard await waitForRequestToStart()
|
2025-05-29 16:47:37 +02:00
|
|
|
|
|
|
|
|
# Here we will check that for each provider, the total remaining collateral
|
|
|
|
|
# will match the available slots.
|
|
|
|
|
# So if a SP hosts 1 slot, it should have enough total remaining collateral
|
|
|
|
|
# to host 2 more slots.
|
|
|
|
|
for provider in providers():
|
|
|
|
|
let client = provider.client
|
|
|
|
|
check eventually(
|
|
|
|
|
block:
|
|
|
|
|
let availabilities = (await client.getAvailabilities()).get
|
|
|
|
|
let availability = availabilities[0]
|
|
|
|
|
let slots = (await client.getSlots()).get
|
|
|
|
|
let availableSlots = (3 - slots.len).u256
|
|
|
|
|
|
|
|
|
|
availability.totalRemainingCollateral ==
|
|
|
|
|
availableSlots * slotSize * minPricePerBytePerSecond,
|
|
|
|
|
timeout = 30 * 1000,
|
|
|
|
|
)
|