Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: coverage nits #446

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/crosschain-data/extensions/CoreStateRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,10 @@ contract CoreStateRegistry is BaseStateRegistry, ICoreStateRegistry {
bool fulfilment;
bool errors;
for (uint256 i; i < numberOfVaults; ++i) {
/// @dev if updating the deposit payload fails because of slippage, multiVaultData.amounts[i] is set to 0
/// @dev this means that this amount was already added to the failedDeposits state variable and should not
/// be re-added (or processed here)
/// @dev it is not possible in theory to have multiVaultData.amounts to be 0 at this point
/// @dev this is due to the fact that 0 values are moved in updateDeposit which must always run prior to
/// processing the payload
/// @dev this check is added here only for sanity purposes and full coverage of the line is not possible
if (multiVaultData.amounts[i] != 0) {
underlying = IERC20(_getVaultAsset(superforms[i]));

Expand Down
6 changes: 6 additions & 0 deletions test/unit/crosschain-data/extensions/CoreStateRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ contract CoreStateRegistryTest is ProtocolActions {
vm.prank(deployer);
vm.expectRevert(Error.BRIDGE_TOKENS_PENDING.selector);
CoreStateRegistry(payable(getContract(AVAX, "CoreStateRegistry"))).processPayload{ value: nativeValue }(1);

vm.prank(deployer);
MockERC20(getContract(AVAX, "DAI")).transfer(getContract(AVAX, "CoreStateRegistry"), 838);

vm.prank(deployer);
CoreStateRegistry(payable(getContract(AVAX, "CoreStateRegistry"))).processPayload{ value: nativeValue }(1);
}

/// @dev this test ensures that if a superform update failed because of slippage in 2 of 4 vaults
Expand Down
83 changes: 83 additions & 0 deletions test/unit/payments/PaymentHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,89 @@ contract PaymentHelperTest is ProtocolActions {
assertGt(fees, 0);
}

function test_estimateSingleXChainMultiVault_retain4626() public {
uint8[] memory ambIds = new uint8[](1);

ambIds[0] = 1;
ambIds[0] = 2;

bytes memory emptyBytes;
uint256[] memory superFormIds = new uint256[](1);
superFormIds[0] = _generateTimelockSuperformPackWithShift();

uint256[] memory uint256MemoryArray = new uint256[](1);
uint256MemoryArray[0] = 420;

LiqRequest[] memory liqRequestMemoryArray = new LiqRequest[](1);
liqRequestMemoryArray[0] = LiqRequest(emptyBytes, address(0), address(0), 1, ETH, 420);
bool[] memory retain4626 = new bool[](1);

retain4626[0] = true;

(,,, uint256 fees) = paymentHelper.estimateSingleXChainMultiVault(
SingleXChainMultiVaultStateReq(
ambIds,
ARBI,
MultiVaultSFData(
superFormIds,
/// timelock
uint256MemoryArray,
uint256MemoryArray,
uint256MemoryArray,
liqRequestMemoryArray,
emptyBytes,
new bool[](1),
retain4626,
receiverAddress,
receiverAddress,
emptyBytes
)
),
false
);
assertGt(fees, 0);
}

function test_estimateSingleXChainMultiVault_sameDst_deposit() public {
uint8[] memory ambIds = new uint8[](1);

ambIds[0] = 1;
ambIds[0] = 2;

bytes memory emptyBytes;
uint256[] memory superFormIds = new uint256[](1);
superFormIds[0] = _generateTimelockSuperformPackWithShift();

uint256[] memory uint256MemoryArray = new uint256[](1);
uint256MemoryArray[0] = 420;

LiqRequest[] memory liqRequestMemoryArray = new LiqRequest[](1);
liqRequestMemoryArray[0] = LiqRequest(emptyBytes, address(0), address(0), 1, ETH, 420);

(,,, uint256 fees) = paymentHelper.estimateSingleXChainMultiVault(
SingleXChainMultiVaultStateReq(
ambIds,
ETH,
MultiVaultSFData(
superFormIds,
/// timelock
uint256MemoryArray,
uint256MemoryArray,
uint256MemoryArray,
liqRequestMemoryArray,
emptyBytes,
new bool[](1),
new bool[](1),
receiverAddress,
receiverAddress,
emptyBytes
)
),
true
);
assertGt(fees, 0);
}

function test_estimateMultiDstSingleVault_formImplPaused() public {
vm.prank(deployer);
SuperformFactory(getContract(ETH, "SuperformFactory")).changeFormImplementationPauseStatus(
Expand Down