Skip to content

Commit

Permalink
test(authorization): split tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Dec 19, 2023
1 parent 58bb2a2 commit fa8c4cf
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/forge/integration/AuthorizationIntegrationTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@ contract AuthorizationIntegrationTest is BaseTest {
authorization.nonce = 0;
authorization.authorizer = vm.addr(privateKey);

Signature memory sig;
bytes32 digest = SigUtils.getTypedDataHash(morpho.DOMAIN_SEPARATOR(), authorization);
(sig.v, sig.r, sig.s) = vm.sign(privateKey, digest);

morpho.setAuthorizationWithSig(authorization, sig);

authorization.isAuthorized = false;

vm.expectRevert(bytes(ErrorsLib.INVALID_NONCE));
morpho.setAuthorizationWithSig(authorization, sig);
}

function testAuthorizationFrontRun(Authorization memory authorization, uint256 privateKey) public {
authorization.isAuthorized = true;
authorization.deadline = bound(authorization.deadline, block.timestamp, type(uint256).max);

// Private key must be less than the secp256k1 curve order.
privateKey = bound(privateKey, 1, type(uint32).max);
authorization.nonce = 0;
authorization.authorizer = vm.addr(privateKey);

address authorized = _boundAddressNotZero(authorization.authorized);
authorization.authorized = address(0);

Expand Down

0 comments on commit fa8c4cf

Please sign in to comment.