Cover new credential code paths and drop duplicate address compute#94
Merged
n13 merged 4 commits intoilluzen/wormhole-secretfrom Apr 18, 2026
Merged
Conversation
Follow-up review feedback for #92. The original PR tested helpers indirectly (parse_secret_hex_str, compute_wormhole_address) but never exercised the new match arms in collect_rewards, and left the clap mutual-exclusion constraints without a guardrail. - Extract credential resolution into `resolve_credential` so the Mnemonic / Secret branches are directly testable, and call it from `collect_rewards`. - Remove the redundant `compute_wormhole_address` call inside the per-transfer proof loop now that `wormhole_address_bytes` is already produced at the top of the flow. - Replace the 6 indirect tests with 7 direct tests that actually run `resolve_credential`, including a mnemonic -> HD-derived-secret -> `Secret { hex }` equivalence test and the `HD derivation failed` error path. - Add 3 clap parsing tests covering `required_unless_present_any` and the three `conflicts_with_all` pairs (wallet+mnemonic, wallet+secret, mnemonic+secret).
Port the derivation-path fix from main (#93): the wormhole HD path for `collect_rewards` must be `m/44'/CHAIN/0'/0'/index'` — the intermediate segment is 0', not 1'. Also move the `derive` progress call to after resolution so it reports the actual derived SS58 address, matching main's behavior. Add `test_resolve_credential_mnemonic_pinned_derivation_path` which pins the expected (address_bytes, secret_bytes) for the canonical abandon-art test mnemonic at index 0. Any future silent regression of the path segments will fail this test.
…luzen/wormhole-secret-review-tests
illuzen
added a commit
that referenced
this pull request
Apr 18, 2026
* allow using secret to collect rewards * add tests * Cover new credential code paths and drop duplicate address compute (#94) * Cover new credential code paths and drop duplicate address compute Follow-up review feedback for #92. The original PR tested helpers indirectly (parse_secret_hex_str, compute_wormhole_address) but never exercised the new match arms in collect_rewards, and left the clap mutual-exclusion constraints without a guardrail. - Extract credential resolution into `resolve_credential` so the Mnemonic / Secret branches are directly testable, and call it from `collect_rewards`. - Remove the redundant `compute_wormhole_address` call inside the per-transfer proof loop now that `wormhole_address_bytes` is already produced at the top of the flow. - Replace the 6 indirect tests with 7 direct tests that actually run `resolve_credential`, including a mnemonic -> HD-derived-secret -> `Secret { hex }` equivalence test and the `HD derivation failed` error path. - Add 3 clap parsing tests covering `required_unless_present_any` and the three `conflicts_with_all` pairs (wallet+mnemonic, wallet+secret, mnemonic+secret). * Fix wormhole HD path and pin it with a regression test Port the derivation-path fix from main (#93): the wormhole HD path for `collect_rewards` must be `m/44'/CHAIN/0'/0'/index'` — the intermediate segment is 0', not 1'. Also move the `derive` progress call to after resolution so it reports the actual derived SS58 address, matching main's behavior. Add `test_resolve_credential_mnemonic_pinned_derivation_path` which pins the expected (address_bytes, secret_bytes) for the canonical abandon-art test mnemonic at index 0. Any future silent regression of the path segments will fail this test. * format --------- Co-authored-by: Nikolaus Heger <nheger@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up on #92 addressing review feedback around test coverage of the new
WormholeCredentialcode paths.Summary
resolve_credentialhelper incollect_rewards_lib.rsso theWormholeCredential::Mnemonic/WormholeCredential::Secretbranches are directly unit-testable instead of being buried insidecollect_rewards.compute_wormhole_addresscall inside the per-transfer proof loop — the top-level match already produceswormhole_address_byteswith the identical value, so we were hashing the secret once per transfer for no reason.resolve_credential(the previous tests re-implemented the logic in a "simulate what WormholeCredential::Secret does" style, so a real bug in the match arm would still pass).New tests
collect_rewards_lib::tests:`cli::wormhole::tests`:
Test plan