The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
hyperlane-monorepo/solidity/test/isms/TrustedRelayerIsm.t.sol

51 lines
1.4 KiB

// SPDX-License-Identifier: MIT or Apache-2.0
pragma solidity ^0.8.13;
import {Test} from "forge-std/Test.sol";
import {TestMailbox} from "../../contracts/test/TestMailbox.sol";
import {TestRecipient} from "../../contracts/test/TestRecipient.sol";
import {TypeCasts} from "../../contracts/libs/TypeCasts.sol";
import {TrustedRelayerIsm} from "../../contracts/isms/TrustedRelayerIsm.sol";
contract TrustedRelayerIsmTest is Test {
using TypeCasts for address;
uint32 localDomain = 12345;
uint32 remoteDomain = 54321;
TestMailbox mailbox;
TrustedRelayerIsm ism;
TestRecipient recipient;
address relayer;
function setUp() public {
relayer = msg.sender;
recipient = new TestRecipient();
mailbox = new TestMailbox(12345);
ism = new TrustedRelayerIsm(address(mailbox), relayer);
recipient.setInterchainSecurityModule(address(ism));
}
function test_verify(
uint32 origin,
bytes32 sender,
bytes calldata body
) public {
bytes memory message = mailbox.buildInboundMessage(
origin,
address(recipient).addressToBytes32(),
sender,
body
);
vm.expectRevert("Mailbox: ISM verification failed");
mailbox.process("", message);
assertFalse(ism.verify("", message));
vm.prank(relayer);
mailbox.process("", message);
assertTrue(ism.verify("", message));
}
}