From e4f2e1c558da45586b72bb2fc1544ff4ff6ab410 Mon Sep 17 00:00:00 2001 From: Ermyas Abebe Date: Wed, 20 Mar 2024 21:55:02 +1100 Subject: [PATCH] Fix failing fork test --- test/fork/root/RootERC20BridgeFlowRate.t.sol | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/fork/root/RootERC20BridgeFlowRate.t.sol b/test/fork/root/RootERC20BridgeFlowRate.t.sol index ca5b409e..6089d6f5 100644 --- a/test/fork/root/RootERC20BridgeFlowRate.t.sol +++ b/test/fork/root/RootERC20BridgeFlowRate.t.sol @@ -223,13 +223,16 @@ contract RootERC20BridgeFlowRateForkTest is Test, Utils { uint256 largeTransferThreshold = bridge.largeTransferThresholds(token); uint256 totalWithdrawals; uint256 amount; - while (depth > 0) { + // There could be scenarios where depth is already 0 but the withdrawal queue is not activated. + // For instance, when the global queue was activated in the past and then manually deactivated. + // Hence, a do-while loop is used to ensure that at least one withdrawal transaction is sent before checking the depth. + do { amount = depth > largeTransferThreshold ? largeTransferThreshold - 1 : depth + 1; _giveBridgeFunds(address(bridge), token, amount); _sendWithdrawalMessage(bridge, token, withdrawer, amount); (, depth,,) = bridge.flowRateBuckets(token); totalWithdrawals += amount; - } + } while (depth > 0); assertTrue(bridge.withdrawalQueueActivated()); _verifyWithdrawalWasQueued(bridge, token, withdrawer, amount);