From efe3fd89bb805b6a2dbf56f9d58d60031169914e Mon Sep 17 00:00:00 2001 From: emidev98 Date: Mon, 4 Dec 2023 19:15:39 +0200 Subject: [PATCH] feat(v2.9): automatically install relayer when not installed --- integration-tests/README.md | 8 ++------ integration-tests/package.json | 4 ++-- integration-tests/src/modules/wasm/ics20.test.ts | 8 ++++---- integration-tests/src/setup/init-test-framework.sh | 2 +- integration-tests/src/setup/relayer/init-relayer.sh | 6 +++--- integration-tests/src/teardown.ts | 2 +- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/integration-tests/README.md b/integration-tests/README.md index 9eec00bd..5baaa345 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -1,14 +1,10 @@ # Terra Core Integration Tests -This project is meant to increase the success ratio for new core releases, improve reliability and features for [@terra-money/feather.js](https://github.com/terra-money/feather.js). This tests are written using TypeScript with [jest](https://jestjs.io/) and executed in parallel to improve time execution. +This project is meant to increase the success ratio of new core releases, improve reliability and features for [@terra-money/feather.js](https://github.com/terra-money/feather.js). This tests are written using TypeScript with [jest](https://jestjs.io/) and tries to improve the coverage by asserting as many outputs as possible. ### Development -This set of tests must run out of the box in Linux-based systems installing [GoLang 1.20](https://go.dev/), [jq](https://stedolan.github.io/jq/), [screen](https://www.geeksforgeeks.org/screen-command-in-linux-with-examples/) and [rly](https://github.com/cosmos/relayer). - -Keep in mind that tests are executed in paralel when using the same account with two different tests it can misslead test results with errors like "account missmatch sequence" when submitting two transactions with the same nonce, missmatching balances, etc... - -Another good practice with this framework is to isolate and assert values within a test considering that the data is not wiped out each time a new test is executed. +This set of tests must run out of the box in Linux-based systems installing [GoLang 1.20](https://go.dev/), [jq](https://stedolan.github.io/jq/) and [screen](https://www.geeksforgeeks.org/screen-command-in-linux-with-examples/). The relayer used in the tests is [go relayer](https://github.com/cosmos/relayer). Keep in mind that the data is not wiped out each time a new test is executed. Folders structure: diff --git a/integration-tests/package.json b/integration-tests/package.json index 8ddac978..934f6e8d 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -8,8 +8,8 @@ "test:relayer": "bash src/setup/relayer/init-relayer.sh", "test:chain:upgrade" : "bash src/setup/chain-upgrade/chain-upgrade.sh", "test:start" : "jest --runInBand --detectOpenHandles", - "start": "npm run test:init && npm run test:relayer && npm run test:start", - "test:clean": "rm -rf src/test-data chain-upgrade-data && pkill terrad && pkill terrad && pkill rly" + "start": "npm run test:init && npm run test:relayer && npm run test:start &", + "test:clean": "rm -rf src/test-data chain-upgrade-data && pkill terrad && pkill terrad && pkill relayer" }, "repository": { "type": "git", diff --git a/integration-tests/src/modules/wasm/ics20.test.ts b/integration-tests/src/modules/wasm/ics20.test.ts index 6987a3c1..72f86aa9 100644 --- a/integration-tests/src/modules/wasm/ics20.test.ts +++ b/integration-tests/src/modules/wasm/ics20.test.ts @@ -110,7 +110,7 @@ describe("Wasm Module (https://github.com/CosmWasm/wasmd/releases/tag/v0.45.0) " test("must create the channel for the ICS20 contract", async () => { // Stop the relayer to don't create conflicts try { - execSync("pkill rly") + execSync("pkill relayer") } catch (e) { console.log(e) @@ -118,12 +118,12 @@ describe("Wasm Module (https://github.com/CosmWasm/wasmd/releases/tag/v0.45.0) " // Create the path const pathToRelayDir = path.join(__dirname, "/../../test-data/relayer"); - execSync(`rly tx link "test1-test2" --src-port="wasm.${ics20ContractAddr}" --dst-port="transfer" --version="ics20-1" --home="${pathToRelayDir}"`, { stdio: "ignore" }) + execSync(`relayer tx link "test1-test2" --src-port="wasm.${ics20ContractAddr}" --dst-port="transfer" --version="ics20-1" --home="${pathToRelayDir}"`, { stdio: "ignore" }) await blockInclusion(); // Start the relayer again - const rlyStart = exec(`rly start "test1-test2" -p="events" -b=100 --flush-interval="1s" --time-threshold="1s" --home="${pathToRelayDir}" > ${pathToRelayDir}/relayer.log 2>&1`) - rlyStart.unref(); + const relayerStart = exec(`relayer start "test1-test2" -p="events" -b=100 --flush-interval="1s" --time-threshold="1s" --home="${pathToRelayDir}" > ${pathToRelayDir}/relayer.log 2>&1`) + relayerStart.unref(); const res = await LCD.chain1.ibc.channels("test-1", { "pagination.limit": 1, diff --git a/integration-tests/src/setup/init-test-framework.sh b/integration-tests/src/setup/init-test-framework.sh index 640074fc..2473546d 100755 --- a/integration-tests/src/setup/init-test-framework.sh +++ b/integration-tests/src/setup/init-test-framework.sh @@ -54,7 +54,7 @@ rm -rf $CHAIN_DIR echo "Stopping any processes related with the tests..." pkill terrad pkill terrad -pkill rly +pkill relayer # Add directories for both chains, exit if an error occurs if ! mkdir -p $CHAIN_DIR/$CHAINID_1 2>/dev/null; then diff --git a/integration-tests/src/setup/relayer/init-relayer.sh b/integration-tests/src/setup/relayer/init-relayer.sh index 6d871736..d73aa885 100755 --- a/integration-tests/src/setup/relayer/init-relayer.sh +++ b/integration-tests/src/setup/relayer/init-relayer.sh @@ -7,7 +7,7 @@ echo "##################" echo "" # Configure predefined mnemonic pharses -BINARY=rly +BINARY=relayer CHAIN_DIR=$(pwd)/src/test-data CHAINID_1=test-1 CHAINID_2=test-2 @@ -17,8 +17,8 @@ MNEMONIC_2="record gift you once hip style during joke field prize dust unique l # Ensure rly is installed if ! [ -x "$(command -v $BINARY)" ]; then echo "$BINARY is required to run this script..." - echo "You can download at https://github.com/cosmos/relayer" - exit 1 + echo "Installing go relayer https://github.com/cosmos/relayer" + go install github.com/cosmos/relayer/v2@v2.4.2 fi echo "Initializing $BINARY..." diff --git a/integration-tests/src/teardown.ts b/integration-tests/src/teardown.ts index 4d9ba20e..fe0fa714 100644 --- a/integration-tests/src/teardown.ts +++ b/integration-tests/src/teardown.ts @@ -4,7 +4,7 @@ import path from 'path'; module.exports = async () => { try { const pathToDataDir = path.join(__dirname, "/test-data"); - execSync("pkill rly") + execSync("pkill relayer") execSync("pkill terrad") execSync("pkill terrad") execSync(`rm -r ${pathToDataDir}`)