Skip to content

feat: add create cluster tests#325

Open
varex83 wants to merge 13 commits intomainfrom
bohdan/cmd-create-cluster-test
Open

feat: add create cluster tests#325
varex83 wants to merge 13 commits intomainfrom
bohdan/cmd-create-cluster-test

Conversation

@varex83
Copy link
Copy Markdown
Collaborator

@varex83 varex83 commented Apr 14, 2026

Summary

Ports the Go TestCreateCluster test suite to Rust, covering all major create_cluster flows end-to-end, and fixes several correctness issues uncovered in the process.

New tests (crates/cli/src/commands/create_cluster.rs)

A shared run_test_create_cluster helper drives all test cases, mirroring the Go test loop. Each case exercises run() against a temp directory and asserts:

  • the command succeeds (or returns a specific error)
  • the generated cluster-lock.json passes verify_hashes() and verify_signatures()
  • all distributed validators have unique public keys
  • deposit-data amounts match expectations
  • CLI output and produced file tree match golden snapshots

Test cases covered:

Test Notes
simnet 4-node simnet cluster
goerli Goerli network, 3-node
custom_testnet_flags Custom chain ID / fork version / genesis timestamp
custom_target_gas_limit Non-default target_gas_limit
solo_flow_definition_from_disk Definition loaded from a local JSON file
solo_flow_definition_from_network Definition served over HTTP (wiremock)
splitkeys --split-existing-keys, keys generated in a temp dir
splitkeys_with_cluster_definition Split keys combined with a pre-existing definition
four_partial_deposits / two_partial_deposits Multiple deposit amounts per validator
with_fee_recipient_and_withdrawal_addresses Custom fee-recipient + withdrawal addresses
validate_def Invalid definition triggers expected error

Golden files live in crates/cli/src/commands/testdata/ and can be regenerated with UPDATE_GOLDEN=1 cargo test.

Bug fixes

  • create_cluster::run — call def.set_definition_hashes() before proceeding with key generation; the hashes were previously unset, causing verify_hashes() to fail.
  • definition.rs deserialization — validate that num_validators == validator_addresses.len() for schema versions v1.5–v1.10; add #[serde(default)] to fee_recipient_address, withdrawal_address, and compounding so older JSON examples without those fields still deserialize correctly.
  • lock.rs no_registration check — remove the zero-fee_recipient guard. The Go reference uses len == 0 (missing field), not the zero Ethereum address; a legitimately zero fee-recipient is valid. Only an all-zero BLS signature or pubkey indicates a missing registration.
  • cluster-definition-005.json — fix malformed timestamp (stray spaces around : separators).

Test plan

  • cargo test -p pluto-cli passes with all new test cases green
  • UPDATE_GOLDEN=1 cargo test regenerates golden files without diff
  • Existing tests unaffected

Base automatically changed from bohdan/cmd-create-cluster to main April 15, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant