Skip to content
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

Add more tests for nonstandard orders #54

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Changes from 1 commit
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
31 changes: 31 additions & 0 deletions test/foundry-tests/reactors/RelayOrderReactorTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ contract RelayOrderReactorTest is GasSnapshot, Test, PermitSignature, DeployPerm
assertEq(tokenIn.balanceOf(address(filler)), 250000000000000000);
}

function test_execute_noInputs() public {
Input[] memory inputs = new Input[](0);
OrderInfo memory orderInfo =
OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 1000);
RelayOrder memory order = RelayOrderBuilder.init(orderInfo, inputs).withEndTime(block.timestamp + 1000);

SignedOrder memory signedOrder =
SignedOrder(abi.encode(order), signOrder(swapperPrivateKey, address(permit2), order));

vm.expectEmit(true, true, true, true, address(reactor));
emit Fill(order.hash(), address(filler), swapper, order.info.nonce);
// should be fillable
vm.prank(filler);
reactor.execute(signedOrder, filler);
}

function test_multicall_execute_noDecay() public {
tokenIn.mint(address(swapper), ONE * 100);
// First order.
Expand Down Expand Up @@ -176,6 +192,21 @@ contract RelayOrderReactorTest is GasSnapshot, Test, PermitSignature, DeployPerm
reactor.execute(signedOrder, filler);
}

function test_execute_noInputs_reverts_SignatureExpired() public {
zhongeric marked this conversation as resolved.
Show resolved Hide resolved
uint256 deadline = block.timestamp + 10;
Input[] memory inputs = new Input[](0);
RelayOrder memory order = RelayOrderBuilder.initDefault(tokenIn, address(reactor), swapper);
zhongeric marked this conversation as resolved.
Show resolved Hide resolved
order.info = order.info.withDeadline(deadline);

SignedOrder memory signedOrder =
SignedOrder(abi.encode(order), signOrder(swapperPrivateKey, address(permit2), order));

vm.warp(deadline + 1);
vm.prank(filler);
zhongeric marked this conversation as resolved.
Show resolved Hide resolved
vm.expectRevert(abi.encodeWithSelector(SignatureExpired.selector, deadline));
reactor.execute(signedOrder, filler);
}

function test_execute_reverts_InvalidNonce() public {
tokenIn.mint(address(swapper), ONE * 100);

Expand Down
Loading