Skip to content

[Chore] De-duplicate shared helpers between testnet-load.sh and testnet-load-v2.sh #97

Description

@collinsezedike

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).

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions