Skip to content

Commit

Permalink
fix: remove redundant masks from adapter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Van0k committed Jun 28, 2024
1 parent 7b83eb0 commit ba21a14
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ contract CurveV1Adapter2AssetsUnitTest is AdapterUnitTestHelper {
address token1;
address lpToken;

uint256 token0Mask;
uint256 token1Mask;
uint256 lpTokenMask;

function setUp() public {
_setUp();

(token0, token0Mask) = (tokens[0], 1);
(token1, token1Mask) = (tokens[1], 2);
(lpToken, lpTokenMask) = (tokens[2], 4);
token0 = tokens[0];
token1 = tokens[1];
lpToken = tokens[2];

address[] memory coins = new address[](2);
coins[0] = token0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@ contract CurveV1Adapter3AssetsUnitTest is AdapterUnitTestHelper {
address token2;
address lpToken;

uint256 token0Mask;
uint256 token1Mask;
uint256 token2Mask;
uint256 lpTokenMask;

function setUp() public {
_setUp();

(token0, token0Mask) = (tokens[0], 1);
(token1, token1Mask) = (tokens[1], 2);
(token2, token2Mask) = (tokens[2], 4);
(lpToken, lpTokenMask) = (tokens[3], 8);
token0 = tokens[0];
token1 = tokens[1];
token2 = tokens[2];
lpToken = tokens[3];

address[] memory coins = new address[](3);
coins[0] = token0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,14 @@ contract CurveV1Adapter4AssetsUnitTest is AdapterUnitTestHelper {
address token3;
address lpToken;

uint256 token0Mask;
uint256 token1Mask;
uint256 token2Mask;
uint256 token3Mask;
uint256 lpTokenMask;

function setUp() public {
_setUp();

(token0, token0Mask) = (tokens[0], 1);
(token1, token1Mask) = (tokens[1], 2);
(token2, token2Mask) = (tokens[2], 4);
(token3, token3Mask) = (tokens[3], 8);
(lpToken, lpTokenMask) = (tokens[4], 16);
token0 = tokens[0];
token1 = tokens[1];
token2 = tokens[2];
token3 = tokens[3];
lpToken = tokens[4];

address[] memory coins = new address[](4);
coins[0] = token0;
Expand Down
16 changes: 5 additions & 11 deletions contracts/test/unit/adapters/curve/CurveV1AdapterBase.unit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ contract CurveV1AdapterBaseUnitTest is AdapterUnitTestHelper {
address underlying1;
address lpToken;

uint256 token0Mask;
uint256 token1Mask;
uint256 underlying0Mask;
uint256 underlying1Mask;
uint256 lpTokenMask;

// ----- //
// SETUP //
// ----- //
Expand All @@ -57,11 +51,11 @@ contract CurveV1AdapterBaseUnitTest is AdapterUnitTestHelper {
function setUp() public {
_setUp();

(token0, token0Mask) = (tokens[0], 1);
(token1, token1Mask) = (tokens[1], 2);
(underlying0, underlying0Mask) = (tokens[2], 4);
(underlying1, underlying1Mask) = (tokens[3], 8);
(lpToken, lpTokenMask) = (tokens[4], 16);
token0 = tokens[0];
token1 = tokens[1];
underlying0 = tokens[2];
underlying1 = tokens[3];
lpToken = tokens[4];
}

function _setupPoolAndAdapter(PoolType poolType) internal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@ contract CurveV1AdapterStablNGUnitTest is AdapterUnitTestHelper {
address token2;
address lpToken;

uint256 token0Mask;
uint256 token1Mask;
uint256 token2Mask;
uint256 lpTokenMask;

function setUp() public {
_setUp();

(token0, token0Mask) = (tokens[0], 1);
(token1, token1Mask) = (tokens[1], 2);
(token2, token2Mask) = (tokens[2], 4);
(lpToken, lpTokenMask) = (tokens[3], 8);
token0 = tokens[0];
token1 = tokens[1];
token2 = tokens[2];
lpToken = tokens[3];

address[] memory coins = new address[](3);
coins[0] = token0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ contract ERC4626AdapterUnitTest is AdapterUnitTestHelper {
address asset;
address vault;

uint256 assetMask;
uint256 sharesMask;

function setUp() public {
_setUp();

(asset, assetMask) = (tokens[0], 1);
(vault, sharesMask) = (tokens[1], 2);
asset = tokens[0];
vault = tokens[1];

vm.mockCall(vault, abi.encodeCall(IERC4626.asset, ()), abi.encode(asset));

adapter = new ERC4626Adapter(address(creditManager), vault);
Expand Down
7 changes: 2 additions & 5 deletions contracts/test/unit/adapters/lido/LidoV1Adapter.unit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ contract LidoV1AdapterUnitTest is AdapterUnitTestHelper {
address weth;
address stETH;

uint256 wethMask;
uint256 stETHMask;

function setUp() public {
_setUp();

Expand All @@ -31,8 +28,8 @@ contract LidoV1AdapterUnitTest is AdapterUnitTestHelper {
vm.mockCall(address(creditManager), abi.encodeWithSignature("pool()"), abi.encode(pool));
vm.mockCall(pool, abi.encodeWithSignature("treasury()"), abi.encode(treasury));

(weth, wethMask) = (tokens[0], 1);
(stETH, stETHMask) = (tokens[1], 2);
weth = tokens[0];
stETH = tokens[1];

vm.mockCall(gateway, abi.encodeWithSignature("weth()"), abi.encode(weth));
vm.mockCall(gateway, abi.encodeWithSignature("stETH()"), abi.encode(stETH));
Expand Down
8 changes: 3 additions & 5 deletions contracts/test/unit/adapters/lido/WstETHV1Adapter.unit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ contract WstETHV1AdapterUnitTest is AdapterUnitTestHelper {
address stETH;
address wstETH;

uint256 stETHMask;
uint256 wstETHMask;

function setUp() public {
_setUp();

(stETH, stETHMask) = (tokens[0], 1);
(wstETH, wstETHMask) = (tokens[1], 2);
stETH = tokens[0];
wstETH = tokens[1];

vm.mockCall(wstETH, abi.encodeCall(IwstETHGetters.stETH, ()), abi.encode(stETH));

adapter = new WstETHV1Adapter(address(creditManager), wstETH);
Expand Down
8 changes: 3 additions & 5 deletions contracts/test/unit/adapters/yearn/YearnV2Adapter.unit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ contract YearnV2AdapterUnitTest is AdapterUnitTestHelper {
address token;
address yToken;

uint256 tokenMask;
uint256 yTokenMask;

function setUp() public {
_setUp();

(token, tokenMask) = (tokens[0], 1);
(yToken, yTokenMask) = (tokens[1], 2);
token = tokens[0];
yToken = tokens[1];

vm.mockCall(yToken, abi.encodeCall(IYVault.token, ()), abi.encode(token));

adapter = new YearnV2Adapter(address(creditManager), yToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ contract ZircuitPoolAdapterUnitTest is AdapterUnitTestHelper, IZircuitPoolAdapte
address depositToken;
address phantomToken;

uint256 token0Mask;
uint256 token1Mask;

function setUp() public {
_setUp();

depositToken = tokens[0];
phantomToken = tokens[1];

token0Mask = creditManager.getTokenMaskOrRevert(depositToken);
token1Mask = creditManager.getTokenMaskOrRevert(phantomToken);

zircuitMock = new GeneralMock();
adapter = new ZircuitPoolAdapterHarness(address(creditManager), address(zircuitMock));

Expand Down

0 comments on commit ba21a14

Please sign in to comment.