From 5c5678f2913925b0b3b10e68b3918b44e73ed236 Mon Sep 17 00:00:00 2001 From: adrian Date: Wed, 20 Aug 2025 12:09:15 +0200 Subject: [PATCH] test: update hashflow sequential swap test --- foundry/test/TychoRouterSequentialSwap.t.sol | 13 ++++++++----- src/encoding/evm/swap_encoder/swap_encoders.rs | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/foundry/test/TychoRouterSequentialSwap.t.sol b/foundry/test/TychoRouterSequentialSwap.t.sol index 3d24a41..8a25c0d 100644 --- a/foundry/test/TychoRouterSequentialSwap.t.sol +++ b/foundry/test/TychoRouterSequentialSwap.t.sol @@ -558,11 +558,14 @@ contract TychoRouterSequentialSwapTestForHashflow is TychoRouterTestSetup { // // WETH ──(USV3)──> USDC ───(Hashflow RFQ)──> WBTC - // The Hashflow order expects: - // - 4308094737 USDC input -> 3724533 WBTC output + // The Uniswap pool outputs: + // - 1 weth -> 4322430557 USDC + // The Hashflow tradeRFQT call expects: + // - 4308094737 USDC input -> 3714751 WBTC output + // The difference in USDC (14335820) will stay in the TychoRouter contract uint256 amountIn = 1 ether; - uint256 expectedAmountOut = 3724533; + uint256 expectedAmountOut = 3714751; deal(WETH_ADDR, ALICE, amountIn); uint256 balanceBefore = IERC20(WBTC_ADDR).balanceOf(ALICE); @@ -576,8 +579,8 @@ contract TychoRouterSequentialSwapTestForHashflow is TychoRouterTestSetup { uint256 balanceAfter = IERC20(WBTC_ADDR).balanceOf(ALICE); assertTrue(success, "Call Failed"); - assertGt(balanceAfter - balanceBefore, 0); - assertLe(balanceAfter - balanceBefore, expectedAmountOut); + assertEq(balanceAfter - balanceBefore, expectedAmountOut); assertEq(IERC20(WETH_ADDR).balanceOf(tychoRouterAddr), 0); + assertEq(IERC20(USDC_ADDR).balanceOf(tychoRouterAddr), 14335820); } } diff --git a/src/encoding/evm/swap_encoder/swap_encoders.rs b/src/encoding/evm/swap_encoder/swap_encoders.rs index ce4cadc..fed6326 100644 --- a/src/encoding/evm/swap_encoder/swap_encoders.rs +++ b/src/encoding/evm/swap_encoder/swap_encoders.rs @@ -2200,7 +2200,7 @@ mod tests { } #[test] - fn test_encode_hashflow_single_with_user_data() { + fn test_encode_hashflow_single_fails_without_protocol_data() { // Hashflow requires a swap with protocol data, otherwise will return an error let hashflow_component = ProtocolComponent { id: String::from("hashflow-rfq"),