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

41 lines
1.1 KiB

import { expect } from 'chai';
import { ethers } from 'hardhat';
import { utils } from '@abacus-network/utils';
import { TestSendReceiver__factory } from '../types';
describe('TestSendReceiver', () => {
it('randomly handles a message', async () => {
const [signer] = await ethers.getSigners();
const signerAddress = await signer.getAddress();
const recipientFactory = new TestSendReceiver__factory(signer);
const recipient = await recipientFactory.deploy();
// Didn't know how else to test the randomness
let successes = 0;
let failures = 0;
for (let i = 0; i < 100; i++) {
try {
// "Inject randomness"
await signer.sendTransaction({
from: signerAddress,
to: signerAddress,
value: 1,
});
await recipient.handle(
0,
utils.addressToBytes32(recipient.address),
'0x1234',
);
successes += 1;
} catch (error) {
failures += 1;
}
}
expect(successes).to.be.greaterThan(5);
expect(failures).to.be.greaterThan(5);
});
});