Skip to content

Commit

Permalink
Merge pull request #635 from superform-xyz/permit2MultiDst
Browse files Browse the repository at this point in the history
test: new scenario multi dst permit2
  • Loading branch information
0xTimepunk authored Oct 10, 2024
2 parents 4f5ab6b + d570f6a commit 0663699
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ build-sizes: ## Builds the project and shows sizes

.PHONY: test-vvv
test-vvv: ## Runs tests with verbose output
forge test --match-contract SXSVDNormal4626MultiTokenInputFromBeraNoSlippageAMB23 --evm-version cancun -vvv
forge test --match-contract MDMVDMulti0000NoTokenInputSlippageAMB12Permit2 --evm-version cancun -vvv

.PHONY: ftest
ftest: ## Runs tests with cancun evm version
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;

// Test Utils
import "../../../utils/ProtocolActions.sol";

contract MDMVDMulti0000NoTokenInputSlippageAMB12Permit2 is ProtocolActions {
function setUp() public override {
chainIds = [ETH, OP];

super.setUp();
/*//////////////////////////////////////////////////////////////
!! WARNING !! DEFINE TEST SETTINGS HERE
//////////////////////////////////////////////////////////////*/

AMBs = [1, 2];
MultiDstAMBs = [AMBs, AMBs];

CHAIN_0 = OP;
DST_CHAINS = [OP, ETH];

/// @dev define vaults amounts and slippage for every destination chain and for every action
TARGET_UNDERLYINGS[OP][0] = [0, 1];
TARGET_UNDERLYINGS[ETH][0] = [1, 0];

TARGET_VAULTS[OP][0] = [0, 0];
TARGET_VAULTS[ETH][0] = [0, 0];

TARGET_FORM_KINDS[OP][0] = [0, 0];
TARGET_FORM_KINDS[ETH][0] = [0, 0];

MAX_SLIPPAGE = 1000;

LIQ_BRIDGES[OP][0] = [1, 1];
LIQ_BRIDGES[ETH][0] = [1, 1];

RECEIVE_4626[OP][0] = [false, false];
RECEIVE_4626[ETH][0] = [false, false];

actions.push(
TestAction({
action: Actions.DepositPermit2,
multiVaults: true, //!!WARNING turn on or off multi vaults
user: 0,
testType: TestType.Pass,
revertError: "",
revertRole: "",
slippage: 421, // 0% <- if we are testing a pass this must be below each maxSlippage,
dstSwap: false,
externalToken: 1 // 0 = DAI, 1 = USDT, 2 = WETH
})
);
}

/*///////////////////////////////////////////////////////////////
SCENARIO TESTS
//////////////////////////////////////////////////////////////*/

function test_scenario(uint128 amountOne_, uint128 amountTwo_) public {
/// @dev amount = 1 after slippage will become 0, hence starting with 2
amountOne_ = uint128(bound(amountOne_, 2 * 10 ** 6, TOTAL_SUPPLY_USDC / 4));
amountTwo_ = uint128(bound(amountTwo_, 2 * 10 ** 6, TOTAL_SUPPLY_USDC / 4));
AMOUNTS[OP][0] = [amountOne_, amountTwo_];
AMOUNTS[ETH][0] = [amountTwo_, amountOne_];

for (uint256 act; act < actions.length; ++act) {
TestAction memory action = actions[act];
MultiVaultSFData[] memory multiSuperformsData;
SingleVaultSFData[] memory singleSuperformsData;
MessagingAssertVars[] memory aV;
StagesLocalVars memory vars;
bool success;

_runMainStages(action, act, multiSuperformsData, singleSuperformsData, aV, vars, success);
}
}
}
3 changes: 1 addition & 2 deletions test/utils/CommonProtocolActions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ abstract contract CommonProtocolActions is BaseSetup {
abi.encodeWithSelector(LiFiMock.swapAndStartBridgeTokensViaBridge.selector, bridgeData, swapData);
} else {
LibSwap.SwapData[] memory swapData = new LibSwap.SwapData[](1);

swapData[0] = LibSwap.SwapData(
address(0),
/// @dev callTo (arbitrary)
Expand Down Expand Up @@ -181,7 +180,7 @@ abstract contract CommonProtocolActions is BaseSetup {
} else if (args.liqBridgeKind == 2) {
/// @notice bridge id 2 doesn't support same chain swaps
if (args.toChainId == args.srcChainId) {
revert();
revert("bridge id 2 doesn't support same chain swaps: ");
}

ISocketRegistry.BridgeRequest memory bridgeRequest;
Expand Down
2 changes: 1 addition & 1 deletion test/utils/ProtocolActions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3316,7 +3316,7 @@ abstract contract ProtocolActions is CommonProtocolActions {
/// @notice ID: 2 Hyperlane
if (AMBs[i] == 2) {
HyperlaneHelper(getContract(TO_CHAIN, "HyperlaneHelper")).help(
address(HYPERLANE_MAILBOXES[TO_CHAIN]), // BARTIO
address(HYPERLANE_MAILBOXES[TO_CHAIN]), // BARTIO
address(HYPERLANE_MAILBOXES[FROM_CHAIN]), // SEPOLIA
FORKS[FROM_CHAIN], // SEPOLIA
logs
Expand Down

0 comments on commit 0663699

Please sign in to comment.