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

40 lines
1.2 KiB

import { utils } from '@abacus-network/utils';
import { expect } from 'chai';
import { ethers } from 'hardhat';
import { BadRandomRecipient__factory } from '../types';
describe('BadRecipient', () => {
describe('RandomBadRecipient', () => {
it('randomly handles a message', async () => {
const [signer] = await ethers.getSigners();
const signerAddress = await signer.getAddress();
const recipientFactory = new BadRandomRecipient__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);
});
});
});