-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: migrate GPv2Signing set pre-signature tests to Foundry (#203)
## Description See title. ## Test Plan CI, compare with removed tests. ## Related Issues #120 --------- Co-authored-by: mfw78 <[email protected]>
- Loading branch information
Showing
3 changed files
with
54 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
pragma solidity ^0.8; | ||
|
||
import {GPv2Signing} from "src/contracts/mixins/GPv2Signing.sol"; | ||
|
||
import {Helper} from "./Helper.sol"; | ||
import {Order} from "test/libraries/Order.sol"; | ||
import {Sign} from "test/libraries/Sign.sol"; | ||
|
||
contract SetPreSignature is Helper { | ||
address private immutable owner = makeAddr("GPv2Signing.SetPreSignature owner"); | ||
bytes private orderUid = | ||
Order.computeOrderUid(keccak256("GPv2Signing.SetPreSignature order hash"), owner, type(uint32).max); | ||
|
||
function test_should_set_the_pre_signature() public { | ||
vm.prank(owner); | ||
executor.setPreSignature(orderUid, true); | ||
assertEq(executor.preSignature(orderUid), Sign.PRE_SIGNED); | ||
} | ||
|
||
function test_should_unset_the_pre_signature() public { | ||
vm.prank(owner); | ||
executor.setPreSignature(orderUid, true); | ||
vm.prank(owner); | ||
executor.setPreSignature(orderUid, false); | ||
assertEq(executor.preSignature(orderUid), 0); | ||
} | ||
|
||
function test_should_emit_a_pre_signature_event() public { | ||
vm.prank(owner); | ||
vm.expectEmit(address(executor)); | ||
emit GPv2Signing.PreSignature(owner, orderUid, true); | ||
executor.setPreSignature(orderUid, true); | ||
|
||
vm.prank(owner); | ||
vm.expectEmit(address(executor)); | ||
emit GPv2Signing.PreSignature(owner, orderUid, false); | ||
executor.setPreSignature(orderUid, false); | ||
} | ||
|
||
function test_should_emit_a_PreSignature_event_even_if_storage_does_not_change() public { | ||
vm.prank(owner); | ||
executor.setPreSignature(orderUid, true); | ||
vm.prank(owner); | ||
vm.expectEmit(address(executor)); | ||
emit GPv2Signing.PreSignature(owner, orderUid, true); | ||
executor.setPreSignature(orderUid, true); | ||
} | ||
|
||
function test_reverts_if_the_order_owner_is_not_the_transaction_sender() public { | ||
vm.expectRevert("GPv2: cannot presign order"); | ||
executor.setPreSignature(orderUid, true); | ||
} | ||
} |