Skip to content

Commit

Permalink
Make error verification more precise
Browse files Browse the repository at this point in the history
  • Loading branch information
ermyas committed Feb 1, 2024
1 parent 6e18d51 commit 4bfdc8d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/fork/root/RootERC20BridgeFlowRate.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,17 @@ contract RootERC20BridgeFlowRateForkTest is Test, Utils {

address withdrawer = createAddress(1);
_sendWithdrawalMessage(bridge, token, withdrawer, amount);
_verifyWithdrawalWasQueued(bridge, token, withdrawer, amount);
RootERC20BridgeFlowRate.PendingWithdrawal memory pending =
_verifyWithdrawalWasQueued(bridge, token, withdrawer, amount);

// check that early withdrawal attempt fails
vm.expectRevert();
vm.expectRevert(
abi.encodeWithSelector(
IFlowRateWithdrawalQueueErrors.WithdrawalRequestTooEarly.selector,
block.timestamp,
pending.timestamp + bridge.withdrawalDelay()
)
);
bridge.finaliseQueuedWithdrawal(withdrawer, 0);

// check that timely withdrawal succeeds
Expand Down Expand Up @@ -246,14 +253,15 @@ contract RootERC20BridgeFlowRateForkTest is Test, Utils {
address token,
address withdrawer,
uint256 txValue
) private {
) private returns (RootERC20BridgeFlowRate.PendingWithdrawal memory) {
uint256[] memory indices = new uint256[](1);
indices[0] = 0;
assertEq(bridge.getPendingWithdrawalsLength(withdrawer), 1, "Expected 1 pending withdrawal");
RootERC20BridgeFlowRate.PendingWithdrawal[] memory pending = bridge.getPendingWithdrawals(withdrawer, indices);
assertEq(pending[0].withdrawer, withdrawer, "Unexpected withdrawer");
assertEq(pending[0].token, token, "Unexpected token");
assertEq(pending[0].amount, txValue, "Unexpected amount");
return pending[0];
}

function _verifyBalance(address token, address withdrawer, uint256 expectedAmount) private {
Expand Down

0 comments on commit 4bfdc8d

Please sign in to comment.