Skip to content

Commit

Permalink
Add zero parameter value checks for MMR constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ermyas committed Oct 4, 2023
1 parent 16e7dcb commit 80048f9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/MultiBridgeMessageReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,16 @@ contract MultiBridgeMessageReceiver is IMultiBridgeMessageReceiver, ExecutorAwar

/// @notice sets the initial parameters
constructor(uint256 _srcChainId, address _gac) {
srcChainId = _srcChainId;
if (_gac == address(0)) {
revert Error.ZERO_ADDRESS_INPUT();
}

if (_srcChainId == 0) {
revert Error.INVALID_SENDER_CHAIN_ID();
}

gac = IGAC(_gac);
srcChainId = _srcChainId;
}

/*/////////////////////////////////////////////////////////////////
Expand Down
12 changes: 12 additions & 0 deletions test/unit-tests/MultiBridgeMessageReceiver.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ contract MultiBridgeMessageReceiverTest is Setup {
timelockAddr = contractAddress[DST_CHAIN_ID]["TIMELOCK"];
}

/// @dev cannot be called with zero source chain id
function test_constructor_zero_chain_id_input() public {
vm.expectRevert(Error.INVALID_SENDER_CHAIN_ID.selector);
new MultiBridgeMessageReceiver(0, address(42));
}

/// @dev cannot be called with zero address GAC
function test_constructor_zero_gac_address_input() public {
vm.expectRevert(Error.ZERO_ADDRESS_INPUT.selector);
new MultiBridgeMessageReceiver(1, address(0));
}

/// @dev receives message from one adapter
function test_receive_message() public {
vm.startPrank(wormholeAdapterAddr);
Expand Down

0 comments on commit 80048f9

Please sign in to comment.