Skip to content

Commit

Permalink
feat(v2.9): automatically install relayer when not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 committed Dec 4, 2023
1 parent 1386d06 commit efe3fd8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
8 changes: 2 additions & 6 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/src/modules/wasm/ics20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ 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)
}

// 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,
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/setup/init-test-framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/src/setup/relayer/init-relayer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/[email protected]
fi

echo "Initializing $BINARY..."
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/teardown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down

0 comments on commit efe3fd8

Please sign in to comment.