Summary
scripts/testnet-load.sh and scripts/testnet-load-v2.sh duplicate roughly 80 lines of near-identical helper code: log/log_success/log_error, get_time/elapsed_time/avg_time, gen_key, balance, and invoke_contract. Both scripts were written independently (v1's load test, then v2's mirroring its structure) and the shared parts were never factored out.
Scope
- Extract the common helpers into a shared file, e.g.
scripts/lib/load-test-common.sh, sourced by both testnet-load.sh and testnet-load-v2.sh.
- No behavior change: both scripts should produce identical output/results before and after, just with the duplicated code removed from each in favor of one shared source.
- Keep whatever's genuinely script-specific (contract-specific parameters, phase logic, the v2 script's
network_id/json_field/commitment-computation helpers) where it is; only extract what's actually identical between the two.
- Update
shellcheck scripts/*.sh (CI) to still pass; a sourced lib file under scripts/lib/ may need its own shellcheck pass or an explicit include in the CI glob, check this before assuming it's covered automatically.
Proposed approach
Diff the two scripts to confirm the exact set of duplicated functions, move them verbatim into the new shared file, then replace each script's own copy with a source line near the top (using the same CONTRACT_DIR-relative pattern both scripts already use for WASM_PATH).
Summary
scripts/testnet-load.shandscripts/testnet-load-v2.shduplicate roughly 80 lines of near-identical helper code:log/log_success/log_error,get_time/elapsed_time/avg_time,gen_key,balance, andinvoke_contract. Both scripts were written independently (v1's load test, then v2's mirroring its structure) and the shared parts were never factored out.Scope
scripts/lib/load-test-common.sh, sourced by bothtestnet-load.shandtestnet-load-v2.sh.network_id/json_field/commitment-computation helpers) where it is; only extract what's actually identical between the two.shellcheck scripts/*.sh(CI) to still pass; a sourced lib file underscripts/lib/may need its own shellcheck pass or an explicit include in the CI glob, check this before assuming it's covered automatically.Proposed approach
Diff the two scripts to confirm the exact set of duplicated functions, move them verbatim into the new shared file, then replace each script's own copy with a
sourceline near the top (using the sameCONTRACT_DIR-relative pattern both scripts already use forWASM_PATH).