From e6a7c5d0565d74443042b8ff7f305e65072e057e Mon Sep 17 00:00:00 2001 From: Franco NG Date: Fri, 24 Nov 2023 16:22:32 +0100 Subject: [PATCH] Update test cases and config file, removing ccuFee = 0 --- .../config/custom_config_node_one.json | 1 - .../config/default/config.json | 1 - .../test/unit/plugin.spec.ts | 26 ++++++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/examples/interop/pos-mainchain-fast/config/custom_config_node_one.json b/examples/interop/pos-mainchain-fast/config/custom_config_node_one.json index bc652cc06e..ec397464d4 100644 --- a/examples/interop/pos-mainchain-fast/config/custom_config_node_one.json +++ b/examples/interop/pos-mainchain-fast/config/custom_config_node_one.json @@ -29,7 +29,6 @@ "chainConnector": { "receivingChainID": "04000001", "encryptedPrivateKey": "kdf=argon2id&cipher=aes-128-gcm&version=1&ciphertext=aa92aefc87797b8e107e0ebc8f863333b8dbc173b7d6e75b0f3ca1f5113d64050247a2c79679840193ea564a34c80f7e3d8ff77d5a9a2cd7e9c1e912e707b38206d4700485013ae14e33db2e31f4f0cfeee5fdbe4e2356cce179819f87da348cf2fe057f6e320b809db3ffdad7cbae86c568184caebe3ba44edb49c59e263012&mac=e4d31ce6274e3dd83c70732f9965846114d53e07e831b1f5bb9a841e1731d85a&salt=a3fd8ab81c91b9b5&iv=c3028fe54417f71e1caba5727be0040d&tag=f97a0df7b6349f90310ebf3eed4dde42&iterations=1¶llelism=4&memorySize=2097023", - "ccuFee": "0", "receivingChainIPCPath": "~/.lisk/pos-sidechain-example-one", "registrationHeight": 10 } diff --git a/examples/interop/pos-sidechain-example-one/config/default/config.json b/examples/interop/pos-sidechain-example-one/config/default/config.json index 2888ccf84f..55f8adb31d 100644 --- a/examples/interop/pos-sidechain-example-one/config/default/config.json +++ b/examples/interop/pos-sidechain-example-one/config/default/config.json @@ -45,7 +45,6 @@ "chainConnector": { "receivingChainID": "04000000", "encryptedPrivateKey": "kdf=argon2id&cipher=aes-128-gcm&version=1&ciphertext=c91b8dc71310bd3cdb28061ed3cad59044e16c7ecce1fc22259428c83314d8f55d4b32c1ee1fec519fdb614b52ef3f9388ae0da092b1caf0d519ed33a1d63d4105e366e8bf44f857252e738f19b5befc047acebc9a69cc196cac8521a9e64ecee93520c5ac04e124229a33e8dff97f13d78b4980cbe74d09596f37b299373729&mac=fea49a78aaa02d2c1fdc075737ab63be41e0f7f4beda7bacfda39acfbcc70647&salt=55107ca75dbf6f50&iv=bf7696ce4e1a0a64cf88af35f7028aae&tag=411573e9fdf474df43b022d321219b7d&iterations=1¶llelism=4&memorySize=2097023", - "ccuFee": "0", "receivingChainIPCPath": "~/.lisk/mainchain-node-one", "registrationHeight": 10 }, diff --git a/framework-plugins/lisk-framework-chain-connector-plugin/test/unit/plugin.spec.ts b/framework-plugins/lisk-framework-chain-connector-plugin/test/unit/plugin.spec.ts index 5cbe54e18d..3c592feeae 100644 --- a/framework-plugins/lisk-framework-chain-connector-plugin/test/unit/plugin.spec.ts +++ b/framework-plugins/lisk-framework-chain-connector-plugin/test/unit/plugin.spec.ts @@ -1064,7 +1064,7 @@ describe('ChainConnectorPlugin', () => { .mockResolvedValue(initializationFees); }); - it('should return config.ccuFee + additionalFee when ccuFee exists', async () => { + it('should return config.ccuFee + additionalFee when config.ccuFee exists', async () => { await initChainConnectorPlugin(chainConnectorPlugin, defaultConfig); await expect(chainConnectorPlugin['_getCcuFee'](transactionTemplate)).resolves.toBe( BigInt(defaultCCUFee) + initializationFees.userAccount, @@ -1094,7 +1094,7 @@ describe('ChainConnectorPlugin', () => { }); }); - it('should return config.ccuFee when ccuFee exists', async () => { + it('should return config.ccuFee when config.ccuFee exists', async () => { await initChainConnectorPlugin(chainConnectorPlugin, defaultConfig); await expect(chainConnectorPlugin['_getCcuFee'](transactionTemplate)).resolves.toBe( BigInt(defaultCCUFee), @@ -1803,6 +1803,11 @@ describe('ChainConnectorPlugin', () => { }) .calledWith('auth_getAuthAccount', expect.anything()) .mockResolvedValue({ nonce: '3' }); + when(sendingChainAPIClientMock.invoke) + .calledWith('token_hasUserAccount', expect.anything()) + .mockResolvedValue({ + exists: true, + }); await chainConnectorPlugin['_submitCCU'](sampleCCUParams); }); @@ -1821,7 +1826,22 @@ describe('ChainConnectorPlugin', () => { expect(sendingChainAPIClientMock.invoke).toHaveBeenCalledWith('txpool_postTransaction', { transaction: expect.any(String), }); - expect(sendingChainAPIClientMock.invoke).toHaveBeenCalledTimes(3); + expect(sendingChainAPIClientMock.invoke).toHaveBeenNthCalledWith( + 1, + 'auth_getAuthAccount', + expect.anything(), + ); + expect(sendingChainAPIClientMock.invoke).toHaveBeenNthCalledWith(2, 'system_getNodeInfo'); + expect(sendingChainAPIClientMock.invoke).toHaveBeenNthCalledWith( + 3, + 'token_hasUserAccount', + expect.anything(), + ); + expect(sendingChainAPIClientMock.invoke).toHaveBeenNthCalledWith( + 4, + 'txpool_postTransaction', + expect.anything(), + ); }); }); });