-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for positive case of upgrade process (#268)
* Change entrypoints for tests * Adopt according to the lat changes in Docker compose files * Fix env param exporting * Change version_to parameter getting * Fix version inserting * Add gen_node_config script from merge commit * Fix test.yml * Fix node_configs generation after merging * Add /bin/bash into common.sh * Fix typo Co-authored-by: @Eengineer1 @askolesov @ankurdotb Signed-off-by: Andrew Nikitin <[email protected]>
- Loading branch information
Andrew Nikitin
committed
Feb 25, 2022
1 parent
471500d
commit 54ec64f
Showing
9 changed files
with
401 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CHEQD_VERSION="latest" | ||
CHEQD_IMAGE_NAME="cheqd-node" | ||
MOUNT_POINT="." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,4 +136,4 @@ do | |
popd | ||
done | ||
|
||
popd # node_configs | ||
popd # node_configs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
|
||
set -euox pipefail | ||
|
||
DOCKER_COMPOSE_DIR="../networks/docker-compose-localnet" | ||
CHEQD_IMAGE_FROM="ghcr.io/cheqd/cheqd-node:0.4.0" | ||
CHEQD_IMAGE_TO="cheqd-node" | ||
CHEQD_VERSION_TO=`echo $(git describe --always --tag --match "v*") | sed 's/^v//'` | ||
git describe --debug | ||
UPGRADE_NAME="v0.4" | ||
VOTING_PERIOD=30 | ||
EXPECTED_BLOCK_SECOND=5 | ||
EXTRA_BLOCKS=5 | ||
UPGRADE_HEIGHT=$(echo $VOTING_PERIOD/$EXPECTED_BLOCK_SECOND+$EXTRA_BLOCKS | bc) | ||
DEPOSIT_AMOUNT=10000000 | ||
CHAIN_ID="cheqd" | ||
CHEQD_USER="cheqd" | ||
|
||
# cheqd_noded docker wrapper | ||
|
||
cheqd_noded_docker() { | ||
docker run --rm \ | ||
-v "$(pwd)":"/cheqd" \ | ||
--network host \ | ||
-u root \ | ||
-e HOME=/cheqd \ | ||
${CHEQD_IMAGE_FROM} "$@" | ||
} | ||
|
||
# Parameters | ||
# $1 - Name of container to run command inside | ||
# $2 - The full command to run | ||
function docker_exec () { | ||
NODE_CONTAINER="$1" | ||
|
||
docker exec -u $CHEQD_USER $NODE_CONTAINER "${@:2}" | ||
} | ||
|
||
# Parameters | ||
# $1 - Version of base image | ||
# $2 - Root path for making directories for volumes | ||
function docker_compose_up () { | ||
CURR_DIR=$(pwd) | ||
MOUNT_POINT="$2" | ||
pushd "node_configs/node0" | ||
export NODE_0_ID=$(cheqd_noded_docker tendermint show-node-id | sed 's/\r//g') | ||
export CHEQD_IMAGE_NAME="$1" | ||
export MOUNT_POINT=$MOUNT_POINT | ||
docker-compose -f ../../$DOCKER_COMPOSE_DIR/docker-compose.yml --env-file ../../$DOCKER_COMPOSE_DIR/.env up -d | ||
pushd $CURR_DIR | ||
} | ||
|
||
# Stop docker-compose | ||
function docker_compose_down () { | ||
docker-compose -f $DOCKER_COMPOSE_DIR/docker-compose.yml --env-file $DOCKER_COMPOSE_DIR/.env down | ||
} | ||
|
||
# Clean environment | ||
function clean_env () { | ||
rm -rf node_configs | ||
} | ||
|
||
# Run command using local generated keys from node_configs/client | ||
function local_client_exec () { | ||
cheqd_noded_docker "$@" --home node_configs/client/.cheqdnode/ --keyring-backend test | ||
} | ||
|
||
function make_777 () { | ||
sudo chmod -R 777 node_configs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
#!/bin/bash | ||
|
||
# Generates configurations for 4 nodes. | ||
|
||
set -euox pipefail | ||
|
||
. common.sh | ||
|
||
# sed in macos requires extra argument | ||
|
||
sed_extension='' | ||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | ||
sed_extension='' | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
sed_extension='.orig' | ||
fi | ||
|
||
|
||
# Parameters | ||
# $1 - The full parameter name | ||
# $2 - Value | ||
# $3 - Path to genesis file | ||
edit_genesis () { | ||
PARAMETER_NAME=$1 | ||
VALUE=$2 | ||
GENESIS_PATH=$3 | ||
jq "${PARAMETER_NAME} = \"${VALUE}\"" $GENESIS_PATH > /tmp/1 && mv /tmp/1 $GENESIS_PATH | ||
} | ||
|
||
# We use local copy of this function because of using -u root for allowing files creation inside the | ||
cheqd_noded_docker() { | ||
docker run --rm \ | ||
-v "$(pwd)":"/cheqd" \ | ||
--network host \ | ||
--entrypoint "cheqd-noded" \ | ||
-u root \ | ||
${CHEQD_IMAGE_FROM} "$@" --home /cheqd/.cheqdnode | ||
} | ||
|
||
VALIDATORS_COUNT="4" | ||
OBSERVERS_COUNT="2" | ||
|
||
NODE_CONFIGS_DIR="node_configs" | ||
rm -rf $NODE_CONFIGS_DIR | ||
mkdir $NODE_CONFIGS_DIR | ||
pushd $NODE_CONFIGS_DIR | ||
|
||
echo "Generating validator keys..." | ||
|
||
for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) | ||
do | ||
NODE_HOME="node$i" | ||
mkdir $NODE_HOME | ||
pushd $NODE_HOME | ||
|
||
echo "[Validator $i] Generating key..." | ||
|
||
cheqd_noded_docker init "node$i" --chain-id $CHAIN_ID | ||
sudo chown -R $USER:$USER . | ||
echo "$(cheqd_noded_docker tendermint show-node-id)" > node_id.txt | ||
echo "$(cheqd_noded_docker tendermint show-validator)" > node_val_pubkey.txt | ||
|
||
echo "Setting minimum fee price..." | ||
|
||
sed -i $sed_extension 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' .cheqdnode/config/app.toml | ||
|
||
popd | ||
done | ||
|
||
|
||
OPERATORS_HOME="client" | ||
mkdir $OPERATORS_HOME | ||
pushd $OPERATORS_HOME | ||
|
||
echo "Initializing genesis..." | ||
cheqd_noded_docker init dummy_node --chain-id $CHAIN_ID | ||
sudo chown -R $USER:$USER . | ||
sed -i $sed_extension 's/"stake"/"ncheq"/' .cheqdnode/config/genesis.json | ||
|
||
echo "Generating operator keys..." | ||
|
||
for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) | ||
do | ||
cheqd_noded_docker keys add "operator$i" --keyring-backend "test" | ||
sudo chown -R $USER:$USER . | ||
done | ||
|
||
echo "Creating genesis accounts..." | ||
|
||
for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) | ||
do | ||
cheqd_noded_docker add-genesis-account "operator$i" 20000000000000000ncheq --keyring-backend "test" | ||
done | ||
|
||
echo "Creating genesis validators..." | ||
|
||
for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) | ||
do | ||
NODE_HOME="../node$i" | ||
pushd $NODE_HOME | ||
|
||
NODE_ID=$(cheqd_noded_docker tendermint show-node-id) | ||
NODE_VAL_PUBKEY=$(cheqd_noded_docker tendermint show-validator) | ||
|
||
popd | ||
|
||
cheqd_noded_docker gentx "operator$i" 1000000000000000ncheq --chain-id $CHAIN_ID --node-id $NODE_ID --pubkey $NODE_VAL_PUBKEY --keyring-backend "test" | ||
done | ||
|
||
echo "Collecting them..." | ||
|
||
cheqd_noded_docker collect-gentxs | ||
cheqd_noded_docker validate-genesis | ||
|
||
echo "Propagating genesis to nodes..." | ||
|
||
# Edit voting parameters | ||
edit_genesis ".app_state.gov.deposit_params.max_deposit_period" "${VOTING_PERIOD}s" .cheqdnode/config/genesis.json | ||
edit_genesis ".app_state.gov.voting_params.voting_period" "${VOTING_PERIOD}s" .cheqdnode/config/genesis.json | ||
|
||
for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) | ||
do | ||
NODE_HOME="../node$i" | ||
|
||
cp ".cheqdnode/config/genesis.json" "$NODE_HOME/.cheqdnode/config/" | ||
done | ||
|
||
|
||
popd # operators' home | ||
|
||
|
||
echo "##### Setting up observers..." | ||
|
||
for ((i=0 ; i<$OBSERVERS_COUNT ; i++)) | ||
do | ||
NODE_HOME="observer$i" | ||
|
||
mkdir $NODE_HOME | ||
pushd $NODE_HOME | ||
|
||
echo "##### [Observer $i] Generating keys..." | ||
cheqd_noded_docker init "node$i" --chain-id $CHAIN_ID | ||
sudo chown -R $USER:$USER . | ||
|
||
echo "##### [Observer $i] Exporting public keys..." | ||
echo "$(cheqd_noded_docker tendermint show-node-id)" > node_id.txt | ||
echo "$(cheqd_noded_docker tendermint show-validator)" > node_val_pubkey.txt | ||
|
||
echo "##### [Observer $i] Loading genesis..." | ||
OPERATORS_HOME="../client" | ||
cp "$OPERATORS_HOME/.cheqdnode/config/genesis.json" ".cheqdnode/config/" | ||
|
||
echo "##### [Observer $i] Setting min gas prices..." | ||
sed -i $sed_extension 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' .cheqdnode/config/app.toml | ||
|
||
popd | ||
done | ||
|
||
popd # node_configs |
Oops, something went wrong.