Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration tests to local net #74

Merged
merged 19 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ scripts/logs/*.log
scripts/logs/*/*.log
scripts-local/state
scripts-local/logs
scripts-local/test-utils/state/
scripts/temp.sh
scripts/testnet/*/state/keys.txt
scripts/tests/validator_selection
Expand Down
14 changes: 3 additions & 11 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
[submodule "scripts/tests/bats"]
path = scripts/tests/bats
url = https://github.com/bats-core/bats-core.git
[submodule "scripts/tests/test_helper/bats-support"]
path = scripts/tests/test_helper/bats-support
url = https://github.com/bats-core/bats-support.git
[submodule "scripts/tests/test_helper/bats-assert"]
path = scripts/tests/test_helper/bats-assert
url = https://github.com/bats-core/bats-assert.git
[submodule "deps/interchain-queries"]
path = deps/interchain-queries
url = git@github.com:Stride-Labs/interchain-queries.git
branch = main
[submodule "deps/hermes"]
path = deps/hermes
url = git@github.com:informalsystems/ibc-rs.git
branch = 4e83aae8afdc9a88a
branch = 4e83aae8a
[submodule "deps/gaia"]
path = deps/gaia
url = git@github.com:Stride-Labs/gaia.git
branch = v7.0.2-pinned
branch = bfb8f8ceb
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ test-cover:
@go test -mod=readonly -race -coverprofile=coverage.out -covermode=atomic ./x/$(module)/...

test-integration:
sh scripts-local/tests/run_all_tests.sh

test-integration-docker:
sh scripts/tests/run_all_tests.sh

###############################################################################
Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ func NewStrideApp(
keys[recordsmoduletypes.MemStoreKey],
app.GetSubspace(recordsmoduletypes.ModuleName),
scopedRecordsKeeper,
app.AccountKeeper,
)
recordsModule := recordsmodule.NewAppModule(appCodec, app.RecordsKeeper, app.AccountKeeper, app.BankKeeper)

Expand Down
8 changes: 8 additions & 0 deletions proto/epochs/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ service Query {
returns (QueryCurrentEpochResponse) {
option (google.api.http).get = "/Stridelabs/stride/epochs/current_epoch";
}
// CurrentEpoch provide current epoch of specified identifier
rpc EpochInfo(QueryEpochInfoRequest)
returns (QueryEpochInfoResponse) {
option (google.api.http).get = "/Stridelabs/stride/epochs/epoch_info";
}
}

message QueryEpochsInfoRequest {
Expand All @@ -33,6 +38,9 @@ message QueryEpochsInfoResponse {
message QueryCurrentEpochRequest { string identifier = 1; }
message QueryCurrentEpochResponse { int64 current_epoch = 1; }

message QueryEpochInfoRequest { string identifier = 1; }
message QueryEpochInfoResponse { EpochInfo epoch = 1 [ (gogoproto.nullable) = false ]; }

// syntax = "proto3";
// package Stridelabs.stride.epochs;

Expand Down
3 changes: 0 additions & 3 deletions scripts-local/account_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ GAIA_ADDRESS=$($GAIA_CMD keys show $GAIA_VAL_ACCT --keyring-backend test -a)

HERMES_STRIDE_ADDRESS=$($STRIDE_CMD keys show $HERMES_STRIDE_ACCT --keyring-backend test -a)
HERMES_GAIA_ADDRESS=$($GAIA_CMD keys show $HERMES_GAIA_ACCT --keyring-backend test -a)

GAIA_DELEGATE_VAL='cosmosvaloper1pcag0cj4ttxg8l7pcg0q4ksuglswuuedadj7ne'
GAIA_DELEGATE_VAL_2='cosmosvaloper133lfs9gcpxqj6er3kx605e3v9lqp2pg5syhvsz'
4 changes: 2 additions & 2 deletions scripts-local/check_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -eu

echo "Checking executable dependencies... ";
DEPENDENCIES="jq"
DEPENDENCIES="jq bats"
deps=0
for name in ${DEPENDENCIES}
do
Expand All @@ -23,6 +23,6 @@ for module in ${MODULES};
do
[ "$(ls -A ./deps/${module})" ] || { echo "\n * $module is required to run this script;";deps=1; }
done
[[ $deps -ne 1 ]] && echo "OK\n" || { echo "\nInstall the dependency modules with \"git submodule update --init\"...\n"; }
[[ $deps -ne 1 ]] && echo "OK\n" || { echo "\nInstall the dependency modules with \"git submodule update --init && git submodule update --recursive\"...\n"; }


5 changes: 5 additions & 0 deletions scripts-local/init_stride.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ main_config=$STATE/$STRIDE_NODE_NAME/config/genesis.json
# NOTE: If you add new epochs, these indexes will need to be updated
jq '.app_state.epochs.epochs[$epochIndex].duration = $epochLen' --arg epochLen $DAY_EPOCH_LEN --argjson epochIndex $DAY_EPOCH_INDEX $main_config > json.tmp && mv json.tmp $main_config
jq '.app_state.epochs.epochs[$epochIndex].duration = $epochLen' --arg epochLen $STRIDE_EPOCH_LEN --argjson epochIndex $STRIDE_EPOCH_INDEX $main_config > json.tmp && mv json.tmp $main_config
jq '.app_state.stakeibc.params.rewards_interval = $interval' --arg interval $INTERVAL_LEN $main_config > json.tmp && mv json.tmp $main_config
jq '.app_state.stakeibc.params.delegate_interval = $interval' --arg interval $INTERVAL_LEN $main_config > json.tmp && mv json.tmp $main_config
jq '.app_state.stakeibc.params.deposit_interval = $interval' --arg interval $INTERVAL_LEN $main_config > json.tmp && mv json.tmp $main_config
jq '.app_state.stakeibc.params.redemption_rate_interval = $interval' --arg interval $INTERVAL_LEN $main_config > json.tmp && mv json.tmp $main_config
jq '.app_state.stakeibc.params.reinvest_interval = $interval' --arg interval $INTERVAL_LEN $main_config > json.tmp && mv json.tmp $main_config

# add validator account
echo $STRIDE_VAL_MNEMONIC | $STRIDE_CMD keys add $STRIDE_VAL_ACCT --recover --keyring-backend=test
Expand Down
19 changes: 18 additions & 1 deletion scripts-local/start_network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
set -eu
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )


source $SCRIPT_DIR/vars.sh


mkdir -p $SCRIPT_DIR/logs

CACHE="${1:-false}"
Expand All @@ -27,6 +29,7 @@ for log in $STRIDE_LOGS $GAIA_LOGS $GAIA_LOGS_2 $HERMES_LOGS $ICQ_LOGS; do
touch $log
done


if [ "$CACHE" != "true" ]; then
# If not caching, initialize state for Stride, Gaia, and relayers
sh ${SCRIPT_DIR}/init_stride.sh
Expand Down Expand Up @@ -95,12 +98,26 @@ if [ "$CACHE" != "true" ]; then
# Submit a transaction on stride to register the gaia host zone
echo "Creating host zone..."
$STRIDE_CMD tx stakeibc register-host-zone \
connection-0 $ATOM cosmos $IBCATOM channel-0 3 \
connection-0 $ATOM_DENOM $IBC_ATOM_DENOM channel-0 3 \
--chain-id $STRIDE_CHAIN --home $STATE/stride \
--keyring-backend test --from $STRIDE_VAL_ACCT --gas 1000000 -y
fi
# sleep a while longer to wait for ICA accounts to set up
sleep 60

echo "Registering validators on host zone..."

CSLEEP 10
$GAIA_CMD tx bank send gval1 $GAIA_VAL_2_ADDR 10000uatom --chain-id $GAIA_CHAIN --keyring-backend test -y
CSLEEP 10
$GAIA_CMD tx bank send gval1 $GAIA_VAL_3_ADDR 10000uatom --chain-id $GAIA_CHAIN --keyring-backend test -y

CSLEEP 10
$STRIDE_CMD tx stakeibc add-validator GAIA gval1 $GAIA_DELEGATE_VAL 10 5 --chain-id $STRIDE_CHAIN --keyring-backend test --from $STRIDE_VAL_ACCT -y
CSLEEP 30
$STRIDE_CMD tx stakeibc add-validator GAIA gval2 $GAIA_DELEGATE_VAL_2 10 10 --chain-id $STRIDE_CHAIN --keyring-backend test --from $STRIDE_VAL_ACCT -y
CSLEEP 30


# Add more detailed log files
$SCRIPT_DIR/create_logs.sh &
File renamed without changes.
9 changes: 9 additions & 0 deletions scripts-local/test-utils/2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### LIQ STAKE + EXCH RATE TEST
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# import dependencies
source ${SCRIPT_DIR}/../account_vars.sh

$STRIDE_CMD tx stakeibc liquid-stake 10000 $ATOM_DENOM --keyring-backend test --from $STRIDE_VAL_ACCT -y --chain-id $STRIDE_CHAIN -y
echo "Waiting for liquid staked tokens to be delegated..."
CSLEEP 60
# $STRIDE_CMD tx stakeibc liquid-stake 10000 $ATOM_DENOM --keyring-backend test --from $STRIDE_VAL_ACCT -y --chain-id $STRIDE_CHAIN
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions scripts-local/test-utils/run_any_cli_command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### LIQ STAKE + EXCH RATE TEST
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# import dependencies
source ${SCRIPT_DIR}/../account_vars.sh

$GAIA_CMD q staking delegation $DELEGATION_ICA_ADDR $GAIA_DELEGATE_VAL
9 changes: 0 additions & 9 deletions scripts-local/tests/2.sh

This file was deleted.

Loading