Skip to content

Commit

Permalink
Merge pull request #227 from terra-money/feat/v2.9/tests-relayer
Browse files Browse the repository at this point in the history
feat(v2.9):  automatically install relayer
  • Loading branch information
emidev98 authored Dec 8, 2023
2 parents 03830da + 58e7536 commit 0f3f665
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 25 deletions.
1 change: 1 addition & 0 deletions app/config/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,5 @@ const (
Upgrade2_6 = "v2.6"
Upgrade2_7 = "v2.7"
Upgrade2_8 = "v2.8"
Upgrade2_9 = "v2.9"
)
9 changes: 9 additions & 0 deletions app/upgrade_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
v2_6 "github.com/terra-money/core/v2/app/upgrades/v2.6"
v2_7 "github.com/terra-money/core/v2/app/upgrades/v2.7"
v2_8 "github.com/terra-money/core/v2/app/upgrades/v2.8"
v2_9 "github.com/terra-money/core/v2/app/upgrades/v2.9"
feesharetypes "github.com/terra-money/core/v2/x/feeshare/types"
tokenfactorytypes "github.com/terra-money/core/v2/x/tokenfactory/types"

Expand Down Expand Up @@ -84,6 +85,14 @@ func (app *TerraApp) RegisterUpgradeHandlers() {
app.GetAppCodec(),
),
)
app.Keepers.UpgradeKeeper.SetUpgradeHandler(
terraappconfig.Upgrade2_9,
v2_9.CreateUpgradeHandler(
app.GetModuleManager(),
app.GetConfigurator(),
app.GetAppCodec(),
),
)
}

func (app *TerraApp) RegisterUpgradeStores() {
Expand Down
18 changes: 18 additions & 0 deletions app/upgrades/v2.9/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v2_9

import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
cdc codec.Codec,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, cfg, fromVM)
}
}
4 changes: 2 additions & 2 deletions client/docs/config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"swagger": "2.0",
"info": {
"description": "Source code for <a target='_blank' href='https://github.com/terra-money/core'>Terra Core v2.8</a><br/>UI to interact with the blockchain <a target='_blank' href='https://station.terra.money/'>Station</a><br/>Create a DAO on Terra using <a target='_blank' href='https://enterprise.money/'>Enterprise</a><br/>Run on-chain automted jobs <a target='_blank' href='https://warp.money/'>Wrap</a><br/>Explore the network using <a target='_blank' href='https://terrasco.pe/'>TerraScope</a><br/>Anything you need to know about shared security on <a target='_blank' href='https://alliance.terra.money/'>Alliance Docs</a><br/>More info about the protocol on <a target='_blank' href='https://docs.terra.money/'>Terra Docs</a>",
"version": "v2.8"
"description": "Source code for <a target='_blank' href='https://github.com/terra-money/core'>Terra Core v2.9</a><br/>UI to interact with the blockchain <a target='_blank' href='https://station.terra.money/'>Station</a><br/>Create a DAO on Terra using <a target='_blank' href='https://enterprise.money/'>Enterprise</a><br/>Run on-chain automted jobs <a target='_blank' href='https://warp.money/'>Wrap</a><br/>Explore the network using <a target='_blank' href='https://terrasco.pe/'>TerraScope</a><br/>Anything you need to know about shared security on <a target='_blank' href='https://alliance.terra.money/'>Alliance Docs</a><br/>More info about the protocol on <a target='_blank' href='https://docs.terra.money/'>Terra Docs</a>",
"version": "v2.9"
},
"apis": [
{
Expand Down
4 changes: 2 additions & 2 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ swagger: '2.0'
info:
description: >-
Source code for <a target='_blank'
href='https://github.com/terra-money/core'>Terra Core v2.8</a><br/>UI to
href='https://github.com/terra-money/core'>Terra Core v2.9</a><br/>UI to
interact with the blockchain <a target='_blank'
href='https://station.terra.money/'>Station</a><br/>Create a DAO on Terra
using <a target='_blank'
Expand All @@ -14,7 +14,7 @@ info:
href='https://alliance.terra.money/'>Alliance Docs</a><br/>More info about
the protocol on <a target='_blank' href='https://docs.terra.money/'>Terra
Docs</a>
version: 'v2.8'
version: 'v2.9'
paths:
/terra/alliances:
get:
Expand Down
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-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@terra-money/core-integration-tests",
"version": "v2.8.0",
"version": "v2.9.0",
"description": "Integration tests for Core using feather.js",
"main": "index.ts",
"scripts": {
Expand All @@ -9,7 +9,7 @@
"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"
"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
4 changes: 2 additions & 2 deletions integration-tests/src/setup/chain-upgrade/chain-upgrade.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

OLD_VERSION=release/v2.7
OLD_VERSION=release/v2.8
UPGRADE_HEIGHT=20
CHAIN_ID=pisco-1
CHAIN_HOME=$(pwd)/chain-upgrade-data
DENOM=uluna
SOFTWARE_UPGRADE_NAME="v2.8"
SOFTWARE_UPGRADE_NAME="v2.9"
GOV_PERIOD="5s"

VAL_MNEMONIC_1="clock post desk civil pottery foster expand merit dash seminar song memory figure uniform spice circle try happy obvious trash crime hybrid hood cushion"
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 0f3f665

Please sign in to comment.