Skip to content

Commit

Permalink
add polygon state bridge and polygon world id tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbuild3r committed Sep 6, 2023
1 parent 03a4871 commit 66c899a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/PolygonStateBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ contract PolygonStateBridgeTest is PRBTest, StdCheats {
/// @param rootHistoryExpiry The new root history expiry
event SetRootHistoryExpiry(uint256 rootHistoryExpiry);

// @notice Emmitted when the owner calls setFxChildTunnel for the first time
event SetFxChildTunnel(address fxChildTunnel);

/// @notice Emmitted when a root is sent to PolygonWorldID
/// @param root The latest WorldID Identity Manager root.
event RootPropagated(uint256 root);
Expand Down Expand Up @@ -139,6 +142,18 @@ contract PolygonStateBridgeTest is PRBTest, StdCheats {
polygonStateBridge.setRootHistoryExpiryPolygon(_rootHistoryExpiry);
}

/// @notice tests that the owner of the StateBridge contract can set the fxChildTunnel
/// @param newFxChildTunnel the new fxChildTunnel
function test_owner_setFxChildTunnel(address newFxChildTunnel) public {
vm.assume(newFxChildTunnel != address(0));

vm.expectEmit(true, true, true, true);
emit SetFxChildTunnel(newFxChildTunnel);

vm.prank(owner);
polygonStateBridge.setFxChildTunnel(newFxChildTunnel);
}

///////////////////////////////////////////////////////////////////
/// REVERTS ///
///////////////////////////////////////////////////////////////////
Expand Down
15 changes: 15 additions & 0 deletions src/test/PolygonWorldID.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ contract PolygonWorldIDTest is PRBTest, StdCheats {
/// @notice fxChild contract address
address public fxChild = address(0x2222222);

/// @notice Thrown when setFxRootTunnel is called for the first time
event SetFxRootTunnel(address fxRootTunnel);

function setUp() public {
/// @notice Initialize the PolygonWorldID contract
vm.prank(owner);
Expand Down Expand Up @@ -82,6 +85,18 @@ contract PolygonWorldIDTest is PRBTest, StdCheats {
id.setRootHistoryExpiry(expiryTime);
}

/// @notice checks that the owner of the PolygonWorldID contract can set the fxRootTunnel
/// @param newFxRootTunnel the new fxRootTunnel
function testOwnerCanSetFxRootTunnel(address newFxRootTunnel) public {
vm.assume(newFxRootTunnel != address(0));

vm.expectEmit(true, true, true, true);
emit SetFxRootTunnel(newFxRootTunnel);

vm.prank(owner);
id.setFxRootTunnel(newFxRootTunnel);
}

/// @notice Tests that a nonPendingOwner can't accept ownership of PolygonWorldID
/// @param newOwner the new owner of the contract
function test_notOwner_acceptOwnership_reverts(address newOwner, address randomAddress)
Expand Down

0 comments on commit 66c899a

Please sign in to comment.