Skip to content

Commit

Permalink
add opStateBridge tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbuild3r committed Sep 6, 2023
1 parent 13c401e commit 03a4871
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions src/test/OpStateBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ contract OpStateBridgeTest is PRBTest, StdCheats {

/// @notice Emmitted when the the StateBridge sets the gas limit for sendRootOp
/// @param _opGasLimit The new opGasLimit for sendRootOp
event SetGasLimitSendRoot(uint32 _opGasLimit);
event SetGasLimitPropagateRoot(uint32 _opGasLimit);

/// @notice Emmitted when the the StateBridge sets the gas limit for SetRootHistoryExpiryt
/// @param _opGasLimit The new opGasLimit for SetRootHistoryExpirytimism
Expand Down Expand Up @@ -186,15 +186,15 @@ contract OpStateBridgeTest is PRBTest, StdCheats {

/// @notice tests whether the StateBridge contract can set the opGasLimit for sendRootOptimism
/// @param _opGasLimit The new opGasLimit for sendRootOptimism
function test_owner_setGasLimitSendRoot_succeeds(uint32 _opGasLimit) public {
function test_owner_setGasLimitPropagateRoot_succeeds(uint32 _opGasLimit) public {
vm.assume(_opGasLimit != 0);

vm.expectEmit(true, true, true, true);

emit SetGasLimitSendRoot(_opGasLimit);
emit SetGasLimitPropagateRoot(_opGasLimit);

vm.prank(owner);
opStateBridge.setGasLimitSendRoot(_opGasLimit);
opStateBridge.setGasLimitPropagateRoot(_opGasLimit);
}

/// @notice tests whether the StateBridge contract can set the opGasLimit for SetRootHistoryExpirytimism
Expand Down Expand Up @@ -229,6 +229,7 @@ contract OpStateBridgeTest is PRBTest, StdCheats {

/// @notice tests that the StateBridge contract's ownership can't be changed by a non-owner
/// @param newOwner The new owner of the StateBridge contract (foundry fuzz)
/// @param nonOwner An address that is not the owner of the StateBridge contract
function test_notOwner_transferOwnership_reverts(address nonOwner, address newOwner) public {
vm.assume(nonOwner != owner && nonOwner != address(0) && newOwner != address(0));

Expand All @@ -238,6 +239,14 @@ contract OpStateBridgeTest is PRBTest, StdCheats {
opStateBridge.transferOwnership(newOwner);
}

/// @notice tests that the StateBridge contract's ownership can't be set to be the zero address
function test_owner_transferOwnershipOp_toZeroAddress_reverts() public {
vm.expectRevert("New owner can't be the zero address");

vm.prank(owner);
opStateBridge.transferOwnershipOp(address(0), true);
}

/// @notice tests that the StateBridge contract's ownership can't be changed by a non-owner
/// @param newOwner The new owner of the StateBridge contract (foundry fuzz)
function test_notOwner_transferOwnershipOp_reverts(
Expand Down Expand Up @@ -292,4 +301,22 @@ contract OpStateBridgeTest is PRBTest, StdCheats {
vm.prank(owner);
opStateBridge.renounceOwnership();
}

/// @notice Tests that the StateBridge contract can't set the opGasLimit for sendRootOptimism to 0
function test_setGasLimitToZero_reverts() public {
vm.expectRevert("Gas limit must be greater than 0");

vm.prank(owner);
opStateBridge.setGasLimitPropagateRoot(0);

vm.expectRevert("Gas limit must be greater than 0");

vm.prank(owner);
opStateBridge.setGasLimitSetRootHistoryExpiry(0);

vm.expectRevert("Gas limit must be greater than 0");

vm.prank(owner);
opStateBridge.setGasLimitTransferOwnershipOp(0);
}
}

0 comments on commit 03a4871

Please sign in to comment.