Skip to content

test: add golden test for hash_proto#517

Merged
iamquang95 merged 2 commits into
mainfrom
feat/test-strategy-app-run
Jul 5, 2026
Merged

test: add golden test for hash_proto#517
iamquang95 merged 2 commits into
mainfrom
feat/test-strategy-app-run

Conversation

@iamquang95

Copy link
Copy Markdown
Collaborator

The golden file and output are generated by charon. Then test the input/output on pluto side.

@iamquang95 iamquang95 requested review from emlautarom1 and varex83 July 3, 2026 10:49
@iamquang95

Copy link
Copy Markdown
Collaborator Author

@claude review PR

@claude

claude Bot commented Jul 3, 2026

Copy link
Copy Markdown

Claude finished @iamquang95's task in 2m 9s —— View job


PR Review: test: add golden test for hash_proto

  • Read the diff (msg.rs test, golden JSON, Cargo changes)
  • Cross-check against charon source
  • Verify dependency wiring
  • Post review

Overall this is a clean, well-motivated test-only change. It replaces the single inline-constant test (hash_proto_matches_seeded_unsigned_dataset) with a table-driven golden-vector test sourced from charon. Nice work. ✅

What's good

  • Faithful cross-impl anchoring. The attester_seed0 vector's hash d8f9bc3d… is exactly charon's own TestHashProto golden (charon/core/consensus/qbft/msg_internal_test.go:34), so a green test proves both that pluto's hash_proto matches charon and that the captured vectors are faithful.
  • Logic parity confirmed. hash_proto (msg.rs:272) mirrors charon's hashProto (msg.go:140): deterministic marshal → PutBytesMerkleizeHashRoot, plus the same Any-rejection guard. The BTreeMap keying matches charon's deterministic map marshalling.
  • Good coverage spread. Single-DV, multi-DV cluster shape, and the empty-set boundary (all-zero root) are all exercised, plus distinct UnsignedData byte shapes across attester/aggregator/sync_contribution.
  • Drift guard. Pinning charon_ref == "v1.7.1" and asserting non-empty vectors is a nice guard against silently editing the golden file.
  • Dependency wiring is correct. serde is added to [dev-dependencies] (not runtime deps), and the workspace serde already enables the derive feature — so #[derive(serde::Deserialize)] compiles.

Minor observations (non-blocking, nits)

  1. duty is purely descriptive. hash_proto hashes the raw encoded bytes and is duty-agnostic — the duty/name fields only feed the failure message, not any behavior. The real coverage value comes from varying data_hex, not the duty label. That's fine (it documents intent), just worth being explicit that this test does not exercise any per-duty branching.
  2. empty_set → zero root. Worth a one-line comment in the JSON note (or a // charon-verified: empty encoding merkleizes to the zero root in the test) so a future reader doesn't mistake the all-zero hash for a placeholder/unfilled value.
  3. Inline struct defs. Declaring Entry/Vector/File inside the test fn is fine for a one-off; if more golden-file tests get added later, consider lifting them into a small shared test helper.

Note on verification

I could not run cargo test -p pluto-consensus in this environment (command approval not granted), so I validated by source inspection and by confirming the attester_seed0 vector equals charon's committed golden. Please make sure CI runs the suite before merge — the empty-set and multi-DV vectors in particular are the ones that would surface any real divergence.

· branch feat/test-strategy-app-run

@iamquang95 iamquang95 merged commit c6dd57d into main Jul 5, 2026
12 checks passed
@iamquang95 iamquang95 deleted the feat/test-strategy-app-run branch July 5, 2026 13:05
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.

2 participants