Skip to content

test: cover distribute_cascade and distribute_all_tokens at their exact limits#372

Open
IamHarrie-Labs wants to merge 1 commit into
tributary-protocol:mainfrom
IamHarrie-Labs:test/333-cascade-and-token-boundary-tests
Open

test: cover distribute_cascade and distribute_all_tokens at their exact limits#372
IamHarrie-Labs wants to merge 1 commit into
tributary-protocol:mainfrom
IamHarrie-Labs:test/333-cascade-and-token-boundary-tests

Conversation

@IamHarrie-Labs

Copy link
Copy Markdown

Closes #333

What this covers

The existing tests only checked what happens when you go past the limits (distribute_cascade_exceeds_max_depth uses depth 6, distribute_all_tokens_too_many_tokens uses 11 tokens). Nothing exercised landing exactly on MAX_CASCADE_DEPTH (5) or MAX_DISTRIBUTE_TOKENS (10), which is exactly the boundary where an off-by-one (> vs >=) would hide.

distribute_cascade_at_max_depth: builds a chain six splits deep (parent plus five nested children down to a leaf account), so reaching the leaf genuinely requires cascading the full MAX_CASCADE_DEPTH. Calls distribute_cascade with max_depth set to the constant itself, asserts it succeeds, and checks every split in the chain ends at a zero balance with the leaf account receiving the full amount, not just that the call didn't error.

distribute_all_tokens_at_max_tokens: deposits exactly MAX_DISTRIBUTE_TOKENS (10) distinct tokens into a split and calls distribute_all_tokens with all ten. Asserts it succeeds, returns all ten distributions with the right amounts, and each token's balance is cleared afterward.

Both currently pass against the existing > check in lib.rs (not >=), so this documents the intended behavior at the boundary rather than fixing a live bug. If that comparison operator is ever flipped, these are the tests that would catch it.

Test plan

Ran all three required checks locally:

cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo test

All clean, 59/59 tests passing including the two new ones. Didn't touch anything under sdk/, app/, or indexer/, so no need to run the JS-side build for this change.

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.

Add boundary tests at exactly MAX_CASCADE_DEPTH and MAX_DISTRIBUTE_TOKENS

1 participant