-
Notifications
You must be signed in to change notification settings - Fork 14
test: Add invariant tests for SumTree structure in PDPVerifier #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
test: Add invariant tests for SumTree structure in PDPVerifier #166
Conversation
test/PDPVerifier.t.sol
Outdated
| } | ||
| } | ||
|
|
||
| function testSumTreeInvariantAfterAddsAndRemovals() public { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge with latest master
run forge fmt
|
@Hany-Almnaem please see the above comment - this needs a merge from master (or rebase) plus a |
- Resolve conflict in test/PDPVerifier.t.sol - Fix failing SumTreeEnhancedTest tests - Apply forge fmt formatting
|
@rvagg |
|
Thanks @Hany-Almnaem . I'm going to have to personally put off reviewing this for now because it's a large-enough context switch for me to do it and I have a lot on my plate currently. Maybe @ZenGround0 gets inspired to come have a look, his head is more full of the details here than mine. |
Summary
This PR introduces a suite of tests to validate the correctness and stability of the
sumTreeCountsstructure in thePDPVerifiersmart contract.The tests ensure that each node in the SumTree maintains the invariant:
sumTreeCounts[setId][index] == sum of rootLeafCounts[setId][j]for the correct range derived from the node’s height.This directly addresses and resolves issue: #45
Summary of Changes
Core Tests (Basic Coverage)
testSumTreeInvariantAfterAddsAndRemovals()assertSumTreeInvariant(uint256 setId)testAdvancedSumTreeInvariant()testFuzzedSumTreeInvariant(uint256 seed)Advanced Suite (Tagged
[ADVANCED])Implemented in a separate
SumTreeEnhancedTestcontract:testSumTreeStressTest()testSumTreeEdgeCases()testSumTreePerformance()testSumTreeRandomized(uint256 seed)assertSumTreeInvariant()with more detailed error messaging for diagnostics.Benefits
Notes
forge testPlease let me know if you prefer these broken into separate PRs or test files.