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/optics-core/test/Message.test.js

46 lines
1.3 KiB

const { waffle, ethers } = require('hardhat');
const { provider } = waffle;
const { expect } = require('chai');
const remoteDomain = 1000;
const localDomain = 2000;
describe('Message', async () => {
let messageLib;
before(async () => {
const MessageFactory = await ethers.getContractFactory('TestMessage');
messageLib = await MessageFactory.deploy();
await messageLib.deployed();
});
it('Returns fields from a message', async () => {
const [sender, recipient] = provider.getWallets();
const sequence = 1;
const body = ethers.utils.formatBytes32String('message');
const message = optics.formatMessage(
remoteDomain,
sender.address,
sequence,
localDomain,
recipient.address,
body,
);
expect(await messageLib.origin(message)).to.equal(remoteDomain);
expect(await messageLib.sender(message)).to.equal(
optics.ethersAddressToBytes32(sender.address),
);
expect(await messageLib.sequence(message)).to.equal(sequence);
expect(await messageLib.destination(message)).to.equal(localDomain);
expect(await messageLib.recipient(message)).to.equal(
optics.ethersAddressToBytes32(recipient.address),
);
expect(await messageLib.recipientAddress(message)).to.equal(
recipient.address,
);
expect(await messageLib.body(message)).to.equal(body);
});
});