Skip to content

Commit

Permalink
Add depositor assertions and adjust fuzzer settings
Browse files Browse the repository at this point in the history
  • Loading branch information
apbendi committed Dec 13, 2023
1 parent 30add26 commit f5b85b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@
single_line_statement_blocks = "single"
tab_width = 2
wrap_comments = true

[fuzz]
# We turn on this setting to prevent the fuzzer from picking DelegationSurrogate contracts,
# including before they're actually even deployed, as some other entity in the test, for example
# depositor. This makes no sense and breaks test assertions, but is extremely difficult to handle
# with assume statements because we don't have the surrogate address until it's deployed later in
# the test.
include_storage = false
5 changes: 5 additions & 0 deletions test/UniStaker.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ contract Stake is UniStakerTest {

assertEq(govToken.balanceOf(address(_surrogate)), _amount);
assertEq(govToken.delegates(address(_surrogate)), _delegatee);
assertEq(govToken.balanceOf(_depositor), 0);
}

function testFuzz_TransfersToAnExistingSurrogateWhenStakedToTheSameDelegatee(
Expand All @@ -98,6 +99,8 @@ contract Stake is UniStakerTest {
assertEq(address(uniStaker.surrogates(_delegatee)), address(_surrogate));
assertEq(govToken.delegates(address(_surrogate)), _delegatee);
assertEq(govToken.balanceOf(address(_surrogate)), _amount1 + _amount2);
assertEq(govToken.balanceOf(_depositor1), 0);
assertEq(govToken.balanceOf(_depositor2), 0);
}

function testFuzz_DeploysAndTransferTokenToTwoSurrogatesWhenUsersStakesToDifferentDelegatees(
Expand Down Expand Up @@ -130,5 +133,7 @@ contract Stake is UniStakerTest {
assertEq(govToken.balanceOf(address(_surrogate1)), _amount1);
assertEq(govToken.delegates(address(_surrogate2)), _delegatee2);
assertEq(govToken.balanceOf(address(_surrogate2)), _amount2);
assertEq(govToken.balanceOf(_depositor1), 0);
assertEq(govToken.balanceOf(_depositor2), 0);
}
}

0 comments on commit f5b85b6

Please sign in to comment.