diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5afd886cb8..4ed27ca2ee 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2010,7 +2010,7 @@ jobs: JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/ctp-htlc-eth-besu-erc20 JEST_TEST_CODE_COVERAGE_ENABLED: true TAPE_TEST_PATTERN: >- - --files={./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/get-status-endpoint.test.ts,./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/openapi/openapi-validation.test.ts,./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts} + --files={./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/openapi/openapi-validation.test.ts,./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts} TAPE_TEST_RUNNER_DISABLED: false needs: build-dev runs-on: ubuntu-22.04 diff --git a/.taprc b/.taprc index 67e6efca30..9c60e211da 100644 --- a/.taprc +++ b/.taprc @@ -8,7 +8,6 @@ files: - ./packages/cactus-plugin-keychain-aws-sm/src/test/typescript/integration/plugin-factory-keychain.test.ts - ./packages/cactus-plugin-keychain-aws-sm/src/test/typescript/integration/plugin-factory-keychain.test.ts - ./packages/cactus-plugin-keychain-azure-kv/src/test/typescript/integration/plugin-keychain-azure-kv.test.ts - - ./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/get-status-endpoint.test.ts - ./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/openapi/openapi-validation.test.ts - ./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts - ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/openapi/openapi-validation.test.ts diff --git a/jest.config.js b/jest.config.js index d2b50e9f9d..7ab50e6a5e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -21,7 +21,6 @@ module.exports = { `./packages/cactus-plugin-keychain-aws-sm/src/test/typescript/integration/plugin-factory-keychain.test.ts`, `./packages/cactus-plugin-keychain-aws-sm/src/test/typescript/integration/plugin-factory-keychain.test.ts`, `./packages/cactus-plugin-keychain-azure-kv/src/test/typescript/integration/plugin-keychain-azure-kv.test.ts`, - `./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/get-status-endpoint.test.ts`, `./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/openapi/openapi-validation.test.ts`, `./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts`, `./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/openapi/openapi-validation.test.ts`, diff --git a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/get-status-endpoint.test.ts b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/get-status-endpoint.test.ts index f710734fee..463d0370b2 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/get-status-endpoint.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/get-status-endpoint.test.ts @@ -1,9 +1,11 @@ +import "jest-extended"; + import http from "http"; import type { AddressInfo } from "net"; -import test, { Test } from "tape-promise/tape"; import { v4 as uuidv4 } from "uuid"; import express from "express"; import bodyParser from "body-parser"; + import { Configuration, DefaultApi as BesuApi, @@ -52,419 +54,228 @@ const web3SigningCredential: Web3SigningCredential = { type: Web3SigningCredentialType.PrivateKeyHex, } as Web3SigningCredential; -const testCase = "Test get status"; - -test("BEFORE " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning did not throw OK"); - t.end(); -}); +const testCase = "Test for get-status-endpoint"; -test(testCase, async (t: Test) => { - t.comment("Starting Besu Test Ledger"); - const besuTestLedger = new BesuTestLedger(); - await besuTestLedger.start(); +describe(testCase, () => { + let server: http.Server; - test.onFinish(async () => { - await besuTestLedger.stop(); - await besuTestLedger.destroy(); - await pruneDockerAllIfGithubAction({ logLevel }); + beforeAll(async () => { + const pruning = pruneDockerAllIfGithubAction({ logLevel }); + await expect(pruning).resolves.toBeTruthy(); }); - const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost(); - const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost(); - const keychainId = uuidv4(); - const keychainPlugin = new PluginKeychainMemory({ - instanceId: uuidv4(), - keychainId, - // pre-provision keychain with mock backend holding the private key of the - // test account that we'll reference while sending requests with the - // signing credential pointing to this keychain entry. - backend: new Map([ - [TestTokenJSON.contractName, JSON.stringify(TestTokenJSON)], - ]), - logLevel, - }); - keychainPlugin.set( - DemoHelperJSON.contractName, - JSON.stringify(DemoHelperJSON), - ); - keychainPlugin.set( - HashTimeLockJSON.contractName, - JSON.stringify(HashTimeLockJSON), - ); - const factory = new PluginFactoryLedgerConnector({ - pluginImportType: PluginImportType.Local, - }); - - const pluginRegistry = new PluginRegistry({}); - const connector: PluginLedgerConnectorBesu = await factory.create({ - rpcApiHttpHost, - rpcApiWsHost, - logLevel, - instanceId: connectorId, - pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), - }); - - pluginRegistry.add(connector); - const pluginOptions: IPluginHtlcEthBesuErc20Options = { - instanceId: uuidv4(), - logLevel, - pluginRegistry, - }; - - const factoryHTLC = new PluginFactoryHtlcEthBesuErc20({ - pluginImportType: PluginImportType.Local, - }); - const pluginHtlc = await factoryHTLC.create(pluginOptions); - pluginRegistry.add(pluginHtlc); - const expressApp = express(); expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server)); - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - - const configuration = new Configuration({ basePath: apiHost }); - const api = new BesuApi(configuration); + server = http.createServer(expressApp); - await pluginHtlc.getOrCreateWebServices(); - await pluginHtlc.registerWebServices(expressApp); - - t.comment("Deploys HashTimeLock via .json file on initialize function"); - const initRequest: InitializeRequest = { - connectorId, - keychainId, - constructorArgs: [], - web3SigningCredential, - gas: estimatedGas, - }; - const deployOut = await pluginHtlc.initialize(initRequest); - - t.ok(deployOut, "pluginHtlc.initialize() output is truthy OK"); - t.ok( - deployOut.transactionReceipt, - "pluginHtlc.initialize() output.transactionReceipt is truthy OK", - ); - t.ok( - deployOut.transactionReceipt.contractAddress, - "pluginHtlc.initialize() output.transactionReceipt.contractAddress is truthy OK", - ); - const hashTimeLockAddress = deployOut.transactionReceipt - .contractAddress as string; - - t.comment("Deploys TestToken via .json file on deployContract function"); - const deployOutToken = await connector.deployContract({ - contractName: TestTokenJSON.contractName, - contractAbi: TestTokenJSON.abi, - bytecode: TestTokenJSON.bytecode, - web3SigningCredential, - keychainId, - constructorArgs: ["100", "token", "2", "TKN"], - gas: estimatedGas, - }); - t.ok(deployOutToken, "deployContract() output is truthy OK"); - t.ok( - deployOutToken.transactionReceipt, - "deployContract() output.transactionReceipt is truthy OK", - ); - t.ok( - deployOutToken.transactionReceipt.contractAddress, - "deployContract() output.transactionReceipt.contractAddress is truthy OK", - ); - const tokenAddress = deployOutToken.transactionReceipt - .contractAddress as string; - - t.comment("Deploys DemoHelpers via .json file on deployContract function"); - const deployOutDemo = await connector.deployContract({ - contractName: DemoHelperJSON.contractName, - contractAbi: DemoHelperJSON.abi, - bytecode: DemoHelperJSON.bytecode, - web3SigningCredential, - keychainId, - constructorArgs: [], - gas: estimatedGas, - }); - t.ok(deployOutDemo, "deployContract() output is truthy OK"); - t.ok( - deployOutDemo.transactionReceipt, - "deployContract() output.transactionReceipt is truthy OK", - ); - t.ok( - deployOutDemo.transactionReceipt.contractAddress, - "deployContract() output.transactionReceipt.contractAddress is truthy OK", - ); - - t.comment("Approve 10 Tokens to HashTimeLockAddress"); - const { success } = await connector.invokeContract({ - contractName: TestTokenJSON.contractName, - keychainId, - signingCredential: web3SigningCredential, - invocationType: EthContractInvocationType.Send, - methodName: "approve", - params: [hashTimeLockAddress, "10"], - gas: estimatedGas, - }); - t.equal(success, true, "approve() transactionReceipt.status is true OK"); - - t.comment("Get balance of account"); - const { callOutput } = await connector.invokeContract({ - contractName: TestTokenJSON.contractName, - keychainId, - signingCredential: web3SigningCredential, - invocationType: EthContractInvocationType.Call, - methodName: "balanceOf", - params: [firstHighNetWorthAccount], - }); - t.equal(callOutput, "100", "balance of account is 100 OK"); - - t.comment("Get HashTimeLock contract and account allowance"); - const responseAllowance = await connector.invokeContract({ - contractName: TestTokenJSON.contractName, - keychainId, - signingCredential: web3SigningCredential, - invocationType: EthContractInvocationType.Call, - methodName: "allowance", - params: [firstHighNetWorthAccount, hashTimeLockAddress], - }); - t.equal(responseAllowance.callOutput, "10", "callOutput() is 10 OK"); - - t.comment("Create new contract for HTLC"); - const request: NewContractRequest = { - contractAddress: hashTimeLockAddress, - inputAmount: 10, - outputAmount: 1, - expiration, - hashLock, - tokenAddress, - receiver, - outputNetwork: "BTC", - outputAddress: "1AcVYm7M3kkJQH28FXAvyBFQzFRL6xPKu8", - connectorId, - keychainId, - web3SigningCredential, - gas: estimatedGas, - }; - const responseNewContract = await api.newContractV1(request); - t.equal(responseNewContract.status, 200, "response status is 200 OK"); - - t.comment("Get status of HTLC"); - const responseTxId = await connector.invokeContract({ - contractName: DemoHelperJSON.contractName, - keychainId, - signingCredential: web3SigningCredential, - invocationType: EthContractInvocationType.Call, - methodName: "getTxId", - params: [ - firstHighNetWorthAccount, - receiver, - 10, - hashLock, - expiration, - tokenAddress, - ], - }); - const ids = [responseTxId.callOutput as string]; - const res = await api.getStatusV1({ - ids, - web3SigningCredential, - connectorId, - keychainId, + beforeAll(async () => { + server = http.createServer(expressApp); + await besuTestLedger.start(); }); - t.equal(res.status, 200, "response status is 200 OK"); - t.equal(res.data[0], "1", "the contract status is 1 - Active"); - t.end(); -}); - -test("Test get invalid id status", async (t: Test) => { - t.comment("Starting Besu Test Ledger"); - const besuTestLedger = new BesuTestLedger(); - await besuTestLedger.start(); - test.onFinish(async () => { + afterAll(async () => { await besuTestLedger.stop(); await besuTestLedger.destroy(); }); - const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost(); - const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost(); - const keychainId = uuidv4(); - const keychainPlugin = new PluginKeychainMemory({ - instanceId: uuidv4(), - keychainId, - // pre-provision keychain with mock backend holding the private key of the - // test account that we'll reference while sending requests with the - // signing credential pointing to this keychain entry. - backend: new Map([ - [TestTokenJSON.contractName, JSON.stringify(TestTokenJSON)], - ]), - logLevel, - }); - keychainPlugin.set( - DemoHelperJSON.contractName, - JSON.stringify(DemoHelperJSON), - ); - keychainPlugin.set( - HashTimeLockJSON.contractName, - JSON.stringify(HashTimeLockJSON), - ); - const factory = new PluginFactoryLedgerConnector({ - pluginImportType: PluginImportType.Local, - }); - - const pluginRegistry = new PluginRegistry({}); - const connector: PluginLedgerConnectorBesu = await factory.create({ - rpcApiHttpHost, - rpcApiWsHost, - logLevel, - instanceId: connectorId, - pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), - }); - - pluginRegistry.add(connector); - const pluginOptions: IPluginHtlcEthBesuErc20Options = { - instanceId: uuidv4(), - logLevel, - pluginRegistry, - }; - - const factoryHTLC = new PluginFactoryHtlcEthBesuErc20({ - pluginImportType: PluginImportType.Local, - }); - const pluginHtlc = await factoryHTLC.create(pluginOptions); - pluginRegistry.add(pluginHtlc); - - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server)); - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - - const configuration = new Configuration({ basePath: apiHost }); - const api = new BesuApi(configuration); - - await pluginHtlc.getOrCreateWebServices(); - await pluginHtlc.registerWebServices(expressApp); - - t.comment("Deploys HashTimeLock via .json file on initialize function"); - const initRequest: InitializeRequest = { - connectorId, - keychainId, - constructorArgs: [], - web3SigningCredential, - gas: estimatedGas, - }; - const deployOut = await pluginHtlc.initialize(initRequest); - t.ok(deployOut, "pluginHtlc.initialize() output is truthy OK"); - t.ok( - deployOut.transactionReceipt, - "pluginHtlc.initialize() output.transactionReceipt is truthy OK", - ); - t.ok( - deployOut.transactionReceipt.contractAddress, - "pluginHtlc.initialize() output.transactionReceipt.contractAddress is truthy OK", - ); - const hashTimeLockAddress = deployOut.transactionReceipt - .contractAddress as string; - - t.comment("Deploys TestToken via .json file on deployContract function"); - const deployOutToken = await connector.deployContract({ - contractName: TestTokenJSON.contractName, - contractAbi: TestTokenJSON.abi, - bytecode: TestTokenJSON.bytecode, - web3SigningCredential, - keychainId, - constructorArgs: ["100", "token", "2", "TKN"], - gas: estimatedGas, - }); - t.ok(deployOutToken, "deployContract() output is truthy OK"); - t.ok( - deployOutToken.transactionReceipt, - "deployContract() output.transactionReceipt is truthy OK", - ); - t.ok( - deployOutToken.transactionReceipt.contractAddress, - "deployContract() output.transactionReceipt.contractAddress is truthy OK", - ); - const tokenAddress = deployOutToken.transactionReceipt - .contractAddress as string; - - t.comment("Approve 10 Tokens to HashTimeLockAddress"); - const { success } = await connector.invokeContract({ - contractName: TestTokenJSON.contractName, - signingCredential: web3SigningCredential, - invocationType: EthContractInvocationType.Send, - methodName: "approve", - keychainId, - params: [hashTimeLockAddress, "10"], - gas: estimatedGas, - }); - t.equal(success, true, "approve() transactionReceipt.status is true OK"); + afterAll(async () => await Servers.shutdown(server)); - t.comment("Get balance of account"); - const { callOutput } = await connector.invokeContract({ - contractName: TestTokenJSON.contractName, - keychainId, - signingCredential: web3SigningCredential, - invocationType: EthContractInvocationType.Call, - methodName: "balanceOf", - params: [firstHighNetWorthAccount], + afterAll(async () => { + const pruning = pruneDockerAllIfGithubAction({ logLevel }); + await expect(pruning).resolves.toBeTruthy(); }); - t.equal(callOutput, "100", "balance of account is 100 OK"); - t.comment("Get HashTimeLock contract and account allowance"); - const responseAllowance = await connector.invokeContract({ - contractName: TestTokenJSON.contractName, - keychainId, - signingCredential: web3SigningCredential, - invocationType: EthContractInvocationType.Call, - methodName: "allowance", - params: [firstHighNetWorthAccount, hashTimeLockAddress], - }); - t.equal(responseAllowance.callOutput, "10", "callOutput() is 10 OK"); - - t.comment("Create new contract for HTLC"); - const request: NewContractRequest = { - contractAddress: hashTimeLockAddress, - inputAmount: 10, - outputAmount: 1, - expiration, - hashLock, - tokenAddress, - receiver, - outputNetwork: "BTC", - outputAddress: "1AcVYm7M3kkJQH28FXAvyBFQzFRL6xPKu8", - connectorId, - keychainId, - web3SigningCredential, - gas: estimatedGas, - }; - const responseNewContract = await api.newContractV1(request); - t.equal(responseNewContract.status, 200, "response status is 200 OK"); - - t.comment("Get invalid status of HTLC"); - const fakeId = "0x66616b654964"; - const res = await api.getStatusV1({ - ids: [fakeId], - web3SigningCredential, - connectorId, - keychainId, + test(testCase, async () => { + const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost(); + const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost(); + + const keychainId = uuidv4(); + const keychainPlugin = new PluginKeychainMemory({ + instanceId: uuidv4(), + keychainId, + // pre-provision keychain with mock backend holding the private key of the + // test account that we'll reference while sending requests with the + // signing credential pointing to this keychain entry. + backend: new Map([ + [TestTokenJSON.contractName, JSON.stringify(TestTokenJSON)], + ]), + logLevel, + }); + keychainPlugin.set( + DemoHelperJSON.contractName, + JSON.stringify(DemoHelperJSON), + ); + keychainPlugin.set( + HashTimeLockJSON.contractName, + JSON.stringify(HashTimeLockJSON), + ); + const factory = new PluginFactoryLedgerConnector({ + pluginImportType: PluginImportType.Local, + }); + + const pluginRegistry = new PluginRegistry({}); + const connector: PluginLedgerConnectorBesu = await factory.create({ + rpcApiHttpHost, + rpcApiWsHost, + logLevel, + instanceId: connectorId, + pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), + }); + + pluginRegistry.add(connector); + const pluginOptions: IPluginHtlcEthBesuErc20Options = { + instanceId: uuidv4(), + logLevel, + pluginRegistry, + }; + + const factoryHTLC = new PluginFactoryHtlcEthBesuErc20({ + pluginImportType: PluginImportType.Local, + }); + const pluginHtlc = await factoryHTLC.create(pluginOptions); + pluginRegistry.add(pluginHtlc); + + const listenOptions: IListenOptions = { + hostname: "127.0.0.1", + port: 0, + server, + }; + const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; + const { address, port } = addressInfo; + const apiHost = `http://${address}:${port}`; + + const configuration = new Configuration({ basePath: apiHost }); + const api = new BesuApi(configuration); + + await pluginHtlc.getOrCreateWebServices(); + await pluginHtlc.registerWebServices(expressApp); + + const initRequest: InitializeRequest = { + connectorId, + keychainId, + constructorArgs: [], + web3SigningCredential, + gas: estimatedGas, + }; + const deployOut = await pluginHtlc.initialize(initRequest); + expect(deployOut).toBeTruthy(); + expect(deployOut.transactionReceipt).toBeTruthy(); + expect(deployOut.transactionReceipt.contractAddress).toBeTruthy(); + + const hashTimeLockAddress = deployOut.transactionReceipt + .contractAddress as string; + + const deployOutToken = await connector.deployContract({ + contractName: TestTokenJSON.contractName, + contractAbi: TestTokenJSON.abi, + bytecode: TestTokenJSON.bytecode, + web3SigningCredential, + keychainId, + constructorArgs: ["100", "token", "2", "TKN"], + gas: estimatedGas, + }); + expect(deployOutToken).toBeTruthy(); + expect(deployOutToken.transactionReceipt).toBeTruthy(); + expect(deployOutToken.transactionReceipt.contractAddress).toBeTruthy(); + + const tokenAddress = deployOutToken.transactionReceipt + .contractAddress as string; + + const deployOutDemo = await connector.deployContract({ + contractName: DemoHelperJSON.contractName, + contractAbi: DemoHelperJSON.abi, + bytecode: DemoHelperJSON.bytecode, + web3SigningCredential, + keychainId, + constructorArgs: [], + gas: estimatedGas, + }); + expect(deployOutDemo).toBeTruthy(); + expect(deployOutDemo.transactionReceipt).toBeTruthy(); + expect(deployOutDemo.transactionReceipt.contractAddress).toBeTruthy(); + + const { success } = await connector.invokeContract({ + contractName: TestTokenJSON.contractName, + keychainId, + signingCredential: web3SigningCredential, + invocationType: EthContractInvocationType.Send, + methodName: "approve", + params: [hashTimeLockAddress, "10"], + gas: estimatedGas, + }); + expect(success).toBe(true); + + const { callOutput } = await connector.invokeContract({ + contractName: TestTokenJSON.contractName, + keychainId, + signingCredential: web3SigningCredential, + invocationType: EthContractInvocationType.Call, + methodName: "balanceOf", + params: [firstHighNetWorthAccount], + }); + expect(callOutput).toEqual("100"); + + const responseAllowance = await connector.invokeContract({ + contractName: TestTokenJSON.contractName, + keychainId, + signingCredential: web3SigningCredential, + invocationType: EthContractInvocationType.Call, + methodName: "allowance", + params: [firstHighNetWorthAccount, hashTimeLockAddress], + }); + expect(responseAllowance.callOutput).toEqual("10"); + + const request: NewContractRequest = { + contractAddress: hashTimeLockAddress, + inputAmount: 10, + outputAmount: 1, + expiration, + hashLock, + tokenAddress, + receiver, + outputNetwork: "BTC", + outputAddress: "1AcVYm7M3kkJQH28FXAvyBFQzFRL6xPKu8", + connectorId, + keychainId, + web3SigningCredential, + gas: estimatedGas, + }; + const responseNewContract = await api.newContractV1(request); + expect(responseNewContract.status).toEqual(200); + + const responseTxId = await connector.invokeContract({ + contractName: DemoHelperJSON.contractName, + keychainId, + signingCredential: web3SigningCredential, + invocationType: EthContractInvocationType.Call, + methodName: "getTxId", + params: [ + firstHighNetWorthAccount, + receiver, + 10, + hashLock, + expiration, + tokenAddress, + ], + }); + const ids = [responseTxId.callOutput as string]; + const res = await api.getStatusV1({ + ids, + web3SigningCredential, + connectorId, + keychainId, + }); + expect(res.status).toEqual(200); + expect(res.data[0]).toEqual("1"); + + const fakeId = "0x66616b654964"; + const response = await api.getStatusV1({ + ids: [fakeId], + web3SigningCredential, + connectorId, + keychainId, + }); + expect(response.status).toEqual(200); + expect(response.data[0]).toEqual("0"); }); - t.equal(res.status, 200, "response status is 200 OK"); - t.equal(res.data[0], "0", "the contract status is 0 - INVALID"); - t.end(); });