Skip to content

Commit

Permalink
added necessary transaction and related test to regression test files
Browse files Browse the repository at this point in the history
  • Loading branch information
ovatman committed Sep 11, 2024
1 parent 7d220ab commit 857969c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions test/regression/swaps.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
3 changes: 2 additions & 1 deletion test/regression/swaps.txn
Original file line number Diff line number Diff line change
@@ -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, )

0 comments on commit 857969c

Please sign in to comment.