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

Commit

Permalink
Update code according to PR reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
Phanco committed Oct 20, 2022
1 parent de12483 commit d9a7351
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions elements/lisk-chain/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export {
EVENT_MAX_EVENT_SIZE_BYTES,
MAX_EVENTS_PER_BLOCK,
EVENT_KEY_LENGTH,
NAME_REGEX,
MAX_CROSS_CHAIN_COMMAND_NAME_LENGTH,
MAX_MODULE_NAME_LENGTH,
MIN_CROSS_CHAIN_COMMAND_NAME_LENGTH,
MIN_MODULE_NAME_LENGTH,
} from './constants';
export * from './db_keys';
export type { RawBlock } from './types';
Expand Down
2 changes: 1 addition & 1 deletion framework/src/modules/interoperability/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
MAX_MODULE_NAME_LENGTH,
MIN_CROSS_CHAIN_COMMAND_NAME_LENGTH,
MIN_MODULE_NAME_LENGTH,
} from '@liskhq/lisk-chain/dist-node/constants';
} from '@liskhq/lisk-chain';
import { CHAIN_ID_LENGTH } from '../token/constants';
import {
MAX_LENGTH_NAME,
Expand Down
4 changes: 2 additions & 2 deletions framework/src/modules/interoperability/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { codec } from '@liskhq/lisk-codec';
import { utils, bls } from '@liskhq/lisk-cryptography';
import { validator } from '@liskhq/lisk-validator';
import { dataStructures } from '@liskhq/lisk-utils';
import { NAME_REGEX } from '@liskhq/lisk-chain/dist-node/constants';
import { NAME_REGEX } from '@liskhq/lisk-chain';
import {
ActiveValidators,
CCMsg,
Expand Down Expand Up @@ -94,7 +94,7 @@ export const validateFormat = (ccm: CCMsg) => {
}

if (serializedCCM.byteLength > MAX_CCM_SIZE) {
throw new Error(`Cross chain message is over the the max ccm size limit of ${MAX_CCM_SIZE}`);
throw new Error(`Cross chain message is over the the max CCM size limit of ${MAX_CCM_SIZE}`);
}
};

Expand Down
7 changes: 6 additions & 1 deletion framework/test/unit/modules/interoperability/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,7 @@ describe('Utils', () => {
sendingChainID: obj.sendingChainID ?? cryptography.utils.intToBuffer(20, 4),
status: obj.status ?? CCM_STATUS_OK,
});

it('should throw if format does not fit ccmSchema', () => {
expect(() =>
validateFormat(
Expand All @@ -2151,6 +2152,7 @@ describe('Utils', () => {
),
).toThrow("Property '.module' must NOT have fewer than 1 characters");
});

it('should throw if module does not pass Regex', () => {
expect(() =>
validateFormat(
Expand All @@ -2160,6 +2162,7 @@ describe('Utils', () => {
),
).toThrow('Cross-chain message module name must be alphanumeric.');
});

it('should throw if crossChainCommand does not pass Regex', () => {
expect(() =>
validateFormat(
Expand All @@ -2169,15 +2172,17 @@ describe('Utils', () => {
),
).toThrow('Cross-chain message crossChainCommand name must be alphanumeric.');
});

it('should throw if byteLength exceeds MAX_CCM_SIZE', () => {
expect(() =>
validateFormat(
buildCCM({
params: Buffer.alloc(MAX_CCM_SIZE + 100),
}),
),
).toThrow(`Cross chain message is over the the max ccm size limit of ${MAX_CCM_SIZE}`);
).toThrow(`Cross chain message is over the the max CCM size limit of ${MAX_CCM_SIZE}`);
});

it('should pass validateFormat check', () => {
expect(() => validateFormat(buildCCM({}))).not.toThrow();
});
Expand Down

0 comments on commit d9a7351

Please sign in to comment.