-
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.
Merge branch 'main' into migrate-test-trade-extract-flags
- Loading branch information
Showing
5 changed files
with
88 additions
and
134 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
pragma solidity ^0.8; | ||
|
||
import {GPv2Order} from "src/contracts/libraries/GPv2Order.sol"; | ||
|
||
import {Helper} from "./Helper.sol"; | ||
|
||
contract ExtractOrderUidParams is Helper { | ||
function test_round_trip_encode_decode() public view { | ||
bytes32 orderDigest = keccak256("order digest"); | ||
address owner = address(uint160(uint256(keccak256("owner")))); | ||
uint32 validTo = uint32(uint256(keccak256("valid to"))); | ||
bytes memory orderUid = executor.packOrderUidParamsTest(GPv2Order.UID_LENGTH, orderDigest, owner, validTo); | ||
|
||
(bytes32 extractedOrderDigest, address extractedOwner, uint32 extractedValidTo) = | ||
executor.extractOrderUidParamsTest(orderUid); | ||
assertEq(extractedOrderDigest, orderDigest); | ||
assertEq(extractedOwner, owner); | ||
assertEq(extractedValidTo, validTo); | ||
} | ||
|
||
function test_reverts_with_uid_longer_than_expected() public { | ||
vm.expectRevert("GPv2: invalid uid"); | ||
executor.extractOrderUidParamsTest(new bytes(GPv2Order.UID_LENGTH + 1)); | ||
} | ||
|
||
function test_reverts_with_uid_shorter_than_expected() public { | ||
vm.expectRevert("GPv2: invalid uid"); | ||
executor.extractOrderUidParamsTest(new bytes(GPv2Order.UID_LENGTH - 1)); | ||
} | ||
} |
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,23 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
pragma solidity ^0.8; | ||
|
||
import {GPv2Order} from "src/contracts/libraries/GPv2Order.sol"; | ||
|
||
import {Helper} from "./Helper.sol"; | ||
|
||
contract PackOrderUidParams is Helper { | ||
function test_packOrderUidParams_packs_the_order_UID() public view { | ||
bytes32 orderDigest = keccak256("order digest"); | ||
address owner = address(uint160(uint256(keccak256("owner")))); | ||
uint32 validTo = uint32(uint256(keccak256("valid to"))); | ||
assertEq( | ||
executor.packOrderUidParamsTest(GPv2Order.UID_LENGTH, orderDigest, owner, validTo), | ||
abi.encodePacked(orderDigest, owner, validTo) | ||
); | ||
} | ||
|
||
function test_reverts_if_the_buffer_length_is_wrong() public { | ||
vm.expectRevert("GPv2: uid buffer overflow"); | ||
executor.packOrderUidParamsTest(GPv2Order.UID_LENGTH + 1, bytes32(0), address(0), uint32(0)); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.