-
Notifications
You must be signed in to change notification settings - Fork 421
/
Copy pathmockMailbox.test.ts
36 lines (29 loc) · 1.22 KB
/
mockMailbox.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { expect } from 'chai';
import { ethers } from 'hardhat';
import { utils } 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(
DESTINATION_DOMAIN,
utils.addressToBytes32(recipient.address),
body,
);
await destinationMailbox.processNextInboundMessage();
const dataReceived = await recipient.lastData();
expect(dataReceived).to.eql(ethers.utils.hexlify(body));
});
});