From 39d8f871a2bd09e09da6b1fe7c3ff7e1173aa870 Mon Sep 17 00:00:00 2001 From: shuse2 Date: Wed, 16 Nov 2022 20:19:43 +0100 Subject: [PATCH] :recycle: Apply format --- .../interoperability/internal_method.spec.ts | 72 +++++++++++-------- .../mainchain/commands/cc_update.spec.ts | 4 +- 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/framework/test/unit/modules/interoperability/internal_method.spec.ts b/framework/test/unit/modules/interoperability/internal_method.spec.ts index 9afd9159574..8d131b6801d 100644 --- a/framework/test/unit/modules/interoperability/internal_method.spec.ts +++ b/framework/test/unit/modules/interoperability/internal_method.spec.ts @@ -35,7 +35,10 @@ import { import { PrefixedStateReadWriter } from '../../../../src/state_machine/prefixed_state_read_writer'; import { InMemoryPrefixedStateDB } from '../../../../src/testing/in_memory_prefixed_state'; import { ChannelDataStore } from '../../../../src/modules/interoperability/stores/channel_data'; -import { outboxRootSchema, OutboxRootStore } from '../../../../src/modules/interoperability/stores/outbox_root'; +import { + outboxRootSchema, + OutboxRootStore, +} from '../../../../src/modules/interoperability/stores/outbox_root'; import { TerminatedOutboxAccount, TerminatedOutboxStore, @@ -964,36 +967,42 @@ describe('Base interoperability internal method', () => { }; beforeEach(async () => { - await interopMod.stores - .get(ChannelDataStore) - .set(methodContext, txParams.sendingChainID, { - ...channelData, - }); + await interopMod.stores.get(ChannelDataStore).set(methodContext, txParams.sendingChainID, { + ...channelData, + }); }); it('should reject when inbox root is empty but partnerchain outbox root does not match', async () => { - await expect(mainchainInteroperabilityInternalMethod.verifyPartnerChainOutboxRoot(context, { - ...txParams, - certificate: Buffer.alloc(0), - })).rejects.toThrow('Inbox root does not match partner chain outbox root'); + await expect( + mainchainInteroperabilityInternalMethod.verifyPartnerChainOutboxRoot(context, { + ...txParams, + certificate: Buffer.alloc(0), + }), + ).rejects.toThrow('Inbox root does not match partner chain outbox root'); }); it('should reject when certificate state root does not contain valid inclusion proof for inbox update', async () => { jest.spyOn(SparseMerkleTree.prototype, 'verify').mockResolvedValue(false); - await expect(mainchainInteroperabilityInternalMethod.verifyPartnerChainOutboxRoot(context, { - ...txParams, - })).rejects.toThrow('Invalid inclusion proof for inbox update'); + await expect( + mainchainInteroperabilityInternalMethod.verifyPartnerChainOutboxRoot(context, { + ...txParams, + }), + ).rejects.toThrow('Invalid inclusion proof for inbox update'); }); it('should resolve when certificate is empty and inbox root matches partner outbox root', async () => { jest.spyOn(SparseMerkleTree.prototype, 'verify').mockResolvedValue(false); - jest.spyOn(regularMerkleTree, 'calculateRootFromRightWitness').mockReturnValue(channelData.partnerChainOutboxRoot); + jest + .spyOn(regularMerkleTree, 'calculateRootFromRightWitness') + .mockReturnValue(channelData.partnerChainOutboxRoot); - await expect(mainchainInteroperabilityInternalMethod.verifyPartnerChainOutboxRoot(context, { - ...txParams, - certificate: Buffer.alloc(0), - })).resolves.toBeUndefined(); + await expect( + mainchainInteroperabilityInternalMethod.verifyPartnerChainOutboxRoot(context, { + ...txParams, + certificate: Buffer.alloc(0), + }), + ).resolves.toBeUndefined(); }); it('should resolve when certificate provides valid inclusion proof', async () => { @@ -1001,23 +1010,30 @@ describe('Base interoperability internal method', () => { jest.spyOn(SparseMerkleTree.prototype, 'verify').mockResolvedValue(true); jest.spyOn(regularMerkleTree, 'calculateRootFromRightWitness').mockReturnValue(nextRoot); - await expect(mainchainInteroperabilityInternalMethod.verifyPartnerChainOutboxRoot(context, { - ...txParams, - })).resolves.toBeUndefined(); + await expect( + mainchainInteroperabilityInternalMethod.verifyPartnerChainOutboxRoot(context, { + ...txParams, + }), + ).resolves.toBeUndefined(); - const outboxKey = Buffer.concat([interopMod.stores.get(OutboxRootStore).key, cryptoUtils.hash(txParams.sendingChainID)]); + const outboxKey = Buffer.concat([ + interopMod.stores.get(OutboxRootStore).key, + cryptoUtils.hash(txParams.sendingChainID), + ]); expect(SparseMerkleTree.prototype.verify).toHaveBeenCalledWith( certificate.stateRoot, [outboxKey], { siblingHashes: txParams.inboxUpdate.outboxRootWitness.siblingHashes, - queries: [{ - key: outboxKey, - value: codec.encode(outboxRootSchema, { root: nextRoot }), - bitmap: txParams.inboxUpdate.outboxRootWitness.bitmap, - }], + queries: [ + { + key: outboxKey, + value: codec.encode(outboxRootSchema, { root: nextRoot }), + bitmap: txParams.inboxUpdate.outboxRootWitness.bitmap, + }, + ], }, - ) + ); }); }); }); diff --git a/framework/test/unit/modules/interoperability/mainchain/commands/cc_update.spec.ts b/framework/test/unit/modules/interoperability/mainchain/commands/cc_update.spec.ts index 6e16d70cb41..074b2b23fdc 100644 --- a/framework/test/unit/modules/interoperability/mainchain/commands/cc_update.spec.ts +++ b/framework/test/unit/modules/interoperability/mainchain/commands/cc_update.spec.ts @@ -767,7 +767,7 @@ describe('CrossChainUpdateCommand', () => { ).not.toHaveBeenCalled(); }); - 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 receivign chain is the main chain', async () => { executeContext = createTransactionContext({ chainID, stateStore, @@ -787,7 +787,7 @@ describe('CrossChainUpdateCommand', () => { ).toHaveBeenCalledTimes(3); }); - it('should call forward for ccm and add to the inbox where receivign chain is not the mainchain ', async () => { + it('should call forward for ccm and add to the inbox where receivign chain is not the mainchain', async () => { executeContext = createTransactionContext({ chainID, stateStore,