Skip to content

Commit

Permalink
chore: add test case for refund already approved
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaraRingas committed Nov 25, 2024
1 parent dc5a711 commit 66de57b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/unit/router-plus/SuperformRouterPlus.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2430,6 +2430,8 @@ contract SuperformRouterPlusTest is ProtocolActions {
uint64 REBALANCE_FROM = ETH;
uint64 REBALANCE_TO = OP;

console2.log("Initializing XChain Deposit...");

// Step 1: Initial XCHAIN Deposit
_xChainDeposit(superformId5ETH, REBALANCE_FROM, 1);

Expand All @@ -2440,12 +2442,16 @@ contract SuperformRouterPlusTest is ProtocolActions {

vm.startPrank(deployer);

console2.log("Starting Cross-Chain Rebalance...");

SuperPositions(SUPER_POSITIONS_SOURCE).increaseAllowance(
ROUTER_PLUS_SOURCE, superformId5ETH, args.sharesToRedeem
);
vm.recordLogs();
SuperformRouterPlus(ROUTER_PLUS_SOURCE).startCrossChainRebalance{ value: 2 ether }(args);

console2.log("Processing XChain Withdraw (rebalance from)...");

// Step 3: Process XChain Withdraw (rebalance from)
uint256 balanceOfInterimAssetBefore =
MockERC20(args.interimAsset).balanceOf(getContract(SOURCE_CHAIN, "SuperformRouterPlusAsync"));
Expand All @@ -2464,12 +2470,16 @@ contract SuperformRouterPlusTest is ProtocolActions {
// Step 4: Complete cross-chain rebalance
vm.startPrank(deployer);

console2.log("Completing Cross-Chain Rebalance...");

completeArgs =
_buildCompleteCrossChainRebalanceArgs(interimAmountOnRouterPlusAsync, superformId4OP, REBALANCE_TO);
completeArgs.amountReceivedInterimAsset = completeArgs.amountReceivedInterimAsset / 3;
SuperformRouterPlusAsync(ROUTER_PLUS_ASYNC_SOURCE).completeCrossChainRebalance{ value: 1 ether }(completeArgs);
vm.stopPrank();

console2.log("Requesting Refund...");

// Step 5: Request refund

/// @dev testing invalid requester (not receiver)
Expand Down Expand Up @@ -2526,7 +2536,7 @@ contract SuperformRouterPlusTest is ProtocolActions {

/// @dev testing refund already approved
vm.startPrank(deployer);
vm.expectRevert(ISuperformRouterPlusAsync.REFUND_ALREADY_APPROVED.selector);
vm.expectRevert();
SuperformRouterPlusAsync(ROUTER_PLUS_ASYNC_SOURCE).approveRefund(1);
vm.stopPrank();
}
Expand Down

0 comments on commit 66de57b

Please sign in to comment.