Skip to content

Commit

Permalink
test: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAustrian committed May 10, 2024
1 parent 982abaa commit 6a092ad
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/unit/BPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ abstract contract BasePoolTest is Test, BConst, Utils {
}
}

function _zeroAmountsArray() internal view returns (uint256[] memory _zeroAmounts) {
_zeroAmounts = new uint256[](tokens.length);
}

function _mockTransfer(address _token) internal {
// TODO: add amount to transfer to check that it's called with the right amount
vm.mockCall(_token, abi.encodeWithSelector(IERC20(_token).transfer.selector), abi.encode(true));
Expand All @@ -57,10 +61,6 @@ abstract contract BasePoolTest is Test, BConst, Utils {
bPool.set__records(_token, _record);
}

function _setBalance(address _user, uint256 _balance) internal {
_writeUintAtAddressMapping(address(bPool), 0, _user, _balance);
}

function _setPublicSwap(bool _isPublicSwap) internal {
bPool.set__publicSwap(_isPublicSwap);
}
Expand All @@ -69,6 +69,10 @@ abstract contract BasePoolTest is Test, BConst, Utils {
bPool.set__finalized(_isFinalized);
}

function _setBalance(address _user, uint256 _balance, bool _adjustTotalSupply) internal {
deal(address(bPool), _user, _balance, _adjustTotalSupply);
}

function _setTotalSupply(uint256 _totalSupply) internal {
// NOTE: not in smock as it uses ERC20.totalSupply()
_writeUintToStorage(address(bPool), 2, _totalSupply);
Expand Down Expand Up @@ -439,8 +443,7 @@ contract BPool_Unit_ExitPool is BasePoolTest {
}

// Set LP token balance
_setBalance(address(bPool), _fuzz.initPoolSupply); // bPool
_setBalance(address(this), _fuzz.initPoolSupply); // fn caller
_setBalance(address(this), _fuzz.initPoolSupply, true); // give LP tokens to fn caller, update totalSupply
// Set public swap
_setPublicSwap(true);
// Set finalize
Expand Down Expand Up @@ -472,7 +475,7 @@ contract BPool_Unit_ExitPool is BasePoolTest {
}

function test_HappyPath(ExitPool_FuzzScenario memory _fuzz) public happyPath(_fuzz) {
uint256[] memory minAmountsOut = new uint256[](tokens.length); // Using min possible amounts
uint256[] memory minAmountsOut = _zeroAmountsArray(); // Using min possible amounts

bPool.exitPool(_fuzz.poolAmountIn, minAmountsOut);
}
Expand Down

0 comments on commit 6a092ad

Please sign in to comment.