Skip to content

refactor: update tests with SignetStd for easy local/fork testing #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 54 additions & 54 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
GnosisSafeTest:test_gnosis_receive() (gas: 15927)
OrderOriginPermit2Test:test_fillPermit2() (gas: 223464)
OrderOriginPermit2Test:test_fillPermit2_multi() (gas: 1007964)
OrderOriginPermit2Test:test_initiatePermit2() (gas: 233946)
OrderOriginPermit2Test:test_initiatePermit2_multi() (gas: 984506)
OrdersTest:test_fill_ERC20() (gas: 71459)
OrdersTest:test_fill_ETH() (gas: 69090)
OrdersTest:test_fill_both() (gas: 169814)
OrdersTest:test_fill_multiETH() (gas: 132830)
OrdersTest:test_fill_underflowETH() (gas: 115817)
OrdersTest:test_initiate_ERC20() (gas: 82526)
OrdersTest:test_initiate_ETH() (gas: 45597)
OrdersTest:test_initiate_both() (gas: 119816)
OrdersTest:test_initiate_multiERC20() (gas: 175432)
OrdersTest:test_initiate_multiETH() (gas: 76000)
OrdersTest:test_orderExpired() (gas: 28383)
OrdersTest:test_sweepERC20() (gas: 60695)
OrdersTest:test_sweepETH() (gas: 83379)
OrdersTest:test_underflowETH() (gas: 63976)
PassagePermit2Test:test_disallowedEnterPermit2() (gas: 691528)
PassagePermit2Test:test_enterTokenPermit2() (gas: 144090)
PassageTest:test_configureEnter() (gas: 128735)
PassageTest:test_disallowedEnter() (gas: 57503)
PassageTest:test_enter() (gas: 25519)
PassageTest:test_enterToken() (gas: 65326)
PassageTest:test_enterToken_defaultChain() (gas: 63912)
PassageTest:test_enter_defaultChain() (gas: 24055)
PassageTest:test_fallback() (gas: 22093)
PassageTest:test_onlyTokenAdmin() (gas: 17173)
PassageTest:test_receive() (gas: 21487)
PassageTest:test_setUp() (gas: 17000)
PassageTest:test_withdraw() (gas: 60168)
RollupPassagePermit2Test:test_exitTokenPermit2() (gas: 127878)
RollupPassageTest:test_exit() (gas: 22403)
RollupPassageTest:test_exitToken() (gas: 50824)
RollupPassageTest:test_fallback() (gas: 20509)
RollupPassageTest:test_receive() (gas: 19948)
TransactTest:test_configureGas() (gas: 22828)
TransactTest:test_enterTransact() (gas: 103979)
TransactTest:test_onlyGasAdmin() (gas: 8810)
TransactTest:test_setUp() (gas: 17494)
TransactTest:test_transact() (gas: 101449)
TransactTest:test_transact_defaultChain() (gas: 100562)
TransactTest:test_transact_globalGasLimit() (gas: 104972)
TransactTest:test_transact_perTransactGasLimit() (gas: 32776)
ZenithTest:test_addSequencer() (gas: 88101)
ZenithTest:test_badSignature() (gas: 37061)
ZenithTest:test_incorrectHostBlock() (gas: 35075)
ZenithTest:test_notSequencer() (gas: 33887)
ZenithTest:test_notSequencerAdmin() (gas: 10125)
ZenithTest:test_onePerBlock() (gas: 68153)
ZenithTest:test_removeSequencer() (gas: 39476)
ZenithTest:test_setUp() (gas: 8366)
ZenithTest:test_submitBlock() (gas: 63313)
GnosisSafeTest:test_gnosis_receive() (gas: 16106)
OrderOriginPermit2Test:test_fillPermit2() (gas: 174723)
OrderOriginPermit2Test:test_fillPermit2_multi() (gas: 510586)
OrderOriginPermit2Test:test_initiatePermit2() (gas: 187081)
OrderOriginPermit2Test:test_initiatePermit2_multi() (gas: 470943)
OrdersTest:test_fill_ERC20() (gas: 76273)
OrdersTest:test_fill_ETH() (gas: 73740)
OrdersTest:test_fill_both() (gas: 179143)
OrdersTest:test_fill_multiETH() (gas: 141885)
OrdersTest:test_fill_underflowETH() (gas: 120789)
OrdersTest:test_initiate_ERC20() (gas: 90588)
OrdersTest:test_initiate_ETH() (gas: 53217)
OrdersTest:test_initiate_both() (gas: 130158)
OrdersTest:test_initiate_multiERC20() (gas: 186451)
OrdersTest:test_initiate_multiETH() (gas: 86339)
OrdersTest:test_orderExpired() (gas: 32846)
OrdersTest:test_sweepERC20() (gas: 62965)
OrdersTest:test_sweepETH() (gas: 89995)
OrdersTest:test_underflowETH() (gas: 69404)
PassagePermit2Test:test_disallowedEnterPermit2() (gas: 1130187)
PassagePermit2Test:test_enterTokenPermit2() (gas: 150794)
PassageTest:test_configureEnter() (gas: 141651)
PassageTest:test_disallowedEnter() (gas: 58928)
PassageTest:test_enter() (gas: 26523)
PassageTest:test_enterToken() (gas: 66880)
PassageTest:test_enterToken_defaultChain() (gas: 65384)
PassageTest:test_enter_defaultChain() (gas: 24949)
PassageTest:test_fallback() (gas: 22784)
PassageTest:test_onlyTokenAdmin() (gas: 19145)
PassageTest:test_receive() (gas: 22222)
PassageTest:test_setUp() (gas: 23289)
PassageTest:test_withdraw() (gas: 64486)
RollupPassagePermit2Test:test_exitTokenPermit2() (gas: 135717)
RollupPassageTest:test_exit() (gas: 23114)
RollupPassageTest:test_exitToken() (gas: 53266)
RollupPassageTest:test_fallback() (gas: 20910)
RollupPassageTest:test_receive() (gas: 20393)
TransactTest:test_configureGas() (gas: 27486)
TransactTest:test_enterTransact() (gas: 127464)
TransactTest:test_onlyGasAdmin() (gas: 9895)
TransactTest:test_setUp() (gas: 23757)
TransactTest:test_transact() (gas: 107567)
TransactTest:test_transact_defaultChain() (gas: 106574)
TransactTest:test_transact_globalGasLimit() (gas: 117828)
TransactTest:test_transact_perTransactGasLimit() (gas: 34574)
ZenithTest:test_addSequencer() (gas: 98616)
ZenithTest:test_badSignature() (gas: 46355)
ZenithTest:test_incorrectHostBlock() (gas: 42276)
ZenithTest:test_notSequencer() (gas: 39566)
ZenithTest:test_notSequencerAdmin() (gas: 11279)
ZenithTest:test_onePerBlock() (gas: 78387)
ZenithTest:test_removeSequencer() (gas: 50114)
ZenithTest:test_setUp() (gas: 8035)
ZenithTest:test_submitBlock() (gas: 70434)
2 changes: 1 addition & 1 deletion lib/forge-std
Submodule forge-std updated 56 files
+1 −0 .github/CODEOWNERS
+57 −109 .github/workflows/ci.yml
+3 −1 .github/workflows/sync.yml
+0 −3 .gitmodules
+193 −0 CONTRIBUTING.md
+21 −5 README.md
+12 −0 RELEASE_CHECKLIST.md
+5 −3 foundry.toml
+0 −1 lib/ds-test
+1 −1 package.json
+13 −2 scripts/vm.py
+16 −9 src/Base.sol
+1 −0 src/Script.sol
+590 −202 src/StdAssertions.sol
+49 −11 src/StdChains.sol
+17 −5 src/StdCheats.sol
+30 −0 src/StdConstants.sol
+18 −3 src/StdInvariant.sol
+111 −11 src/StdJson.sol
+202 −107 src/StdStorage.sol
+283 −0 src/StdToml.sol
+1 −19 src/StdUtils.sol
+5 −4 src/Test.sol
+1,416 −62 src/Vm.sol
+635 −608 src/console.sol
+1 −1,555 src/console2.sol
+1 −1 src/interfaces/IERC1155.sol
+3 −3 src/interfaces/IERC4626.sol
+72 −0 src/interfaces/IERC6909.sol
+1 −1 src/interfaces/IERC721.sol
+150 −0 src/interfaces/IERC7540.sol
+241 −0 src/interfaces/IERC7575.sol
+0 −216 src/mocks/MockERC20.sol
+0 −221 src/mocks/MockERC721.sol
+693 −4 src/safeconsole.sol
+44 −0 test/CommonBase.t.sol
+35 −909 test/StdAssertions.t.sol
+55 −44 test/StdChains.t.sol
+66 −37 test/StdCheats.t.sol
+38 −0 test/StdConstants.t.sol
+12 −12 test/StdError.t.sol
+49 −0 test/StdJson.t.sol
+12 −22 test/StdMath.t.sol
+190 −17 test/StdStorage.t.sol
+1 −1 test/StdStyle.t.sol
+49 −0 test/StdToml.t.sol
+26 −26 test/StdUtils.t.sol
+9 −6 test/Vm.t.sol
+1 −1 test/compilation/CompilationScript.sol
+1 −1 test/compilation/CompilationScriptBase.sol
+1 −1 test/compilation/CompilationTest.sol
+1 −1 test/compilation/CompilationTestBase.sol
+8 −0 test/fixtures/test.json
+6 −0 test/fixtures/test.toml
+0 −441 test/mocks/MockERC20.t.sol
+0 −721 test/mocks/MockERC721.t.sol
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
2 changes: 1 addition & 1 deletion lib/safe-smart-account
2 changes: 1 addition & 1 deletion lib/stablecoin-evm
Submodule stablecoin-evm updated 221 files
57 changes: 12 additions & 45 deletions test/Helpers.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,28 @@ pragma solidity 0.8.26;
// system contracts
import {Zenith} from "../src/Zenith.sol";
import {UsesPermit2} from "../src/UsesPermit2.sol";
import {RollupOrders} from "../src/orders/RollupOrders.sol";
// deps
import {ERC20} from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import {ERC20Burnable} from "openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol";
import {Test, console2} from "forge-std/Test.sol";
import {SignetStdTest, TestERC20} from "./SignetStdTest.t.sol";

