Skip to content

Commit

Permalink
test: double step cases (erc20 and/or native combos)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Dec 3, 2024
1 parent 1d6d23e commit 0a3a1ad
Show file tree
Hide file tree
Showing 2 changed files with 750 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,148 @@ contract SynapseIntentRouterBalanceChecksTest is SynapseIntentRouterTest {
function test_depositNative_exactAmount_extraFunds_revert_unspentNative() public withExtraFunds {
test_depositNative_exactAmount_revert_unspentNative();
}

// ═════════════════════════════════════════ DOUBLE ZAP UNSPENT FUNDS ══════════════════════════════════════════════

function test_swapDepositERC20_exactAmounts_revert_unspentERC20() public {
uint256 amountDeposit = AMOUNT * TOKEN_PRICE;
ISynapseIntentRouter.StepParams[] memory steps = getSwapDepositERC20Steps(FULL_BALANCE, amountDeposit);
vm.expectRevert(SIR__UnspentFunds.selector);
completeUserIntent({
msgValue: 0,
amountIn: AMOUNT + 1,
minLastStepAmountIn: amountDeposit,
deadline: block.timestamp,
steps: steps
});
}

function test_swapDepositERC20_exactAmounts_revert_unspentWETH() public {
uint256 amountReduced = AMOUNT * TOKEN_PRICE - 1;
ISynapseIntentRouter.StepParams[] memory steps = getSwapDepositERC20Steps(FULL_BALANCE, amountReduced);
vm.expectRevert(SIR__UnspentFunds.selector);
completeUserIntent({
msgValue: 0,
amountIn: AMOUNT,
minLastStepAmountIn: amountReduced,
deadline: block.timestamp,
steps: steps
});
}

function test_swapDepositERC20_exactAmounts_extraFunds_revert_unspentERC20() public withExtraFunds {
test_swapDepositERC20_exactAmounts_revert_unspentERC20();
}

function test_swapDepositERC20_exactAmounts_extraFunds_revert_unspentWETH() public withExtraFunds {
test_swapDepositERC20_exactAmounts_revert_unspentWETH();
}

function test_swapDepositERC20_exactAmount1_extraFunds_revertWithBalanceChecks() public override withExtraFunds {
uint256 amountDeposit = AMOUNT * TOKEN_PRICE;
ISynapseIntentRouter.StepParams[] memory steps = getSwapDepositERC20Steps(FULL_BALANCE, amountDeposit);
vm.expectRevert(SIR__UnspentFunds.selector);
completeUserIntent({
msgValue: 0,
amountIn: AMOUNT,
minLastStepAmountIn: amountDeposit,
deadline: block.timestamp,
steps: steps
});
}

function test_wrapDepositWETH_exactAmounts_revert_unspentNative() public {
ISynapseIntentRouter.StepParams[] memory steps = getWrapDepositWETHSteps(AMOUNT, AMOUNT);
steps[0].msgValue = AMOUNT + 1;
vm.expectRevert(SIR__UnspentFunds.selector);
completeUserIntent({
msgValue: AMOUNT + 1,
amountIn: AMOUNT + 1,
minLastStepAmountIn: AMOUNT,
deadline: block.timestamp,
steps: steps
});
}

function test_wrapDepositWETH_exactAmounts_revert_unspentWETH() public {
uint256 amountReduced = AMOUNT - 1;
ISynapseIntentRouter.StepParams[] memory steps = getWrapDepositWETHSteps(AMOUNT, amountReduced);
vm.expectRevert(SIR__UnspentFunds.selector);
completeUserIntent({
msgValue: AMOUNT,
amountIn: AMOUNT,
minLastStepAmountIn: amountReduced,
deadline: block.timestamp,
steps: steps
});
}

function test_wrapDepositWETH_exactAmounts_extraFunds_revert_unspentNative() public withExtraFunds {
test_wrapDepositWETH_exactAmounts_revert_unspentNative();
}

function test_wrapDepositWETH_exactAmounts_extraFunds_revert_unspentWETH() public withExtraFunds {
test_wrapDepositWETH_exactAmounts_revert_unspentWETH();
}

function test_wrapDepositWETH_exactAmount1_extraFunds_revertWithBalanceChecks() public override withExtraFunds {
ISynapseIntentRouter.StepParams[] memory steps = getWrapDepositWETHSteps(FULL_BALANCE, AMOUNT);
vm.expectRevert(SIR__UnspentFunds.selector);
completeUserIntent({
msgValue: AMOUNT,
amountIn: AMOUNT,
minLastStepAmountIn: AMOUNT,
deadline: block.timestamp,
steps: steps
});
}

function test_unwrapDepositNative_exactAmounts_revert_unspentWETH() public {
ISynapseIntentRouter.StepParams[] memory steps = getUnwrapDepositNativeSteps(AMOUNT, AMOUNT);
vm.expectRevert(SIR__UnspentFunds.selector);
completeUserIntent({
msgValue: 0,
amountIn: AMOUNT + 1,
minLastStepAmountIn: AMOUNT,
deadline: block.timestamp,
steps: steps
});
}

function test_unwrapDepositNative_exactAmounts_revert_unspentNative() public {
uint256 amountReduced = AMOUNT - 1;
ISynapseIntentRouter.StepParams[] memory steps = getUnwrapDepositNativeSteps(AMOUNT, amountReduced);
vm.expectRevert(SIR__UnspentFunds.selector);
completeUserIntent({
msgValue: 0,
amountIn: AMOUNT,
minLastStepAmountIn: amountReduced,
deadline: block.timestamp,
steps: steps
});
}

function test_unwrapDepositNative_exactAmounts_extraFunds_revert_unspentWETH() public withExtraFunds {
test_unwrapDepositNative_exactAmounts_revert_unspentWETH();
}

function test_unwrapDepositNative_exactAmounts_extraFunds_revert_unspentNative() public withExtraFunds {
test_unwrapDepositNative_exactAmounts_revert_unspentNative();
}

function test_unwrapDepositNative_exactAmount1_extraFunds_revertWithBalanceChecks()
public
override
withExtraFunds
{
ISynapseIntentRouter.StepParams[] memory steps = getUnwrapDepositNativeSteps(FULL_BALANCE, AMOUNT);
vm.expectRevert(SIR__UnspentFunds.selector);
completeUserIntent({
msgValue: 0,
amountIn: AMOUNT,
minLastStepAmountIn: AMOUNT,
deadline: block.timestamp,
steps: steps
});
}
}
Loading

0 comments on commit 0a3a1ad

Please sign in to comment.