From 857969c3c05d5b5f3cfcaa935282db798297f1b4 Mon Sep 17 00:00:00 2001 From: Tolga Ovatman Date: Wed, 11 Sep 2024 09:01:01 +0300 Subject: [PATCH] added necessary transaction and related test to regression test files --- test/regression/swaps.sol | 16 ++++++++++++++++ test/regression/swaps.txn | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/regression/swaps.sol b/test/regression/swaps.sol index eb245aa..0772c32 100644 --- a/test/regression/swaps.sol +++ b/test/regression/swaps.sol @@ -720,4 +720,20 @@ contract UniswapV2SwapTest { assert(daiAmountOut >= daiAmountMin); } + + function testRouterAddLiquidity() public { + uint256 testAmount = 131072; // Hex: 0x20000 + _dai.mint(address(this), testAmount); + _dai.approve(address(_uni.router()), testAmount); + _usdc.mint(address(this), testAmount); + _usdc.approve(address(_uni.router()), testAmount); + + _uni.router().addLiquidity(address(_dai), address(_usdc), 10000, 10000, 0, 0, address(this)); + + assert(_dai.balanceOf(address(this)) == 121072); + assert(_usdc.balanceOf(address(this)) == 121072); + assert(_dai.balanceOf(_uni.router().get_local_pair(address(_dai), address(_usdc))) == 10000); + assert(_usdc.balanceOf(_uni.router().get_local_pair(address(_dai), address(_usdc))) == 10000); + assert(UniswapV2Pair(_uni.router().get_local_pair(address(_dai), address(_usdc))).balanceOf(address(this)) == 9000); + } } diff --git a/test/regression/swaps.txn b/test/regression/swaps.txn index f96198e..6e55649 100644 --- a/test/regression/swaps.txn +++ b/test/regression/swaps.txn @@ -1,2 +1,3 @@ create(1, 0, 1724300000, UniswapV2SwapTest, ), -txn(1, 2, 0, 1724300000, testSwapLoop, ) +txn(1, 2, 0, 1724300000, testSwapLoop, ), +txn(1, 2, 0, 1724300000, testRouterAddLiquidity, ) \ No newline at end of file