@hyperlane-xyz/sdk
Version:
The official SDK for the Hyperlane Network
37 lines • 1.49 kB
JavaScript
import { expect } from 'chai';
import { ethers } from 'ethers';
import { existsSync, readFileSync, readdirSync } from 'fs';
import { IsmType } from '../types.js';
import { AggregationMetadataBuilder, } from './aggregation.js';
const path = '../../solidity/fixtures/aggregation';
const files = existsSync(path) ? readdirSync(path) : [];
const fixtures = files
.map((f) => JSON.parse(readFileSync(`${path}/${f}`, 'utf8')))
.map((contents) => {
const { encoded, ...values } = contents;
return {
encoded,
decoded: {
type: IsmType.AGGREGATION,
submoduleMetadata: Object.values(values).map((value) => value === null || value === 'null' ? null : String(value)),
},
};
});
describe('AggregationMetadataBuilder', () => {
fixtures.forEach((fixture, i) => {
it(`should encode fixture ${i}`, () => {
expect(AggregationMetadataBuilder.encode(fixture.decoded)).to.equal(fixture.encoded);
});
it(`should decode fixture ${i}`, () => {
const count = fixture.decoded.submoduleMetadata.length;
expect(AggregationMetadataBuilder.decode(fixture.encoded, {
ism: {
type: IsmType.AGGREGATION,
modules: new Array(count).fill(ethers.constants.AddressZero),
threshold: count,
},
})).to.deep.equal(fixture.decoded);
});
});
});
//# sourceMappingURL=aggregation.test.js.map