Skip to content

Commit

Permalink
WIP: formatting and test scope cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
apbendi committed Feb 8, 2024
1 parent 3eb8d6a commit c2ce4cc
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions test/UniStaker.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1260,37 +1260,39 @@ contract PermitAndStakeMore is UniStakerTest {
(address _depositor, uint256 _depositorPrivateKey) = makeAddrAndKey("depositor");
uint256 _stakeMoreAmount = 1578e18;
uint256 _deadline = 1e18 days;
uint256 _wrongNonce = 1;
// If any of the values defined above are changed, the expected recovered address must also
// be recalculated and updated.
address _expectedRecoveredSigner = address(0xF03C6C880C40b5698e466C136C460ea71A0C5E33);

UniStaker.DepositIdentifier _depositId;
(_initialDepositAmount, _depositId) = _boundMintAndStake(_depositor, _initialDepositAmount, _delegatee, _beneficiary);
(_initialDepositAmount, _depositId) =
_boundMintAndStake(_depositor, _initialDepositAmount, _delegatee, _beneficiary);
_mintGovToken(_depositor, _stakeMoreAmount);

bytes32 _messageHash;
// Separate scope to avoid stack to deep errors
{
bytes32 _message = keccak256(
abi.encode(
PERMIT_TYPEHASH,
_depositor,
address(uniStaker),
_stakeMoreAmount,
1, // intentionally incorrect nonce, which should be 0
_deadline
)
);
bytes32 _message = keccak256(
abi.encode(
PERMIT_TYPEHASH,
_depositor,
address(uniStaker),
_stakeMoreAmount,
_wrongNonce, // intentionally incorrect nonce, which should be 0
_deadline
)
);

_messageHash =
keccak256(abi.encodePacked("\x19\x01", govToken.DOMAIN_SEPARATOR(), _message));
}
bytes32 _messageHash =
keccak256(abi.encodePacked("\x19\x01", govToken.DOMAIN_SEPARATOR(), _message));

(uint8 _v, bytes32 _r, bytes32 _s) = vm.sign(_depositorPrivateKey, _messageHash);
(uint8 _v, bytes32 _r, bytes32 _s) = vm.sign(_depositorPrivateKey, _messageHash);

vm.prank(_depositor);
vm.expectRevert(
abi.encodeWithSelector(ERC20Permit.ERC2612InvalidSigner.selector, _expectedRecoveredSigner, _depositor)
);
uniStaker.permitAndStakeMore(_depositId, _stakeMoreAmount, _deadline, _v, _r, _s);
vm.prank(_depositor);
vm.expectRevert(
abi.encodeWithSelector(
ERC20Permit.ERC2612InvalidSigner.selector, _expectedRecoveredSigner, _depositor
)
);
uniStaker.permitAndStakeMore(_depositId, _stakeMoreAmount, _deadline, _v, _r, _s);
}
}

Expand Down

0 comments on commit c2ce4cc

Please sign in to comment.