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

Commit

Permalink
Revert check, since this check would be needed only in case message r…
Browse files Browse the repository at this point in the history
…ecovery gets enabled in sidechains
  • Loading branch information
sitetester committed Nov 9, 2023
1 parent d1e24f0 commit 142e547
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,6 @@ export class RecoverMessageCommand extends BaseInteroperabilityCommand<Mainchain
error: new Error('Cross-chain message sending chain is not live.'),
};
}

// Check that sending chain is valid. This check is relevant only in case direct sidechain channels are enabled
if (!chainID.equals(getMainchainID(chainID)) && !ccm.sendingChainID.equals(chainID)) {
return {
status: VerifyStatus.FAIL,
error: new Error('Cross-chain message sending chain ID is not valid.'),
};
}
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,111 +506,6 @@ describe('MessageRecoveryCommand', () => {
expect(result.error?.message).toInclude(`Cross-chain message sending chain is not live.`);
});

it('should not return error if OWN_CHAIN_ID === getMainchainID() but ccm.sendingChainID != OWN_CHAIN_ID', async () => {
const chainIDLocal = Buffer.from([0, 0, 0, 0]);
ccms = [
{
nonce: BigInt(0),
module: MODULE_NAME_INTEROPERABILITY,
crossChainCommand: CROSS_CHAIN_COMMAND_REGISTRATION,
sendingChainID: Buffer.from([1, 2, 3, 4]), // ***
receivingChainID: chainIDLocal,
fee: BigInt(1),
status: CCMStatusCode.OK,
params: Buffer.alloc(0),
},
];
ccmsEncoded = ccms.map(ccm => codec.encode(ccmSchema, ccm));
transactionParams.crossChainMessages = [...ccmsEncoded];
transactionParams.chainID = chainIDLocal; // ***
transactionParams.idxs = appendPrecedingToIndices([1], terminatedChainOutboxSize);

commandVerifyContext = createCommandVerifyContext(transaction, transactionParams);

await interopModule.stores
.get(TerminatedOutboxStore)
.set(createStoreGetter(commandVerifyContext.stateStore as any), chainIDLocal, {
outboxRoot,
outboxSize: terminatedChainOutboxSize,
partnerChainInboxSize: 0,
});

const result = await command.verify(commandVerifyContext);
expect(result.status).toBe(VerifyStatus.OK);
});

it('should not return error if OWN_CHAIN_ID !== getMainchainID() but ccm.sendingChainID === OWN_CHAIN_ID', async () => {
const chainIDLocal = Buffer.from([1, 2, 3, 4]);
ccms = [
{
nonce: BigInt(0),
module: MODULE_NAME_INTEROPERABILITY,
crossChainCommand: CROSS_CHAIN_COMMAND_REGISTRATION,
sendingChainID: chainIDLocal, // ***
receivingChainID: chainIDLocal,
fee: BigInt(1),
status: CCMStatusCode.OK,
params: Buffer.alloc(0),
},
];
ccmsEncoded = ccms.map(ccm => codec.encode(ccmSchema, ccm));
transactionParams.crossChainMessages = [...ccmsEncoded];
transactionParams.chainID = chainIDLocal; // ***
transactionParams.idxs = appendPrecedingToIndices([1], terminatedChainOutboxSize);

commandVerifyContext = createCommandVerifyContext(transaction, transactionParams);

await interopModule.stores
.get(TerminatedOutboxStore)
.set(createStoreGetter(commandVerifyContext.stateStore as any), chainIDLocal, {
outboxRoot,
outboxSize: terminatedChainOutboxSize,
partnerChainInboxSize: 0,
});

const result = await command.verify(commandVerifyContext);
expect(result.status).toBe(VerifyStatus.OK);
});

it('should return error if OWN_CHAIN_ID != getMainchainID() and ccm.sendingChainID != OWN_CHAIN_ID', async () => {
const chainIDLocal = Buffer.from([1, 2, 3, 4]);
ccms = [
{
nonce: BigInt(0),
module: MODULE_NAME_INTEROPERABILITY,
crossChainCommand: CROSS_CHAIN_COMMAND_REGISTRATION,
sendingChainID: Buffer.from([5, 6, 7, 8]), // ***
receivingChainID: chainIDLocal,
fee: BigInt(1),
status: CCMStatusCode.OK,
params: Buffer.alloc(0),
},
];
ccmsEncoded = ccms.map(ccm => codec.encode(ccmSchema, ccm));
transactionParams.crossChainMessages = [...ccmsEncoded];
transactionParams.chainID = chainIDLocal; // ***
transactionParams.idxs = appendPrecedingToIndices([1], terminatedChainOutboxSize);

commandVerifyContext = createCommandVerifyContext(transaction, transactionParams);

await interopModule.stores
.get(TerminatedOutboxStore)
.set(
createStoreGetter(commandVerifyContext.stateStore as any),
commandVerifyContext.params.chainID,
{
outboxRoot,
outboxSize: terminatedChainOutboxSize,
partnerChainInboxSize: 0,
},
);

const result = await command.verify(commandVerifyContext);

expect(result.status).toBe(VerifyStatus.FAIL);
expect(result.error?.message).toInclude('Cross-chain message sending chain ID is not valid.');
});

it('should return status OK for valid params', async () => {
const chainIDLocal = Buffer.from([0, 0, 0, 0]);
ccms = [
Expand Down

0 comments on commit 142e547

Please sign in to comment.