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 0146205 commit 8d80722
Showing 1 changed file with 42 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
import {
ChainInfo,
GenesisInteroperability,
TerminatedStateAccountWithChainID,
} from '../../../../../src/modules/interoperability/types';
import {
InMemoryPrefixedStateDB,
Expand All @@ -37,6 +38,7 @@ import {
} from '../../../../../src/testing';
import {
computeValidatorsHash,
getMainchainID,
validNameChars,
} from '../../../../../src/modules/interoperability/utils';

Expand Down Expand Up @@ -450,6 +452,46 @@ describe('initGenesisState', () => {
expect(interopMod['_verifyTerminatedStateAccountsIDs']).toHaveBeenCalledTimes(1);
});

it('should call _verifyChainID the same number of times as size of terminatedStateAccounts', () => {
const interopModPrototype = Object.getPrototypeOf(interopMod);
jest.spyOn(interopModPrototype, '_verifyChainID' as any);

const chainInfoLocal: ChainInfo = {
...chainInfo,
chainData: {
...chainData,
status: ChainStatus.TERMINATED,
lastCertificate: {
...lastCertificate,
validatorsHash: computeValidatorsHash(activeValidators, certificateThreshold),
},
},
chainValidators: {
activeValidators,
certificateThreshold,
},
};

const terminatedStateAccounts: TerminatedStateAccountWithChainID[] = [
{
chainID: chainInfoLocal.chainID,
terminatedStateAccount,
},
{
chainID: Buffer.from([0, 0, 0, 2]),
terminatedStateAccount,
},
];

interopModPrototype._verifyTerminatedStateAccountsCommon(
terminatedStateAccounts,
getMainchainID(params.chainID as Buffer),
);
expect(interopModPrototype['_verifyChainID']).toHaveBeenCalledTimes(
terminatedStateAccounts.length,
);
});

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 +774,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

0 comments on commit 8d80722

Please sign in to comment.