Fix double-counting in getVTokenPremium1155.t.sol#109
Open
1d34h4z4rd wants to merge 1 commit intoNFTX-project:masterfrom
Open
Fix double-counting in getVTokenPremium1155.t.sol#1091d34h4z4rd wants to merge 1 commit intoNFTX-project:masterfrom
1d34h4z4rd wants to merge 1 commit intoNFTX-project:masterfrom
Conversation
Author
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.
forge testoutput:Ran 41 test suites in 1.84s (12.02s CPU time): 285 tests passed, 0 failed, 0 skipped (285 total tests)
Fix incorrect inventory tracking in fuzz test for
getVTokenPremium1155Summary
This PR fixes a logic bug in the fuzz test
test_WhenTheAmountIsLessThanOrEqualToTheQuantityOfNftsInTheVault.The test previously double-counted deposited NFTs, which caused incorrect assumptions about the vault's inventory and resulted in unexpected
NFTInventoryExceeded()reverts during fuzzing.This was a test-side accounting error, not a protocol vulnerability.
Root Cause
Inside the deposit loop, the test incremented
totalDepositedtwice:Since the vault only receives one deposit per iteration, the test inflated the perceived inventory to
2 × actual.As a result, fuzzing could pick values where:
NtotalDeposited = 2NAwhereN < A ≤ 2NThis made the test incorrectly expect success, while the contract correctly reverted.
Fix
The double-counting has been removed. Now each deposit is counted exactly once:
This aligns
totalDepositedwith the vault’s actual internal accounting.Impact
Testing