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

Commit

Permalink
Fix length requirement and dataType on getChainAccountRequestSchema a…
Browse files Browse the repository at this point in the history
…nd test cases
  • Loading branch information
Phanco committed Jun 21, 2023
1 parent d9d9dc5 commit 4ecdcb4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions framework/src/modules/interoperability/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,10 @@ export const getChainAccountRequestSchema = {
required: ['chainID'],
properties: {
chainID: {
type: 'string',
format: 'hex',
dataType: 'bytes',
fieldNumber: 1,
minLength: CHAIN_ID_LENGTH,
maxLength: CHAIN_ID_LENGTH,
},
},
};
Expand Down
4 changes: 2 additions & 2 deletions framework/test/unit/modules/interoperability/endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ describe('Test interoperability endpoint', () => {
getStore: (p1: Buffer, p2: Buffer) => stateStore.getStore(p1, p2),
getImmutableMethodContext: jest.fn(),
getOffchainStore: jest.fn(),
chainID: Buffer.alloc(0),
params: { chainID: '00000001' },
chainID: utils.intToBuffer(1, 4),
params: { chainID: utils.intToBuffer(1, 4) },
logger: {} as any,
header: { aggregateCommit: { height: 10 }, height: 12, timestamp: Date.now() },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('MainchainInteroperabilityEndpoint', () => {
it('should return false when chainID equals mainchainID', async () => {
context = createTransientModuleEndpointContext({
params: {
chainID: '00000000',
chainID: Buffer.from('00000000', 'hex'),
},
});
const isAvailable = await endpoint.isChainIDAvailable(context);
Expand All @@ -148,7 +148,7 @@ describe('MainchainInteroperabilityEndpoint', () => {
it('should return false when chainID is not on the mainchain network', async () => {
context = createTransientModuleEndpointContext({
params: {
chainID: '11111111',
chainID: Buffer.from('11111111', 'hex'),
},
});
const isAvailable = await endpoint.isChainIDAvailable(context);
Expand All @@ -158,7 +158,7 @@ describe('MainchainInteroperabilityEndpoint', () => {
it('should return false when the chainID exists', async () => {
context = createTransientModuleEndpointContext({
params: {
chainID: '00000001',
chainID: Buffer.from('00000001', 'hex'),
},
});
chainAccountStore.has.mockResolvedValue(true);
Expand Down

0 comments on commit 4ecdcb4

Please sign in to comment.