fix(escrow): use TREE_HEIGHT constant in test assertions#78
fix(escrow): use TREE_HEIGHT constant in test assertions#780xKyungmin wants to merge 2 commits intosolana-foundation:mainfrom
Conversation
Replace hardcoded tree height values with the TREE_HEIGHT constant in test_process_release_funds_instruction_data_valid to prevent compilation errors when building with the test-tree feature.
Replace hardcoded sibling proof indices and loop bounds with TREE_HEIGHT-derived values to prevent out-of-bounds compilation errors when building with the test-tree feature.
Greptile SummaryThis PR replaces hardcoded tree-height values (
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Test Setup: sibling_proofs array of size TREE_HEIGHT"] --> B["Compute expected root"]
B --> C{".take(N) — how many levels?"}
C -->|"N < TREE_HEIGHT (old behavior)"| D["Intermediate hash at level N"]
C -->|"N = TREE_HEIGHT (new behavior)"| E["Full root hash at level TREE_HEIGHT"]
D --> F["Verifier matches at level N → early return Ok"]
E --> G["Verifier matches at final level → normal return Ok"]
F --> H["Early termination path exercised ✓"]
G --> I["Early termination path NOT exercised ✗"]
|
Summary
Several tests in
release_funds.rsandsmt_utils.rshardcode the tree height as16(or use indices assumingTREE_HEIGHT >= 16) instead of using theTREE_HEIGHTconstant. When compiled with thetest-treefeature (TREE_HEIGHT = 3), this causes compilation errors:Without
test-tree, the defaultTREE_HEIGHT = 16happens to match the hardcoded values, so the errors are currently masked.Changes
release_funds.rs[2u8; 512]->[2u8; TREE_HEIGHT * 32][[2u8; 32]; 16]->[[2u8; 32]; TREE_HEIGHT]smt_utils.rs[5],[7],[10]) with[TREE_HEIGHT - 1][3]) with[TREE_HEIGHT - 1].take(6),.take(8)) with.take(TREE_HEIGHT)All changes are consistent with the rest of the test suite which already uses the
TREE_HEIGHTconstant.Test plan
cargo test -p contra-escrow-program— 40 passedcargo test -p contra-escrow-program --features test-tree— 40 passed