Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wcgcyx committed Feb 20, 2024
1 parent e72d47b commit 10b0ce2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion test/invariant/child/ChildERC20BridgeHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ contract ChildERC20BridgeHandler is Test {
rootHelper.deposit(user, rootToken, amount - currentBalance, gasAmt);
}

uint256 previousLen = rootHelper.getQueueSize(user);
childHelper.withdraw(user, childToken, amount, gasAmt);
rootHelper.finaliseWithdrawal(user);
rootHelper.finaliseWithdrawal(user, previousLen);
}
}
3 changes: 2 additions & 1 deletion test/invariant/root/RootERC20BridgeFlowRateHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ contract RootERC20BridgeFlowRateHandler is Test {

if (currentBalance < amount) {
// Withdraw difference
uint256 previousLen = rootHelper.getQueueSize(user);
childHelper.withdraw(user, childToken, amount - currentBalance, gasAmt);
rootHelper.finaliseWithdrawal(user);
rootHelper.finaliseWithdrawal(user, previousLen);
}

rootHelper.deposit(user, rootToken, amount, gasAmt);
Expand Down
16 changes: 13 additions & 3 deletions test/invariant/root/RootHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,26 @@ contract RootHelper is Test {
vm.selectFork(original);
}

function finaliseWithdrawal(address user) public {
function getQueueSize(address user) public returns (uint256 length) {
uint256 original = vm.activeFork();

vm.selectFork(rootId);

length = rootBridge.getPendingWithdrawalsLength(user);

vm.selectFork(original);
}

function finaliseWithdrawal(address user, uint256 previousLen) public {
uint256 original = vm.activeFork();

vm.selectFork(rootId);

// Check if this withdrawal has hit rate limit
if (rootBridge.getPendingWithdrawalsLength(user) > 0) {
if (rootBridge.getPendingWithdrawalsLength(user) > previousLen) {
skip(86401);
vm.prank(user);
rootBridge.finaliseQueuedWithdrawal(user, 0);
rootBridge.finaliseQueuedWithdrawal(user, previousLen);
}

if (rootBridge.withdrawalQueueActivated()) {
Expand Down

0 comments on commit 10b0ce2

Please sign in to comment.