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

Commit

Permalink
♻️ Fix test description
Browse files Browse the repository at this point in the history
  • Loading branch information
shuse2 committed Nov 21, 2022
1 parent faffdb8 commit 138e063
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ import { CCMStatusCode, MIN_RETURN_FEE } from './constants';
import { CCMProcessedCode, CcmProcessedEvent, CCMProcessedResult } from './events/ccm_processed';
import { CcmSendSuccessEvent } from './events/ccm_send_success';
import { ccmSchema, crossChainUpdateTransactionParams } from './schemas';
import { CrossChainMessageContext, TokenMethod } from './types';
import { ChainAccountStore } from './stores/chain_account';
import { getMainchainID } from './utils';
import {
CCMsg,
CrossChainMessageContext,
CrossChainUpdateTransactionParams,
TokenMethod,
} from './types';
import { ChainAccountStore, ChainStatus } from './stores/chain_account';
import { getMainchainID, isInboxUpdateEmpty, validateFormat } from './utils';
import { ChainValidatorsStore } from './stores/chain_validators';
import { ChannelDataStore } from './stores/channel_data';

export abstract class BaseCrossChainUpdateCommand<
T extends BaseInteroperabilityInternalMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ import { PrefixedStateReadWriter } from '../../../../src/state_machine/prefixed_
import { ChainValidatorsStore } from '../../../../src/modules/interoperability/stores/chain_validators';
import { ChannelDataStore } from '../../../../src/modules/interoperability/stores/channel_data';
import { MainchainInteroperabilityInternalMethod } from '../../../../src/modules/interoperability/mainchain/internal_method';
import { CrossChainMessageContext } from '../../../../src/modules/interoperability/types';
import { createCrossChainMessageContext } from '../../../../src/testing';
import { ChainAccountStore } from '../../../../src/modules/interoperability/stores/chain_account';
import { getMainchainID } from '../../../../src/modules/interoperability/utils';
import { BaseInteroperabilityInternalMethod } from '../../../../src/modules/interoperability/base_interoperability_internal_methods';

class CrossChainUpdateCommand extends BaseCrossChainUpdateCommand<MainchainInteroperabilityInternalMethod> {
// eslint-disable-next-line @typescript-eslint/require-await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ describe('CrossChainUpdateCommand', () => {
);
});

it('should reject when first CCU contains a certificate older than LIVENESS_LIMIT / 2', async () => {
it('should reject when first CCU contains a certificate older than LIVENESS_LIMIT / 2', async () => {
await interopMod.stores.get(ChainAccountStore).set(stateStore, params.sendingChainID, {
...partnerChainAccount,
status: ChainStatus.REGISTERED,
Expand Down Expand Up @@ -381,7 +381,7 @@ it('should reject when first CCU contains a certificate older than LIVENESS_LIMI
);
});

it('should call apply for ccm and add to the inbox where receivign chain is the main chain', async () => {
it('should call apply for ccm and add to the inbox where receiving chain is the main chain', async () => {
executeContext = createTransactionContext({
chainID,
stateStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ describe('CrossChainUpdateCommand', () => {
params: codec.encode(crossChainUpdateTransactionParams, params),
}),
}).createCommandVerifyContext(sidechainCCUUpdateCommand.schema);
jest
.spyOn(sidechainCCUUpdateCommand['internalMethod'], 'isLive')
.mockResolvedValue(true);
jest.spyOn(sidechainCCUUpdateCommand['internalMethod'], 'isLive').mockResolvedValue(true);
});

it('should reject when ccu params validation fails', async () => {
Expand All @@ -281,9 +279,7 @@ describe('CrossChainUpdateCommand', () => {
});

it('should return error when sending chain not live', async () => {
jest
.spyOn(sidechainCCUUpdateCommand['internalMethod'], 'isLive')
.mockResolvedValue(false);
jest.spyOn(sidechainCCUUpdateCommand['internalMethod'], 'isLive').mockResolvedValue(false);
await expect(sidechainCCUUpdateCommand.verify(verifyContext)).rejects.toThrow(
'The sending chain is not live',
);
Expand Down Expand Up @@ -347,7 +343,7 @@ describe('CrossChainUpdateCommand', () => {
);
});

it('should call apply for ccm and add to the inbox where receivign chain is the main chain', async () => {
it('should call apply for ccm and add to the inbox where receiving chain is the main chain', async () => {
executeContext = createTransactionContext({
chainID,
stateStore,
Expand All @@ -362,9 +358,9 @@ describe('CrossChainUpdateCommand', () => {

await expect(sidechainCCUUpdateCommand.execute(executeContext)).resolves.toBeUndefined();
expect(sidechainCCUUpdateCommand['apply']).toHaveBeenCalledTimes(3);
expect(
sidechainCCUUpdateCommand['internalMethod'].appendToInboxTree,
).toHaveBeenCalledTimes(3);
expect(sidechainCCUUpdateCommand['internalMethod'].appendToInboxTree).toHaveBeenCalledTimes(
3,
);
});
});
});

0 comments on commit 138e063

Please sign in to comment.