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/mockMailbox.test.ts

36 lines
1.2 KiB

import { expect } from 'chai';
import { ethers } from 'hardhat';
import { addressToBytes32 } from '@hyperlane-xyz/utils';
import { MockMailbox__factory, TestRecipient__factory } from '../types';
const ORIGIN_DOMAIN = 1000;
const DESTINATION_DOMAIN = 2000;
describe('MockMailbox', function () {
it('should be able to mock sending and receiving a message', async function () {
const [signer] = await ethers.getSigners();
const mailboxFactory = new MockMailbox__factory(signer);
const testRecipientFactory = new TestRecipient__factory(signer);
const originMailbox = await mailboxFactory.deploy(ORIGIN_DOMAIN);
const destinationMailbox = await mailboxFactory.deploy(DESTINATION_DOMAIN);
await originMailbox.addRemoteMailbox(
DESTINATION_DOMAIN,
destinationMailbox.address,
);
const recipient = await testRecipientFactory.deploy();
const body = ethers.utils.toUtf8Bytes('This is a test message');
await originMailbox['dispatch(uint32,bytes32,bytes)'](
DESTINATION_DOMAIN,
addressToBytes32(recipient.address),
body,
);
await destinationMailbox.processNextInboundMessage();
const dataReceived = await recipient.lastData();
expect(dataReceived).to.eql(ethers.utils.hexlify(body));
});
});