test(scenarios): add createDataSet smoke scenario - #153
Conversation
ab542e0 to
00a1da1
Compare
7d8a304 to
7e19448
Compare
7e19448 to
b21e5d7
Compare
There was a problem hiding this comment.
TLDR
- Load
devnet-info.json. - Pick
USER_2by default. - Pick the first approved PDP service provider.
- Build a Synapse client for that user on the devnet chain.
- Create unique smoke-test metadata so this dataset can be identified later.
- Ask the SDK to create a storage context for that provider and metadata.
- Run
synapse.storage.prepare(...)for a tiny dataset size. - If prepare says funds or approvals are needed, submit those transactions:
- ERC20 approval
- FilecoinPay deposit
- FWSS operator approval
- Directly call
SP.createDataSet(...). - Wait for
SP.waitForCreateDataSet(...)to confirm dataset creation. - Fetch datasets through
synapse.storage.findDataSets(). - Assert the new dataset exists and has the expected properties:
- positive dataset ID
- live
- managed
- correct payer
- correct provider/payee
- matching smoke metadata
| ORDER = [ | ||
| ("test_containers", 5), | ||
| ("test_basic_balances", 10), | ||
| ("test_create_dataset_smoke", 300), |
There was a problem hiding this comment.
I think this will cause the 300-second outer timeout to win before the 280-second Node timeout whenever cloning, installing, and building takes more than 20 seconds. That bypasses the inner timeout/retry handling and can lose buffered diagnostics. Non-blocking, but I’d give the outer scenario timeout enough headroom for setup plus the Node timeout and retries.
| const context = await synapse.storage.createContext({ | ||
| providerId: provider.id, | ||
| metadata, | ||
| withCDN: false, | ||
| }) | ||
| assert(context.dataSetId == null, `Expected unique metadata to create a new data set, got ${context.dataSetId}`) | ||
|
|
||
| await prepareWithPlainErc20(synapse, context) |
There was a problem hiding this comment.
it's unfortunate that you need to make a context just to get the proper prepare & costing setup; opened an issue for this but for now you're right about needing to do it this way FilOzone/synapse-sdk#899
| async function waitForDataSet(synapse, dataSetId) { | ||
| let lastCount = 0 | ||
| for (let attempt = 1; attempt <= 15; attempt++) { | ||
| const dataSets = await synapse.storage.findDataSets() |
There was a problem hiding this comment.
you could replace this with one of a few different synapse-core variants that avoid having to do as much work as this does, the easiest might just be getDataSet from '@filoz/synapse-core/warm-storage' (there's also getClientDataSets which findDataSets uses to get hte list). For a singular you should get a non-null response when it exists, just give it the dataSetId you want.
There was a problem hiding this comment.
Nice, let me have a look at these two. Thanks for the tip.
There was a problem hiding this comment.
This is nice to have but I can see this being broken apart over time to eventually replace example-storage-e2e.js; or perhaps just moving that into here, so we'll end up thinking about how to organise these files, maybe in their own directory.
Also, we can just write this in TypeScript and run it directly since that should work with modern Node.js. You get the proper typing free.
There was a problem hiding this comment.
Yeah, sure, let's do ts!
Related to #121
This introduces createDataSet scenraio described in the related issue. Combined with the other proposed additions related to the issue, it will allow us to fully test the partial upgrade scenario.
Testing