From f5fd8ad7ec6917c82ecd10780f9d0b7ad7c03eb7 Mon Sep 17 00:00:00 2001 From: Sujith Date: Wed, 11 Oct 2023 20:24:50 -0400 Subject: [PATCH] chore: add unit test multimessage receiver --- .gitignore | 1 + .../MultiBridgeMessageReceiver.t.sol | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/.gitignore b/.gitignore index ff803e0..b9fc5cb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ bin/ build/ cache/ out/ +coverage/ *.pid *.log diff --git a/test/unit-tests/MultiBridgeMessageReceiver.t.sol b/test/unit-tests/MultiBridgeMessageReceiver.t.sol index 184c5b4..58145c1 100644 --- a/test/unit-tests/MultiBridgeMessageReceiver.t.sol +++ b/test/unit-tests/MultiBridgeMessageReceiver.t.sol @@ -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);