Skip to content

Commit 4ce7e71

Browse files
authored
feat: Create bucket (#10)
* add local network option * account derivation * add account scenarios * add helpers * derive N accounts * add missing network info * remove preflight * upload deps and package.json * WIP: account generation + SIWE * clean up toError * clean up read envs * clean up MspClient config * lint * WIP: having sequential index for each VU * common entry point for all tests * common account derivation step * clean siwe + getProfile test * point to index.ts entry point * mute/restor metrics functions * update derive accounts * update authentication * run with logs & index allocator script * minor improvements in config * example getProfile * clean up * fmt & clean up * update download test * clean up * update download test * improve download test * simplify running test command * clean up * update readme * fmt * clean up unauth calls * remove duplicated function * create bucket example * script to fund accounts * create bucket related functions * types definition * user api to interact with the chain * utils function file * remove SIWE from bucket creation example * batch fund accounts process * fmt * set default log level to info * fix account derivation to start over from first index * log account balance * update package and lock file * lint * minor fixes * lint * fix merge conflicts * improve readme with commands descriptions * remove unused methods for index allocation. Keep only sequential index * simplify fund accounts * amount can be set only with decimal values * remove the dry-run mode * add some docs to fund accounts script * fmt * remove unused script * add main function as entry point and improve types
1 parent 155ffdc commit 4ce7e71

File tree

15 files changed

+1591
-164
lines changed

15 files changed

+1591
-164
lines changed

README.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,35 @@ Local notes:
4545
- `pnpm fmt:fix` — apply formatting
4646
- `pnpm lint` — check lint rules
4747
- `pnpm lint:fix` — apply safe lint fixes
48-
- `pnpm test:run scenarios/<file>.yml` — run any scenario (build + logs wrapper)
48+
- `pnpm typecheck` — TypeScript typecheck (no emit)
49+
- `pnpm build` — compile to `./dist`
50+
- `pnpm with-logs -- <command>` — run `<command>` with per-run JSONL logs + a local index allocator
51+
- `pnpm run:with-logs -- <command>` — build, then run `<command>` with logs + index allocator
52+
- `pnpm test:run <scenario.yml>` — run any Artillery scenario (via the logs/index wrapper)
53+
- `pnpm test:unauth` — unauthenticated MSP endpoints scenario
54+
- `pnpm test:examples.getProfile` — SIWE + `getProfile` scenario
55+
- `pnpm test:examples.createBucket` — derive account + create a bucket scenario
56+
- `pnpm test:download` — SIWE + download file scenario
57+
- `pnpm util:fund-accounts` — fund derived test accounts
58+
59+
## Fund accounts utility
60+
61+
`pnpm util:fund-accounts` is a small helper to print or fund EVM accounts derived from a mnemonic.
62+
63+
Print first 10 derived addresses:
64+
65+
```bash
66+
TEST_MNEMONIC="..." pnpm util:fund-accounts
67+
```
68+
69+
Fund first 10 derived addresses (0.01 native token each):
70+
71+
```bash
72+
NETWORK=local TEST_MNEMONIC="..." pnpm util:fund-accounts -- --privateKey 0x... --amount 0.01 --start 0 --count 10
73+
```
74+
75+
Notes:
76+
- `--batchSize` controls parallelism per batch (default: 10). If `batchSize > count`, only `count` transfers are sent.
4977

5078
List available scenarios:
5179

@@ -62,7 +90,7 @@ NETWORK=stagenet pnpm test:run scenarios/<file>.yml
6290
Examples (replace the scenario file with anything from `ls scenarios`):
6391

6492
```bash
65-
NETWORK=local pnpm test:run scenarios/artillery.msp-unauth.yml
93+
NETWORK=local pnpm test:run scenarios/msp.unauth.yml
6694
```
6795

6896
```bash
@@ -93,11 +121,11 @@ Env vars:
93121
Examples:
94122

95123
```bash
96-
LOG_LEVEL=debug NETWORK=testnet pnpm test:run scenarios/artillery.msp-unauth.yml
124+
LOG_LEVEL=debug NETWORK=testnet pnpm test:run scenarios/msp.unauth.yml
97125
```
98126

99127
```bash
100-
LOG_LEVEL=info LOG_FILE=./artillery.log NETWORK=testnet pnpm test:run scenarios/artillery.msp-unauth.yml
128+
LOG_LEVEL=info LOG_FILE=./artillery.log NETWORK=testnet pnpm test:run scenarios/msp.unauth.yml
101129
```
102130

103131
## Standalone MSP unauth load test
@@ -111,7 +139,7 @@ It uses `NETWORK=testnet|stagenet` and the MSP base URL from `src/networks.ts`.
111139
Run:
112140

113141
```bash
114-
NETWORK=stagenet pnpm test:run scenarios/artillery.msp-unauth.yml
142+
NETWORK=stagenet pnpm test:run scenarios/msp.unauth.yml
115143
```
116144

117145
Knobs (optional):

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
"with-logs": "pnpm exec tsx scripts/run-scenario.ts --",
1616
"run:with-logs": "pnpm build && pnpm with-logs",
1717
"test:run": "pnpm run:with-logs artillery run",
18-
1918
"test:unauth": "pnpm test:run scenarios/msp.unauth.yml",
2019
"test:examples.getProfile": "pnpm test:run scenarios/examples.getProfile.yml",
21-
"test:download": "pnpm test:run scenarios/download.yml"
20+
"test:examples.createBucket": "pnpm test:run scenarios/examples.createBucket.yml",
21+
"test:download": "pnpm test:run scenarios/download.yml",
22+
"util:fund-accounts": "pnpm exec tsx scripts/fund-accounts.ts"
2223
},
2324
"dependencies": {
2425
"@storagehub-sdk/core": "0.4.0",
2526
"@storagehub-sdk/msp-client": "0.4.0",
27+
"@polkadot/api": "^12.4.2",
2628
"artillery": "^2.0.0",
2729
"pino": "^10.1.0",
2830
"viem": "^2.42.1"

0 commit comments

Comments
 (0)