From a971b10cf57337bfd2a89bdf8772ed95b1bc74f1 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 24 Jan 2024 18:56:35 +0530 Subject: [PATCH] Pass fixturenet account address in env --- test/cli.test.ts | 25 ++++++++++--------------- test/run-tests.sh | 5 ++++- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/test/cli.test.ts b/test/cli.test.ts index 095c46a..2541fce 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -1,3 +1,4 @@ +import assert from 'assert'; import { spawnSync } from 'child_process'; describe('Test laconic CLI commands', () => { @@ -30,6 +31,9 @@ describe('Test laconic CLI commands', () => { }); describe('laconic cns ', () => { + const existingAccount = process.env.EXISTING_ACCOUNT; + assert(existingAccount, 'EXISTING_ACCOUNT not set in env'); + test('laconic cns status', async () => { const result = spawnSync('laconic', ['cns', 'status']); @@ -55,8 +59,8 @@ describe('Test laconic CLI commands', () => { describe('laconic cns bond ', () => { const bondBalance = 1000000000; + const bondOwner = existingAccount; let bondId: string; - let bondOwner: string; test('laconic cns bond create', async () => { const result = spawnSync('laconic', ['cns', 'bond', 'create', '--type', 'aphoton', '--quantity', bondBalance.toString(), '--gas', '200000', '--fees', '200000aphoton']); @@ -89,13 +93,10 @@ describe('Test laconic CLI commands', () => { const outputObj = Array.from(JSON.parse(output)); // Expected bond - const expectedBond = getExpectedBond({ id: bondId, balance: bondBalance }); + const expectedBond = getExpectedBond({ id: bondId, owner: bondOwner, balance: bondBalance }); expect(outputObj.length).toEqual(1); - expect(outputObj[0]).toHaveProperty('owner'); - expect(outputObj[0]).toMatchObject(expectedBond); - - bondOwner = outputObj[0].owner; + expect(outputObj[0]).toEqual(expectedBond); }); test('laconic cns bond list --owner ', async () => { @@ -142,9 +143,10 @@ describe('Test laconic CLI commands', () => { // Helper methods -function getExpectedBond(params: { id: string, balance: number, owner?: string }): any { - const bond: any = { +function getExpectedBond(params: { id: string, owner: string, balance: number}): any { + return { id: params.id, + owner: params.owner, balance: [ { type: "aphoton", @@ -152,11 +154,4 @@ function getExpectedBond(params: { id: string, balance: number, owner?: string } } ] }; - - // Add owner only if passed - if (params.owner) { - bond.owner = params.owner; - } - - return bond; } diff --git a/test/run-tests.sh b/test/run-tests.sh index 572e250..1ec0755 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -3,6 +3,9 @@ # Get the key from laconicd laconicd_key=$(yes | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe) +# Get the fixturenet account address +laconicd_account_address=$(docker compose exec laconicd laconicd keys list | awk '/- address:/ {print $3}') + # Set parameters for the test suite cosmos_chain_id=laconic_9000-1 laconicd_rest_endpoint=http://127.0.0.1:1317 @@ -26,4 +29,4 @@ echo "$config" > "$config_file" docker compose exec laconicd sh -c "curl --retry 10 --retry-delay 3 --retry-connrefused http://127.0.0.1:9473/api" # Run tests -yarn test +EXISTING_ACCOUNT=$laconicd_account_address yarn test