Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
♻️ Revert removed test
Browse files Browse the repository at this point in the history
  • Loading branch information
shuse2 committed Nov 1, 2023
1 parent 64f162a commit dcb7d10
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,43 @@ describe('initGenesisState', () => {
expect(interopMod['_verifyTerminatedStateAccountsIDs']).toHaveBeenCalledTimes(1);
});

it('_verifyChainID the same number of times as size of terminatedStateAccounts + size of chainInfo', async () => {
jest.spyOn(interopMod, '_verifyChainID' as any);

const context = createInitGenesisStateContext(
{
...genesisInteroperability,
chainInfos: [
{
...chainInfo,
chainData: {
...chainData,
status: ChainStatus.TERMINATED,
lastCertificate: {
...lastCertificate,
validatorsHash: computeValidatorsHash(activeValidators, certificateThreshold),
},
},
chainValidators: {
activeValidators,
certificateThreshold,
},
},
],
terminatedStateAccounts: [
{
chainID: chainInfo.chainID,
terminatedStateAccount,
},
],
},
params,
);

await expect(interopMod.initGenesisState(context)).resolves.toBeUndefined();
expect(interopMod['_verifyChainID']).toHaveBeenCalledTimes(2);
});

it('should throw error if chainInfo.chainID exists in terminatedStateAccounts & chainInfo.chainData.status is ACTIVE', async () => {
const context = createInitGenesisStateContext(
{
Expand Down Expand Up @@ -732,43 +769,6 @@ describe('initGenesisState', () => {
'For each terminatedStateAccount there should be a corresponding chainInfo at TERMINATED state',
);
});

it('should call _verifyTerminatedStateAccounts', async () => {
jest.spyOn(interopMod, '_verifyTerminatedStateAccounts' as any);

const context = createInitGenesisStateContext(
{
...genesisInteroperability,
chainInfos: [
{
...chainInfo,
chainData: {
...chainData,
status: ChainStatus.TERMINATED,
lastCertificate: {
...lastCertificate,
validatorsHash: computeValidatorsHash(activeValidators, certificateThreshold),
},
},
chainValidators: {
activeValidators,
certificateThreshold,
},
},
],
terminatedStateAccounts: [
{
chainID: chainInfo.chainID,
terminatedStateAccount,
},
],
},
params,
);

await expect(interopMod.initGenesisState(context)).resolves.toBeUndefined();
expect(interopMod['_verifyTerminatedStateAccounts']).toHaveBeenCalledTimes(1);
});
});

it(`should call _verifyTerminatedOutboxAccounts from initGenesisState `, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,28 @@ describe('initGenesisState', () => {
expect(interopMod['_verifyTerminatedStateAccounts']).toHaveBeenCalledTimes(1);
});

it('_verifyChainID the same number of times as size of terminatedStateAccounts', async () => {
jest.spyOn(interopMod, '_verifyChainID' as any);

// const chainIDDefault = getMainchainID(chainID);
const context = createInitGenesisStateContext(
{
...defaultData,
chainInfos: chainInfosDefault,
terminatedStateAccounts: [
{
chainID: Buffer.from([1, 1, 2, 3]),
terminatedStateAccount,
},
],
},
params,
);

await interopMod.initGenesisState(context);
expect(interopMod['_verifyChainID']).toHaveBeenCalledTimes(1);
});

it(`should throw error if stateAccount.chainID is equal to OWN_CHAIN_ID`, async () => {
const context = createInitGenesisStateContext(
{
Expand Down

0 comments on commit dcb7d10

Please sign in to comment.