Skip to content

Commit

Permalink
test: fix before amount
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Aug 20, 2024
1 parent 8c6c122 commit 52c7912
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/test/Auction.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ contract AuctionTest is Setup, ITaker {
skip(auction.auctionLength() / 2);

uint256 needed = auction.getAmountNeeded(id, _amount);
uint256 beforeAsset = ERC20(asset).balanceOf(address(this));

airdrop(ERC20(asset), address(this), needed);

Expand All @@ -311,7 +312,7 @@ contract AuctionTest is Setup, ITaker {
(, , , _available) = auction.auctionInfo(id);
assertEq(_available, 0);

assertEq(ERC20(asset).balanceOf(address(this)), 0);
assertEq(ERC20(asset).balanceOf(address(this)), beforeAsset);
assertEq(ERC20(from).balanceOf(address(this)), before + _amount);
assertEq(ERC20(from).balanceOf(address(auction)), 0);
assertEq(ERC20(asset).balanceOf(address(mockStrategy)), needed);
Expand Down Expand Up @@ -351,6 +352,7 @@ contract AuctionTest is Setup, ITaker {
uint256 toTake = (_amount * _percent) / MAX_BPS;
uint256 left = _amount - toTake;
uint256 needed = auction.getAmountNeeded(id, toTake);
uint256 beforeAsset = ERC20(asset).balanceOf(address(this));

airdrop(ERC20(asset), address(this), needed);

Expand All @@ -366,7 +368,7 @@ contract AuctionTest is Setup, ITaker {

(, , , _available) = auction.auctionInfo(id);
assertEq(_available, left);
assertEq(ERC20(asset).balanceOf(address(this)), 0);
assertEq(ERC20(asset).balanceOf(address(this)), beforeAsset);
assertEq(ERC20(from).balanceOf(address(this)), before + toTake);
assertEq(ERC20(from).balanceOf(address(auction)), left);
assertEq(ERC20(asset).balanceOf(address(mockStrategy)), needed);
Expand Down Expand Up @@ -405,6 +407,7 @@ contract AuctionTest is Setup, ITaker {
uint256 toTake = _amount / 2;
uint256 left = _amount - toTake;
uint256 needed = auction.getAmountNeeded(id, toTake);
uint256 beforeAsset = ERC20(asset).balanceOf(address(this));

airdrop(ERC20(asset), address(this), needed);

Expand All @@ -424,7 +427,7 @@ contract AuctionTest is Setup, ITaker {

(, , , _available) = auction.auctionInfo(id);
assertEq(_available, left);
assertEq(ERC20(asset).balanceOf(address(this)), 0);
assertEq(ERC20(asset).balanceOf(address(this)), beforeAsset);
assertEq(ERC20(from).balanceOf(address(this)), before + toTake);
assertEq(ERC20(from).balanceOf(address(auction)), left);
assertEq(ERC20(asset).balanceOf(address(mockStrategy)), needed);
Expand Down
6 changes: 4 additions & 2 deletions src/test/AuctionSwapper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ contract AuctionSwapperTest is Setup {
uint256 toTake = (_amount * _percent) / MAX_BPS;
uint256 left = _amount - toTake;
uint256 needed = auction.getAmountNeeded(id, toTake);
uint256 beforeAsset = ERC20(asset).balanceOf(address(this));

airdrop(ERC20(asset), address(this), needed);

Expand All @@ -324,7 +325,7 @@ contract AuctionSwapperTest is Setup {

(, , , _available) = auction.auctionInfo(id);
assertEq(_available, left);
assertEq(ERC20(asset).balanceOf(address(this)), 0);
assertEq(ERC20(asset).balanceOf(address(this)), beforeAsset);
assertEq(ERC20(from).balanceOf(address(this)), before + toTake);
assertEq(ERC20(from).balanceOf(address(auction)), left);
assertEq(ERC20(asset).balanceOf(address(swapper)), needed);
Expand Down Expand Up @@ -470,6 +471,7 @@ contract AuctionSwapperTest is Setup {
uint256 toTake = (kickable * _percent) / MAX_BPS;
uint256 left = kickable - toTake;
uint256 needed = auction.getAmountNeeded(id, toTake);
uint256 beforeAsset = ERC20(asset).balanceOf(address(this));

airdrop(ERC20(asset), address(this), needed);

Expand All @@ -487,7 +489,7 @@ contract AuctionSwapperTest is Setup {

(, , , _available) = auction.auctionInfo(id);
assertEq(_available, left);
assertEq(ERC20(asset).balanceOf(address(this)), 0);
assertEq(ERC20(asset).balanceOf(address(this)), beforeAsset);
assertEq(ERC20(from).balanceOf(address(this)), before + toTake);
assertEq(ERC20(from).balanceOf(address(auction)), left);
assertEq(ERC20(asset).balanceOf(address(swapper)), needed);
Expand Down

0 comments on commit 52c7912

Please sign in to comment.