contract TestERC20 is ERC20Burnable {
constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {}

function mint(address recipient, uint256 amount) external {
_mint(recipient, amount);
}
}

contract Permit2Helpers is Test {
address permit2Contract;

contract Permit2Helpers is SignetStdTest {
/// @notice the address signing the Permit messages and its pk
uint256 ownerKey = 123;
address owner = vm.addr(ownerKey);

// permit consts
UsesPermit2.Witness witness;

// single permit
UsesPermit2.Permit2 singlePermit;
ISignatureTransfer.SignatureTransferDetails singleTransferDetails;

// batch permit
UsesPermit2.Permit2Batch batchPermit;
ISignatureTransfer.SignatureTransferDetails[] batchTransferDetails;

bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;

Expand All @@ -50,18 +48,6 @@ contract Permit2Helpers is Test {
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME);
}

function _setUpPermit2(address token, uint256 amount) internal {
vm.label(owner, "owner");

// setup permit2 contract
permit2Contract = 0x000000000022D473030F116dDEE9F6B43aC78BA3;
vm.label(address(permit2Contract), "permit2");

// approve permit2
vm.prank(owner);
TestERC20(token).approve(address(permit2Contract), amount * 10000);
}

/// @notice given a Permit and a Witness, produce a signature from the `owner`
function signPermit(
uint256 signingKey,
Expand Down Expand Up @@ -154,7 +140,7 @@ contract Permit2Helpers is Test {

/// @notice Builds a domain separator using the current chainId and contract address.
function _buildDomainSeparator(bytes32 typeHash, bytes32 nameHash) private view returns (bytes32) {
return keccak256(abi.encode(typeHash, nameHash, block.chainid, permit2Contract));
return keccak256(abi.encode(typeHash, nameHash, block.chainid, PERMIT2));
}

/// @notice Creates an EIP-712 typed data hash
Expand Down Expand Up @@ -187,22 +173,3 @@ interface IBatchPermit {
bytes calldata /*signature*/
) external;
}

contract HelpersTest is Test {
Zenith public target;

function setUp() public {
vm.createSelectFork("https://rpc.holesky.ethpandaops.io");
target = new Zenith(0x29403F107781ea45Bf93710abf8df13F67f2008f);
}

function check_signature() public {
bytes32 hash = 0xdcd0af9a45fa82dcdd1e4f9ef703d8cd459b6950c0638154c67117e86facf9c1;
uint8 v = 28;
bytes32 r = 0xb89764d107f812dbbebb925711b320d336ff8d03f08570f051123df86334f3f5;
bytes32 s = 0x394cd592577ce6307154045607b9b18ecc1de0eb636e996981477c2d9b1a7675;
address signer = ecrecover(hash, v, r, s);
vm.label(signer, "recovered signer");
assertEq(signer, 0x5b0517Dc94c413a5871536872605522E54C85a03);
}
}
34 changes: 17 additions & 17 deletions test/Orders.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ import {OrderOrigin} from "../src/orders/OrderOrigin.sol";
import {TestERC20} from "./Helpers.t.sol";
import {ERC20} from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import {Test, console2} from "forge-std/Test.sol";
import {SignetStdTest} from "./SignetStdTest.t.sol";

contract OrdersTest is Test {
contract OrdersTest is SignetStdTest {
RollupOrders public target;

IOrders.Input[] public inputs;
IOrders.Output[] public outputs;

address token;
address token2;
uint32 chainId = 3;

address recipient = address(0x123);
uint256 amount = 200;
uint256 deadline = block.timestamp;
uint256 deadline;

event Filled(IOrders.Output[] outputs);

Expand All @@ -29,24 +31,28 @@ contract OrdersTest is Test {
event Sweep(address indexed recipient, address indexed token, uint256 amount);

function setUp() public virtual {
target = new RollupOrders(address(0));
target = ROLLUP_ORDERS;

// setup token
token = address(new TestERC20("hi", "HI"));
// setup first token
token = address(ROLLUP_WBTC);
vm.prank(ROLLUP_MINTER);
TestERC20(token).mint(address(this), amount * 10000);
TestERC20(token).approve(address(target), amount * 10000);

// setup second token
token2 = address(new TestERC20("bye", "BYE"));
token2 = address(ROLLUP_WETH);
vm.prank(ROLLUP_MINTER);
TestERC20(token2).mint(address(this), amount * 10000);
TestERC20(token2).approve(address(target), amount * 10000);

// setup simple Order Inputs/Outputs
IOrders.Input memory input = IOrders.Input(token, amount);
inputs.push(input);

IOrders.Output memory output = IOrders.Output(token, amount, recipient, chainId);
IOrders.Output memory output = IOrders.Output(token, amount, recipient, ROLLUP_CHAIN_ID);
outputs.push(output);

deadline = block.timestamp;
}

// input ERC20
Expand Down Expand Up @@ -143,9 +149,6 @@ contract OrdersTest is Test {
}

function test_sweepETH() public {
// set self as Builder
vm.coinbase(address(this));

// initiate an ETH order
inputs[0].token = address(0);
target.initiate{value: amount}(deadline, inputs, outputs);
Expand All @@ -161,9 +164,6 @@ contract OrdersTest is Test {
}

function test_sweepERC20() public {
// set self as Builder
vm.coinbase(address(this));

// send ERC20 to the contract
TestERC20(token).transfer(address(target), amount);

Expand Down Expand Up @@ -194,7 +194,7 @@ contract OrdersTest is Test {

function test_fill_both() public {
// add ETH output
outputs.push(IOrders.Output(address(0), amount * 2, recipient, chainId));
outputs.push(IOrders.Output(address(0), amount * 2, recipient, ROLLUP_CHAIN_ID));

// expect Outputs are filled, ERC20 is transferred
vm.expectEmit();
Expand All @@ -211,7 +211,7 @@ contract OrdersTest is Test {
// change first output to ETH
outputs[0].token = address(0);
// add second ETH oputput
outputs.push(IOrders.Output(address(0), amount * 2, recipient, chainId));
outputs.push(IOrders.Output(address(0), amount * 2, recipient, ROLLUP_CHAIN_ID));

// expect Order event is initiated
vm.expectEmit();
Expand All @@ -226,7 +226,7 @@ contract OrdersTest is Test {
// change first output to ETH
outputs[0].token = address(0);
// add second ETH output
outputs.push(IOrders.Output(address(0), 1, recipient, chainId));
outputs.push(IOrders.Output(address(0), 1, recipient, ROLLUP_CHAIN_ID));

// total ETH outputs should be `amount` + 1; function should underflow only sending `amount`
vm.expectRevert();
Expand Down
Loading