From a9c68a4de0e42199fc9a298d5b7a07df71e704c0 Mon Sep 17 00:00:00 2001 From: TAMARA LIPOWSKI Date: Thu, 30 Jan 2025 17:39:51 -0500 Subject: [PATCH] test: (WIP) Router integration tests TODO it don't pass Took 14 seconds Took 12 minutes --- foundry/test/TychoRouter.t.sol | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/foundry/test/TychoRouter.t.sol b/foundry/test/TychoRouter.t.sol index 4c424d5..9a572ac 100644 --- a/foundry/test/TychoRouter.t.sol +++ b/foundry/test/TychoRouter.t.sol @@ -671,4 +671,23 @@ contract TychoRouterTest is TychoRouterTestSetup { uint256 finalBalance = IERC20(DAI_ADDR).balanceOf(tychoRouterAddr); assertGe(finalBalance, expAmountOut); } + + function testSingleSwapIntegration() public { + // Test created with calldata from our router encoder + // Tests swapping WETH -> DAI on a USV2 pool + vm.rollFork(21740300); + deal(WETH_ADDR, tychoRouterAddr, 1 ether); + uint256 balancerBefore = IERC20(DAI_ADDR).balanceOf(ALICE); + + // Encoded solution generated using `test_split_swap_strategy_encoder` with + // Alice's private key + (bool success,) = tychoRouterAddr.call( + hex"e73e3baa0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002c6a3cd97c6283b95ac8c5a4459ebb0d5fd404f4000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000067c38a9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c6a3cd97c6283b95ac8c5a4459ebb0d5fd404f400000000000000000000000000000000000000000000000000000000679c0498000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000041eea332470b38c64899045460469146ef146969d3ed5f64fc58f25f58bc709dfb172ef15397b7591fcfd6642cd5a50509702c39a39d87ab79575d5c5388203e3b1b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c005a01000000005c2f5a71f67c01775180adc06909288b4c329308bd0625abc02aaa39b223fe8d0a0e5c4f27ead9083c756cc288e6a0c2ddd26feeb64f039a2c41296fcb3f56402c6a3cd97c6283b95ac8c5a4459ebb0d5fd404f40000000000" + ); + uint256 balancerAfter = IERC20(DAI_ADDR).balanceOf(ALICE); + + assertTrue(success, "Call Failed"); + assertGt(balancerAfter, balancerBefore); + + } }