Skip to content

Commit 0663699

Browse files
authored
Merge pull request #635 from superform-xyz/permit2MultiDst
test: new scenario multi dst permit2
2 parents 4f5ab6b + d570f6a commit 0663699

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ build-sizes: ## Builds the project and shows sizes
121121

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

126126
.PHONY: ftest
127127
ftest: ## Runs tests with cancun evm version
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.23;
3+
4+
// Test Utils
5+
import "../../../utils/ProtocolActions.sol";
6+
7+
contract MDMVDMulti0000NoTokenInputSlippageAMB12Permit2 is ProtocolActions {
8+
function setUp() public override {
9+
chainIds = [ETH, OP];
10+
11+
super.setUp();
12+
/*//////////////////////////////////////////////////////////////
13+
!! WARNING !! DEFINE TEST SETTINGS HERE
14+
//////////////////////////////////////////////////////////////*/
15+
16+
AMBs = [1, 2];
17+
MultiDstAMBs = [AMBs, AMBs];
18+
19+
CHAIN_0 = OP;
20+
DST_CHAINS = [OP, ETH];
21+
22+
/// @dev define vaults amounts and slippage for every destination chain and for every action
23+
TARGET_UNDERLYINGS[OP][0] = [0, 1];
24+
TARGET_UNDERLYINGS[ETH][0] = [1, 0];
25+
26+
TARGET_VAULTS[OP][0] = [0, 0];
27+
TARGET_VAULTS[ETH][0] = [0, 0];
28+
29+
TARGET_FORM_KINDS[OP][0] = [0, 0];
30+
TARGET_FORM_KINDS[ETH][0] = [0, 0];
31+
32+
MAX_SLIPPAGE = 1000;
33+
34+
LIQ_BRIDGES[OP][0] = [1, 1];
35+
LIQ_BRIDGES[ETH][0] = [1, 1];
36+
37+
RECEIVE_4626[OP][0] = [false, false];
38+
RECEIVE_4626[ETH][0] = [false, false];
39+
40+
actions.push(
41+
TestAction({
42+
action: Actions.DepositPermit2,
43+
multiVaults: true, //!!WARNING turn on or off multi vaults
44+
user: 0,
45+
testType: TestType.Pass,
46+
revertError: "",
47+
revertRole: "",
48+
slippage: 421, // 0% <- if we are testing a pass this must be below each maxSlippage,
49+
dstSwap: false,
50+
externalToken: 1 // 0 = DAI, 1 = USDT, 2 = WETH
51+
})
52+
);
53+
}
54+
55+
/*///////////////////////////////////////////////////////////////
56+
SCENARIO TESTS
57+
//////////////////////////////////////////////////////////////*/
58+
59+
function test_scenario(uint128 amountOne_, uint128 amountTwo_) public {
60+
/// @dev amount = 1 after slippage will become 0, hence starting with 2
61+
amountOne_ = uint128(bound(amountOne_, 2 * 10 ** 6, TOTAL_SUPPLY_USDC / 4));
62+
amountTwo_ = uint128(bound(amountTwo_, 2 * 10 ** 6, TOTAL_SUPPLY_USDC / 4));
63+
AMOUNTS[OP][0] = [amountOne_, amountTwo_];
64+
AMOUNTS[ETH][0] = [amountTwo_, amountOne_];
65+
66+
for (uint256 act; act < actions.length; ++act) {
67+
TestAction memory action = actions[act];
68+
MultiVaultSFData[] memory multiSuperformsData;
69+
SingleVaultSFData[] memory singleSuperformsData;
70+
MessagingAssertVars[] memory aV;
71+
StagesLocalVars memory vars;
72+
bool success;
73+
74+
_runMainStages(action, act, multiSuperformsData, singleSuperformsData, aV, vars, success);
75+
}
76+
}
77+
}

test/utils/CommonProtocolActions.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ abstract contract CommonProtocolActions is BaseSetup {
144144
abi.encodeWithSelector(LiFiMock.swapAndStartBridgeTokensViaBridge.selector, bridgeData, swapData);
145145
} else {
146146
LibSwap.SwapData[] memory swapData = new LibSwap.SwapData[](1);
147-
148147
swapData[0] = LibSwap.SwapData(
149148
address(0),
150149
/// @dev callTo (arbitrary)
@@ -181,7 +180,7 @@ abstract contract CommonProtocolActions is BaseSetup {
181180
} else if (args.liqBridgeKind == 2) {
182181
/// @notice bridge id 2 doesn't support same chain swaps
183182
if (args.toChainId == args.srcChainId) {
184-
revert();
183+
revert("bridge id 2 doesn't support same chain swaps: ");
185184
}
186185

187186
ISocketRegistry.BridgeRequest memory bridgeRequest;

test/utils/ProtocolActions.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3316,7 +3316,7 @@ abstract contract ProtocolActions is CommonProtocolActions {
33163316
/// @notice ID: 2 Hyperlane
33173317
if (AMBs[i] == 2) {
33183318
HyperlaneHelper(getContract(TO_CHAIN, "HyperlaneHelper")).help(
3319-
address(HYPERLANE_MAILBOXES[TO_CHAIN]), // BARTIO
3319+
address(HYPERLANE_MAILBOXES[TO_CHAIN]), // BARTIO
33203320
address(HYPERLANE_MAILBOXES[FROM_CHAIN]), // SEPOLIA
33213321
FORKS[FROM_CHAIN], // SEPOLIA
33223322
logs

0 commit comments

Comments
 (0)