chore: Write encoding rust calldata to file and read in solidity test
This way we can automatically replace the calldata when something changes. We don't need to manually replace the string ourselves. --- don't change below this line --- ENG-4453 Took 3 hours 26 minutes
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
pragma solidity ^0.8.26;
|
||||
|
||||
import "../TestUtils.sol";
|
||||
import "@src/executors/BalancerV2Executor.sol";
|
||||
import {Test} from "../../lib/forge-std/src/Test.sol";
|
||||
import {Constants} from "../Constants.sol";
|
||||
|
||||
contract BalancerV2ExecutorExposed is BalancerV2Executor {
|
||||
@@ -24,7 +24,7 @@ contract BalancerV2ExecutorExposed is BalancerV2Executor {
|
||||
}
|
||||
}
|
||||
|
||||
contract BalancerV2ExecutorTest is Test, Constants {
|
||||
contract BalancerV2ExecutorTest is Constants, TestUtils {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
BalancerV2ExecutorExposed balancerV2Exposed;
|
||||
@@ -96,10 +96,8 @@ contract BalancerV2ExecutorTest is Test, Constants {
|
||||
}
|
||||
|
||||
function testDecodeIntegration() public view {
|
||||
// Generated by the SwapEncoder - test_encode_balancer_v2
|
||||
bytes memory protocolData =
|
||||
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2ba100000625a3754423978a60c9317c58a424e3d5c6ee304399dbdb9c8ef030ab642b10820db8f560002000000000000000000141d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e0105";
|
||||
|
||||
loadCallDataFromFile("test_encode_balancer_v2");
|
||||
(
|
||||
IERC20 tokenIn,
|
||||
IERC20 tokenOut,
|
||||
@@ -120,7 +118,7 @@ contract BalancerV2ExecutorTest is Test, Constants {
|
||||
function testSwapIntegration() public {
|
||||
// Generated by the SwapEncoder - test_encode_balancer_v2
|
||||
bytes memory protocolData =
|
||||
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2ba100000625a3754423978a60c9317c58a424e3d5c6ee304399dbdb9c8ef030ab642b10820db8f560002000000000000000000141d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e0105";
|
||||
loadCallDataFromFile("test_encode_balancer_v2");
|
||||
|
||||
uint256 amountIn = 10 ** 18;
|
||||
deal(WETH_ADDR, address(balancerV2Exposed), amountIn);
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
pragma solidity ^0.8.26;
|
||||
|
||||
import {EkuboExecutor, TokenTransfer} from "@src/executors/EkuboExecutor.sol";
|
||||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import "../TestUtils.sol";
|
||||
import {Constants} from "../Constants.sol";
|
||||
import {Test, console} from "forge-std/Test.sol";
|
||||
import {NATIVE_TOKEN_ADDRESS} from "@ekubo/math/constants.sol";
|
||||
import {EkuboExecutor, TokenTransfer} from "@src/executors/EkuboExecutor.sol";
|
||||
import {ICore} from "@ekubo/interfaces/ICore.sol";
|
||||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import {NATIVE_TOKEN_ADDRESS} from "@ekubo/math/constants.sol";
|
||||
import {console} from "forge-std/Test.sol";
|
||||
|
||||
contract EkuboExecutorTest is Test, Constants {
|
||||
contract EkuboExecutorTest is Constants, TestUtils {
|
||||
address constant EXECUTOR_ADDRESS =
|
||||
0xcA4F73Fe97D0B987a0D12B39BBD562c779BAb6f6; // Same address as in swap_encoder.rs tests
|
||||
EkuboExecutor executor;
|
||||
@@ -154,8 +155,6 @@ contract EkuboExecutorTest is Test, Constants {
|
||||
|
||||
// Data is generated by test case in swap_encoder::tests::ekubo::test_encode_swap_multi
|
||||
function testMultiHopSwapIntegration() public {
|
||||
multiHopSwap(
|
||||
hex"00ca4f73fe97d0b987a0d12b39bbd562c779bab6f60000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4851d02a5948496a67827242eabc5725531342527c000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000001a36e2eb1c43200000032"
|
||||
);
|
||||
multiHopSwap(loadCallDataFromFile("test_ekubo_encode_swap_multi"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +247,6 @@ contract UniswapV2ExecutorTest is Test, Constants, Permit2TestHelper {
|
||||
}
|
||||
|
||||
function testDecodeIntegration() public view {
|
||||
// Generated by the ExecutorStrategyEncoder - test_executor_strategy_encode
|
||||
bytes memory protocolData =
|
||||
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc288e6a0c2ddd26feeb64f039a2c41296fcb3f564000000000000000000000000000000000000000010000";
|
||||
|
||||
@@ -268,7 +267,6 @@ contract UniswapV2ExecutorTest is Test, Constants, Permit2TestHelper {
|
||||
}
|
||||
|
||||
function testSwapIntegration() public {
|
||||
// Generated by the ExecutorStrategyEncoder - test_executor_strategy_encode
|
||||
bytes memory protocolData =
|
||||
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2a478c2975ab1ea89e8196811f51a7b7ade33eb111d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e0000";
|
||||
uint256 amountIn = 10 ** 18;
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
pragma solidity ^0.8.26;
|
||||
|
||||
import "../../src/executors/UniswapV4Executor.sol";
|
||||
import "../TestUtils.sol";
|
||||
import "./UniswapV4Utils.sol";
|
||||
import "@src/executors/TokenTransfer.sol";
|
||||
import "@src/executors/UniswapV4Executor.sol";
|
||||
import {Constants} from "../Constants.sol";
|
||||
import {Test} from "../../lib/forge-std/src/Test.sol";
|
||||
import {SafeCallback} from "@uniswap/v4-periphery/src/base/SafeCallback.sol";
|
||||
import "@src/executors/TokenTransfer.sol";
|
||||
import {Test} from "../../lib/forge-std/src/Test.sol";
|
||||
|
||||
contract UniswapV4ExecutorExposed is UniswapV4Executor {
|
||||
constructor(IPoolManager _poolManager, address _permit2)
|
||||
@@ -30,7 +31,7 @@ contract UniswapV4ExecutorExposed is UniswapV4Executor {
|
||||
}
|
||||
}
|
||||
|
||||
contract UniswapV4ExecutorTest is Test, Constants {
|
||||
contract UniswapV4ExecutorTest is Constants, TestUtils {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
UniswapV4ExecutorExposed uniswapV4Exposed;
|
||||
@@ -130,9 +131,8 @@ contract UniswapV4ExecutorTest is Test, Constants {
|
||||
|
||||
function testSingleSwapIntegration() public {
|
||||
// USDE -> USDT
|
||||
// Generated by the Tycho swap encoder - test_encode_uniswap_v4_simple_swap
|
||||
bytes memory protocolData =
|
||||
hex"4c9edd5852cd905f086c759e8383e09bff1e68b3dac17f958d2ee523a2206206994597c13d831ec70100cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2dac17f958d2ee523a2206206994597c13d831ec7000064000001";
|
||||
loadCallDataFromFile("test_encode_uniswap_v4_simple_swap");
|
||||
uint256 amountIn = 100 ether;
|
||||
deal(USDE_ADDR, address(uniswapV4Exposed), amountIn);
|
||||
uint256 usdeBalanceBeforePool = USDE.balanceOf(poolManager);
|
||||
@@ -188,10 +188,8 @@ contract UniswapV4ExecutorTest is Test, Constants {
|
||||
|
||||
function testMultipleSwapIntegration() public {
|
||||
// USDE -> USDT -> WBTC
|
||||
// Generated by the Tycho swap encoder - test_encode_uniswap_v4_sequential_swap
|
||||
|
||||
bytes memory protocolData =
|
||||
hex"4c9edd5852cd905f086c759e8383e09bff1e68b32260fac5e5542a773aa44fbcfedf7c193bc2c5990100cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2dac17f958d2ee523a2206206994597c13d831ec70000640000012260fac5e5542a773aa44fbcfedf7c193bc2c599000bb800003c";
|
||||
loadCallDataFromFile("test_encode_uniswap_v4_sequential_swap");
|
||||
|
||||
uint256 amountIn = 100 ether;
|
||||
deal(USDE_ADDR, address(uniswapV4Exposed), amountIn);
|
||||
|
||||
Reference in New Issue
Block a user