Skip to content

Commit

Permalink
chore: add unit test multimessage receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
sujithsomraaj committed Oct 12, 2023
1 parent 16698c6 commit f5fd8ad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ bin/
build/
cache/
out/
coverage/

*.pid
*.log
Expand Down
22 changes: 22 additions & 0 deletions test/unit-tests/MultiBridgeMessageReceiver.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,28 @@ contract MultiBridgeMessageReceiverTest is Setup {
assertTrue(receiver.isExecutionScheduled(msgId));
}

/// @dev cannot execute mismatched message params and hash
function test_schedule_message_hash_mismatch() public {
vm.startPrank(wormholeAdapterAddr);

MessageLibrary.Message memory message = MessageLibrary.Message({
srcChainId: SRC_CHAIN_ID,
dstChainId: DST_CHAIN_ID,
target: address(42),
nonce: 42,
callData: bytes("42"),
nativeValue: 0,
expiration: 0
});
bytes32 msgId = message.computeMsgId();

receiver.receiveMessage(message);

message.nonce = 43;
vm.expectRevert(Error.EXEC_PARAMS_HASH_MISMATCH.selector);
receiver.scheduleMessageExecution(msgId, message.extractExecutionParams());
}

/// @dev cannot schedule execution of message past deadline
function test_schedule_message_execution_passed_deadline() public {
vm.startPrank(wormholeAdapterAddr);
Expand Down

0 comments on commit f5fd8ad

Please sign in to comment.