Skip to content

Commit

Permalink
test: should not allow zero addresses in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Sep 19, 2024
1 parent bc149c5 commit 45ac4b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/messaging/MessageBusManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ contract MessageBusManager is IManager, Ownable {
address public immutable MESSAGE_BUS;

error MessageBusManager__NotFailed(bytes32 messageId);
error MessageBusManager__ZeroAddress();

constructor(address messageBus_, address owner_) {
MESSAGE_BUS = messageBus_;
Expand Down
15 changes: 15 additions & 0 deletions test/messaging/MessageBusManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ contract MessageBusManagerTest is Test {
arr[2] = c;
}

function test_constructor() public {
assertEq(manager.MESSAGE_BUS(), address(messageBus));
assertEq(manager.owner(), owner);
}

function test_constructor_revert_zeroMessageBus() public {
vm.expectRevert(MessageBusManager.MessageBusManager__ZeroAddress.selector);
new MessageBusManager({messageBus_: address(0), owner_: owner});
}

function test_constructor_revert_zeroOwner() public {
vm.expectRevert(MessageBusManager.MessageBusManager__ZeroAddress.selector);
new MessageBusManager({messageBus_: address(messageBus), owner_: address(0)});
}

function test_updateMessageStatus_success() public {
vm.prank(owner);
manager.updateMessageStatus(MESSAGE_ID, IManageable.TxStatus.Success);
Expand Down

0 comments on commit 45ac4b9

Please sign in to comment.