@hyperlane-xyz/sdk
Version:
The official SDK for the Hyperlane Network
56 lines • 2.16 kB
JavaScript
import { expect } from 'chai';
import { existsSync, readFileSync, readdirSync } from 'fs';
import { IsmType, ModuleType } from '../types.js';
import { MultisigMetadataBuilder } from './multisig.js';
const path = '../../solidity/fixtures/multisig';
const files = existsSync(path) ? readdirSync(path) : [];
const fixtures = files
.map((f) => JSON.parse(readFileSync(`${path}/${f}`, 'utf8')))
.map((contents) => {
const type = contents.type;
const { dummy: _dummy, ...signatureValues } = contents.signatures;
const signatures = Object.values(signatureValues);
let decoded;
if (type === ModuleType.MERKLE_ROOT_MULTISIG) {
const { dummy: _dummy, ...branchValues } = contents.prefix.proof;
const branch = Object.values(branchValues);
decoded = {
type: IsmType.MERKLE_ROOT_MULTISIG,
proof: {
branch,
leaf: contents.prefix.id,
index: contents.prefix.signedIndex,
},
checkpoint: {
root: '',
index: contents.prefix.index,
merkle_tree_hook_address: contents.prefix.merkleTree,
},
signatures,
};
}
else {
decoded = {
type: IsmType.MESSAGE_ID_MULTISIG,
checkpoint: {
root: contents.prefix.root,
index: contents.prefix.signedIndex,
merkle_tree_hook_address: contents.prefix.merkleTree,
},
signatures,
};
}
return { decoded, encoded: contents.encoded };
});
// FIXME: migrate to mocha rules: eslint-disable-next-line jest/no-disabled-tests
describe.skip('MultisigMetadataBuilder', () => {
fixtures.forEach((fixture, i) => {
it(`should encode fixture ${i}`, () => {
expect(MultisigMetadataBuilder.encode(fixture.decoded)).to.equal(fixture.encoded);
});
it(`should decode fixture ${i}`, () => {
expect(MultisigMetadataBuilder.decode(fixture.encoded, fixture.decoded.type)).to.deep.equal(fixture.decoded);
});
});
});
//# sourceMappingURL=multisig.test.js.map