Regenerate test fixtures and unskip hardhat tests (#2035)

pull/2051/head
Yorke Rhodes 2 years ago committed by GitHub
parent 117aa93b61
commit 6f7495320b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      rust/chains/hyperlane-ethereum/tests/signer_output.rs
  2. 12
      solidity/test/isms/legacyMultisigIsm.test.ts
  3. 61
      solidity/test/message.test.ts
  4. 29
      vectors/domainHash.json
  5. 23
      vectors/message.json
  6. 67
      vectors/signedCheckpoint.json

@ -20,6 +20,7 @@ use hyperlane_core::{
use hyperlane_ethereum::Signers;
/// Output proof to /vector/message.json
#[test]
pub fn output_message() {
let hyperlane_message = HyperlaneMessage {
nonce: 0,
@ -57,6 +58,7 @@ pub fn output_message() {
}
/// Output merkle proof test vectors
#[test]
pub fn output_merkle_proof() {
let mut tree = MerkleTree::create(&[], TREE_DEPTH);
@ -94,6 +96,7 @@ pub fn output_merkle_proof() {
}
/// Outputs domain hash test cases in /vector/domainHash.json
#[test]
pub fn output_domain_hashes() {
let mailbox = H256::from(H160::from_str("0x2222222222222222222222222222222222222222").unwrap());
let test_cases: Vec<Value> = (1..=3)
@ -120,6 +123,7 @@ pub fn output_domain_hashes() {
}
/// Outputs signed checkpoint test cases in /vector/signedCheckpoint.json
#[test]
pub fn output_signed_checkpoints() {
let mailbox = H256::from(H160::from_str("0x2222222222222222222222222222222222222222").unwrap());
let t = async {

@ -5,6 +5,7 @@ import { ethers } from 'hardhat';
import { Validator, types, utils } from '@hyperlane-xyz/utils';
import domainHashTestCases from '../../../vectors/domainHash.json';
import {
LightTestRecipient__factory,
TestLegacyMultisigIsm,
@ -23,9 +24,6 @@ import {
const ORIGIN_DOMAIN = 1234;
const DESTINATION_DOMAIN = 4321;
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const domainHashTestCases = require('../../../vectors/domainHash.json');
describe('LegacyMultisigIsm', async () => {
let multisigIsm: TestLegacyMultisigIsm,
mailbox: TestMailbox,
@ -470,9 +468,7 @@ describe('LegacyMultisigIsm', async () => {
});
});
// TODO: Update rust code to output v2 domain hashes
// TODO: Update rust code to output checkpoint digests
describe.skip('#_getDomainHash', () => {
describe('#_getDomainHash', () => {
it('matches Rust-produced domain hashes', async () => {
// Compare Rust output in json file to solidity output (json file matches
// hash for local domain of 1000)
@ -481,8 +477,8 @@ describe('LegacyMultisigIsm', async () => {
// This public function on TestLegacyMultisigIsm exposes
// the internal _domainHash on MultisigIsm.
const domainHash = await multisigIsm.getDomainHash(
testCase.originDomain,
testCase.originMailbox,
testCase.domain,
testCase.mailbox,
);
expect(domainHash).to.equal(expectedDomainHash);
}

@ -3,10 +3,9 @@ import { ethers } from 'hardhat';
import { utils } from '@hyperlane-xyz/utils';
import testCases from '../../vectors/message.json';
import { TestMessage, TestMessage__factory } from '../types';
const testCases = require('../../vectors/message.json');
const remoteDomain = 1000;
const localDomain = 2000;
const version = 0;
@ -52,44 +51,30 @@ describe('Message', async () => {
expect(await messageLib.body(message)).to.equal(body);
});
// TODO: Update rust output to new message format
it.skip('Matches Rust-output HyperlaneMessage and leaf', async () => {
const origin = 1000;
const sender = '0x1111111111111111111111111111111111111111';
const destination = 2000;
const recipient = '0x2222222222222222222222222222222222222222';
const body = '0x1234';
it('Matches Rust-output HyperlaneMessage and leaf', async () => {
for (const test of testCases) {
const { origin, sender, destination, recipient, body, nonce, id } = test;
const hyperlaneMessage = utils.formatMessage(
version,
nonce,
origin,
sender,
destination,
recipient,
body,
);
const hexBody = ethers.utils.hexlify(body);
const {
origin: testOrigin,
sender: testSender,
destination: testDestination,
recipient: testRecipient,
body: testBody,
messageHash,
} = testCases[0];
const hyperlaneMessage = utils.formatMessage(
version,
nonce,
origin,
sender,
destination,
recipient,
hexBody,
);
expect(await messageLib.origin(hyperlaneMessage)).to.equal(testOrigin);
expect(await messageLib.sender(hyperlaneMessage)).to.equal(testSender);
expect(await messageLib.destination(hyperlaneMessage)).to.equal(
testDestination,
);
expect(await messageLib.recipient(hyperlaneMessage)).to.equal(
testRecipient,
);
expect(await messageLib.body(hyperlaneMessage)).to.equal(
ethers.utils.hexlify(testBody),
);
expect(utils.messageId(hyperlaneMessage)).to.equal(messageHash);
expect(await messageLib.origin(hyperlaneMessage)).to.equal(origin);
expect(await messageLib.sender(hyperlaneMessage)).to.equal(sender);
expect(await messageLib.destination(hyperlaneMessage)).to.equal(
destination,
);
expect(await messageLib.recipient(hyperlaneMessage)).to.equal(recipient);
expect(await messageLib.body(hyperlaneMessage)).to.equal(hexBody);
expect(utils.messageId(hyperlaneMessage)).to.equal(id);
}
});
});

@ -1,14 +1,17 @@
[
{
"expectedDomainHash": "0x92521b38de115ee8c0903d7273143fbd0398d573cd2b18b371d9de2998d92f04",
"outboxDomain": 1
},
{
"expectedDomainHash": "0xadb88304ca1d74837ba284971887128d4c80acf8c1b95a5702dec546127d393d",
"outboxDomain": 2
},
{
"expectedDomainHash": "0x6aac4b69a2ae80ae2017bb8354783e2c138a7f19418e81337caf4d17a88147b1",
"outboxDomain": 3
}
]
{
"domain": 1,
"expectedDomainHash": "0xbbca56eb98960a4637eb40486d9a069550dd70d9c185ed138516e8e33cf3d7e7",
"mailbox": "0x0000000000000000000000002222222222222222222222222222222222222222"
},
{
"domain": 2,
"expectedDomainHash": "0xa6a93d86d397028e41995d521ccbc270e6db2a2fc530dcb7f0135254f30c8424",
"mailbox": "0x0000000000000000000000002222222222222222222222222222222222222222"
},
{
"domain": 3,
"expectedDomainHash": "0xffb4fbe5142f55e07b5d44b3c7f565c5ef4b016551cbd7c23a92c91621aca06f",
"mailbox": "0x0000000000000000000000002222222222222222222222222222222222222222"
}
]

@ -1,10 +1,15 @@
[
{
"body": [18, 52],
"destination": 2000,
"messageHash": "0xab444826d49ee7fa7521d4a1587b4b25197edd8a43b42307160afb4bf4232157",
"origin": 1000,
"recipient": "0x0000000000000000000000002222222222222222222222222222222222222222",
"sender": "0x0000000000000000000000001111111111111111111111111111111111111111"
}
]
{
"body": [
18,
52
],
"destination": 2000,
"id": "0x545b9ae16e93875efda786a09f3b78221d7f568f46a445fe4cd4a1e38096c576",
"nonce": 0,
"origin": 1000,
"recipient": "0x0000000000000000000000002222222222222222222222222222222222222222",
"sender": "0x0000000000000000000000001111111111111111111111111111111111111111",
"version": 0
}
]

@ -1,35 +1,38 @@
[
{
"index": 1,
"outboxDomain": 1000,
"root": "0x0202020202020202020202020202020202020202020202020202020202020202",
"signature": {
"r": "0x2a1345082bc3cd5521c9f9b3bff58f3c7beb88397dbca84eb6938484200fa197",
"s": "0x27e0cddfdff562a73815c1af7643c0ec3222235b6eadcd5ac998f2425fe1f941",
"v": 28
{
"domain": 1000,
"index": 1,
"mailbox": "0x0000000000000000000000002222222222222222222222222222222222222222",
"root": "0x0202020202020202020202020202020202020202020202020202020202020202",
"signature": {
"r": "0xa5769d4ad3041f82a95c1c8b26fd3fcdac5a95560d336b46b83d585ba91a8f9",
"s": "0x4e1464c784e2836b8c22a2b2c76fdfbdff57f173b20641544ecc0d465af6ed05",
"v": 28
},
"signer": "0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a"
},
"signer": "0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a"
},
{
"index": 2,
"outboxDomain": 1000,
"root": "0x0303030303030303030303030303030303030303030303030303030303030303",
"signature": {
"r": "0xc34adf4c697681ba74de230d9d21ed6881f2f1b21de18cf036968e58a14ce786",
"s": "0x32cc4e8ca33dd4543d1ebf63bfc33cb2ed1ff8f2003351e7ec9e52d7edbfb109",
"v": 27
{
"domain": 1000,
"index": 2,
"mailbox": "0x0000000000000000000000002222222222222222222222222222222222222222",
"root": "0x0303030303030303030303030303030303030303030303030303030303030303",
"signature": {
"r": "0x555b204a20caa709685df249c0f4e5d96532483a94cad7afb2aff6c3b72eabff",
"s": "0x50e19964d11bbcc3ac9ec4b3aaaf365aa9254b1d824509c63aa2470c140f30ea",
"v": 27
},
"signer": "0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a"
},
"signer": "0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a"
},
{
"index": 3,
"outboxDomain": 1000,
"root": "0x0404040404040404040404040404040404040404040404040404040404040404",
"signature": {
"r": "0xeb0b43fe396f25e86402f2a6b93b3268607c0e091699cc83d2304a5616a74c35",
"s": "0x2b8ec167fa8d798abbc3821a8fa05f707f3931a3d1a0deba10c80a6ecb28da0f",
"v": 28
},
"signer": "0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a"
}
]
{
"domain": 1000,
"index": 3,
"mailbox": "0x0000000000000000000000002222222222222222222222222222222222222222",
"root": "0x0404040404040404040404040404040404040404040404040404040404040404",
"signature": {
"r": "0x7aaf6ca4c12c1ec82bc91eca5c04ac599ce9a169d2f59f6d38e6dfc37a696194",
"s": "0x4b42a96d83f3fd1b5e844f8b34f284bc33154cf3a8fbfc6fad93de1d3fe71230",
"v": 27
},
"signer": "0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a"
}
]
Loading…
Cancel
Save