test: cover distribute_cascade and distribute_all_tokens at their exact limits#372
Open
IamHarrie-Labs wants to merge 1 commit into
Conversation
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.
Closes #333
What this covers
The existing tests only checked what happens when you go past the limits (
distribute_cascade_exceeds_max_depthuses depth 6,distribute_all_tokens_too_many_tokensuses 11 tokens). Nothing exercised landing exactly onMAX_CASCADE_DEPTH(5) orMAX_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 fullMAX_CASCADE_DEPTH. Callsdistribute_cascadewithmax_depthset 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 exactlyMAX_DISTRIBUTE_TOKENS(10) distinct tokens into a split and callsdistribute_all_tokenswith 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 inlib.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:
All clean, 59/59 tests passing including the two new ones. Didn't touch anything under
sdk/,app/, orindexer/, so no need to run the JS-side build for this change.