We have a lot of ad-hoc tests floating around. I would like to make them more consistent so it's harder for bugs to fall through the cracks. The most recent bug we didn't manage to catch was the one solved by #574.
This issue aims to create a comprehensive and consistent testing framework that:
- Makes it easy to consistently check that the data we store can also be retrieved and is the same
- Makes it easy to test a full lifecycle of authorize, store, renew / hop submit, promote
- Is clear with when to use typescript vs zombienet-sdk
- Removes unnecessary boilerplate (looking at you Justfile)
Current state
Today we have:
-
Pallet unit tests
-
Runtime tests
-
Chain e2e tests with zombienet-sdk
-
Client e2e tests in examples/*.js
-
UI tests for console-ui
-
- and 5. are good. The purpose of this issue is to simplify how much needs to run in zombienet-sdk, only node-level issues like syncing, and move the client e2e tests from examples to an easier-to-use and more consistent typescript framework. The existing examples are better of as actual examples and not tests.
Harness sketch
test('hop promotion preserves data integrity', async ({ net }) => {
const alice = await net.actor('//Alice', { authorize: { bytes: 10 * MiB, transactions: 100 } });
const data = randomBytes(2 * MiB);
const { cid } = await alice.hop.submitAndAwaitPromotion(data);
await expect(net.ipfs).toRetrieve(cid, data); // enforced terminal assertion
});
Here:
net spawns the network and exposes the client to interact with it. Would also allow setting a shorter retention period / authorization period
actor(suri, opts) manages the signer and the authorizations
submitAndAwaitPromotion is one of many possible wait helpers for making sure nothing breaks in the middle of the lifecycle
expect(net.ipfs).toRetrieve(cid, bytes) fetch via kubo and compare bytes to make sure the data can be retrieved and is the same as the one submitted
Tasks
Phase 1 - Framework
Phase 2 - More tests
Phase 3 - Cleanup
We have a lot of ad-hoc tests floating around. I would like to make them more consistent so it's harder for bugs to fall through the cracks. The most recent bug we didn't manage to catch was the one solved by #574.
This issue aims to create a comprehensive and consistent testing framework that:
Current state
Today we have:
Pallet unit tests
Runtime tests
Chain e2e tests with zombienet-sdk
Client e2e tests in examples/*.js
UI tests for console-ui
Harness sketch
Here:
netspawns the network and exposes the client to interact with it. Would also allow setting a shorter retention period / authorization periodactor(suri, opts)manages the signer and the authorizationssubmitAndAwaitPromotionis one of many possible wait helpers for making sure nothing breaks in the middle of the lifecycleexpect(net.ipfs).toRetrieve(cid, bytes)fetch via kubo and compare bytes to make sure the data can be retrieved and is the same as the one submittedTasks
Phase 1 - Framework
Phase 2 - More tests
Phase 3 - Cleanup