Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkeating committed Mar 19, 2024
1 parent bb885eb commit bc442e0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/UniStaker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ contract UniStaker is INotifiableRewardReceiver, Multicall, EIP712, Nonces {
}

function invalidateNonce() external {
_useNonce(msg.sender);
_useNonce(msg.sender);
}

/// @notice Internal method which finds the existing surrogate contract—or deploys a new one if
Expand Down
50 changes: 24 additions & 26 deletions test/UniStaker.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2626,42 +2626,40 @@ contract SetAdmin is UniStakerTest {
}

contract InvalidateNonce is UniStakerTest {
using stdStorage for StdStorage;
using stdStorage for StdStorage;

// Calll increments nonce
function testFuzz_SucessfullyInvalidateNonceForMsgSender(address _caller, uint256 _initialNonce) public {
vm.assume(_caller != address(0));
vm.assume(_initialNonce != type(uint256).max);
function testFuzz_SucessfullyInvalidateNonceForMsgSender(address _caller, uint256 _initialNonce)
public
{
vm.assume(_caller != address(0));
vm.assume(_initialNonce != type(uint256).max);

// Set nonces in storage assert incremented by one
stdstore
.target(address(uniStaker))
.sig("nonces(address)")
.with_key(_caller)
.checked_write(_initialNonce);
// Set nonces in storage assert incremented by one
stdstore.target(address(uniStaker)).sig("nonces(address)").with_key(_caller).checked_write(
_initialNonce
);

vm.prank(_caller);
uniStaker.invalidateNonce();
vm.prank(_caller);
uniStaker.invalidateNonce();

uint256 currentNonce = uniStaker.nonces(_caller);
uint256 currentNonce = uniStaker.nonces(_caller);

assertEq(currentNonce, _initialNonce + 1, "Current nonce is incorrect");
assertEq(currentNonce, _initialNonce + 1, "Current nonce is incorrect");
}

// Outside nonce owner cannot updateNonce
function testFuzz_NeedName(address _caller, address _nonceOwner, uint256 _initialNonce) public {
vm.assume(_caller != address(0));
vm.assume(_initialNonce != type(uint256).max);

// Set nonces in storage assert incremented by one
stdstore
.target(address(uniStaker))
.sig("nonces(address)")
.with_key(_nonceOwner)
.checked_write(_initialNonce);

vm.prank(_caller);
uniStaker.invalidateNonce();
vm.assume(_caller != address(0));
vm.assume(_initialNonce != type(uint256).max);

// Set nonces in storage assert incremented by one
stdstore.target(address(uniStaker)).sig("nonces(address)").with_key(_nonceOwner).checked_write(
_initialNonce
);

vm.prank(_caller);
uniStaker.invalidateNonce();
}

// It can be called multiple times
Expand Down

0 comments on commit bc442e0

Please sign in to comment.