Repository navigation
fix(types): validate individual ratio legs in validateSplitRatioSum - #1015
Closed
neverm1ndthat wants to merge 1 commit into
Closed
neverm1ndthat wants to merge 1 commit into
neverm1ndthat wants to merge 1 commit into
Conversation
Issue Stellar-split#1012 - reject recipient ratios that are not finite or outside [0, 1] before checking their aggregate sum. This catches invalid inputs like [-1, 2] (sum=1 but semantically wrong), NaN, and Infinity which previously evaded the tolerance check because NaN comparisons always return false. Adds SplitRatioLegError to surface which recipient has the bad ratio and why.
Author
|
Hi @Kingsman-99! This PR addresses Issue #1012 - validateSplitRatioSum now rejects individual ratio legs that are not finite or outside [0,1], not just the aggregate sum. This catches cases like [-1, 2] that sum to 1 but are semantically invalid. PTAL! |
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.
Fixes #1012
Summary
validateSplitRatioSum()insplitExecutor.tsnow validates each recipient ratio individually before checking their aggregate sum.The Bug
validateSplitRatioSum()only verified that|sum - 1| < tolerance. This allowed invalid inputs to pass:Math.abs(NaN - 1) > tolerancealways evaluates to false, so NaN sums silently passThe Fix
Number.isFinitebefore the tolerance checkSplitRatioLegErrorthat surfaces which recipient has the bad ratio and whyTesting
test/splitExecutorRatio.test.tscontinue to passSplitRatioLegErrorclass properly extendsStellarSplitErrorwith codeSPLIT_RATIO_LEG_INVALID