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

29 lines
1.1 KiB

import { expect } from 'chai';
import { ethers } from 'hardhat';
import { utils } from '@hyperlane-xyz/utils';
import { TestRecipient__factory } from '../dist';
import { MockInbox__factory, MockOutbox__factory } from '../types';
describe('Mock mailbox contracts', function () {
it('should be able to mock sending a message', async function () {
const [signer] = await ethers.getSigners();
const originDomain = 1;
const inboxFactory = new MockInbox__factory(signer);
const outboxFactory = new MockOutbox__factory(signer);
const testRecipientFactory = new TestRecipient__factory(signer);
const inbox = await inboxFactory.deploy();
const outbox = await outboxFactory.deploy(originDomain, inbox.address);
const recipient = await testRecipientFactory.deploy();
const data = ethers.utils.toUtf8Bytes('This is a test message');
await outbox.dispatch(0, utils.addressToBytes32(recipient.address), data);
await inbox.processNextPendingMessage();
const dataReceived = await recipient.lastData();
expect(dataReceived).to.eql(ethers.utils.hexlify(data));
});
});