From a0683920d3c819645635ef8ecfbdb7677a8a3e5a Mon Sep 17 00:00:00 2001 From: colmazia Date: Thu, 5 Oct 2023 13:27:51 +0700 Subject: [PATCH] add test_script for chain upgrading --- scripts/test_script/open_vote_proposal_25.sh | 16 ++++++++++++++ scripts/test_script/runbook_24_25.sh | 11 ++++++++++ scripts/test_script/runbook_25_26.sh | 23 ++++++++++++++++++++ scripts/test_script/setup_chains.sh | 20 +++++++++++++++++ scripts/test_script/setup_voting_period.sh | 20 +++++++++++++++++ scripts/test_script/start_cosmovisor.sh | 5 +++++ 6 files changed, 95 insertions(+) create mode 100755 scripts/test_script/open_vote_proposal_25.sh create mode 100755 scripts/test_script/runbook_24_25.sh create mode 100755 scripts/test_script/runbook_25_26.sh create mode 100755 scripts/test_script/setup_chains.sh create mode 100755 scripts/test_script/setup_voting_period.sh create mode 100755 scripts/test_script/start_cosmovisor.sh diff --git a/scripts/test_script/open_vote_proposal_25.sh b/scripts/test_script/open_vote_proposal_25.sh new file mode 100755 index 000000000..0743ce68d --- /dev/null +++ b/scripts/test_script/open_vote_proposal_25.sh @@ -0,0 +1,16 @@ +CURR_HEIGHT=$(bandd query block | jq -r '.block.header.height') + +UPGRADE_HEIGHT=$(($CURR_HEIGHT+60)) + +TX_HASH=$(bandd tx gov submit-proposal software-upgrade $1 \ + --title upgrade --upgrade-info upgrade \ + --description upgrade \ + --upgrade-height $UPGRADE_HEIGHT --deposit 1000000000uband \ + --from requester --chain-id bandchain \ + -y --keyring-backend test --gas-prices 0.0025uband -b sync --output json| jq '.txhash'| tr -d '"') + +sleep 3 + +PROPOSAL_ID=$(bandd query tx $TX_HASH --output=json | jq -r '.raw_log | fromjson | .[] | .events[] | select(.type=="submit_proposal") | .attributes[] | select(.key=="proposal_id") | .value') + +bandd tx gov vote $PROPOSAL_ID VOTE_OPTION_YES --from validator --keyring-backend test --gas-prices 0.0025uband -y -b sync --chain-id bandchain diff --git a/scripts/test_script/runbook_24_25.sh b/scripts/test_script/runbook_24_25.sh new file mode 100755 index 000000000..9edd245d3 --- /dev/null +++ b/scripts/test_script/runbook_24_25.sh @@ -0,0 +1,11 @@ +git checkout v2.4.1 +make install + +./scripts/generate_genesis.sh +./scripts/test_script/setup_voting_period.sh 60s + +./scripts/test_script/setup_chains.sh /Users/ongart/Development/band/chain v2.4.1 v2.5.4 v2_5 + +./scripts/test_script/start_cosmovisor.sh + +# then run the open_vote_proposal_25.sh diff --git a/scripts/test_script/runbook_25_26.sh b/scripts/test_script/runbook_25_26.sh new file mode 100755 index 000000000..024728976 --- /dev/null +++ b/scripts/test_script/runbook_25_26.sh @@ -0,0 +1,23 @@ +git checkout v2.5.4 +make install + +./scripts/generate_genesis.sh +./scripts/test_script/setup_voting_period.sh 60s + +sed -i -e \ + "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0.0025uband\"/" \ + ~/.band/config/app.toml + +sed -i -e \ + '/\[api\]/,+10 s/enable = .*/enable = true/' \ + ~/.band/config/app.toml + +sed -i -e \ + '/\[mempool\]/,+10 s/version = .*/version = \"v1\"/' \ + ~/.band/config/config.toml + +./scripts/test_script/setup_chains.sh /Users/ongart/Development/band/chain v2.5.4 cosmos-sdk-v0.47 v2_6 + +./scripts/test_script/start_cosmovisor.sh + +# then run the open_vote_proposal_25.sh diff --git a/scripts/test_script/setup_chains.sh b/scripts/test_script/setup_chains.sh new file mode 100755 index 000000000..e1c602c46 --- /dev/null +++ b/scripts/test_script/setup_chains.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# make new version binary +cd $1 +git checkout $3 +make install + +# setup cosmovisor for upgrade version +mkdir -p $HOME/.band/cosmovisor/upgrades/$4/bin +cp $HOME/go/bin/bandd $HOME/.band/cosmovisor/upgrades/$4/bin + +# make old version binary +git checkout $2 +make install + +# setup cosmovisor for genesis version +mkdir -p $HOME/.band/cosmovisor/genesis/bin +mkdir -p $HOME/.band/cosmovisor/upgrades +cp $HOME/go/bin/bandd $HOME/.band/cosmovisor/genesis/bin + diff --git a/scripts/test_script/setup_voting_period.sh b/scripts/test_script/setup_voting_period.sh new file mode 100755 index 000000000..d1cd27334 --- /dev/null +++ b/scripts/test_script/setup_voting_period.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +new_voting_period=$1 +genesis_file="$HOME/.band/config/genesis.json" + +# update voting period for testing +voting_period_value=$(jq -r '.app_state.gov.params.voting_period' $genesis_file) +if [ "$voting_period_value" != "null" ]; then + cat <<< $(jq --arg new_voting_period "$new_voting_period" '.app_state.gov.params.voting_period = $new_voting_period' $genesis_file) > $genesis_file +fi + +voting_period_value=$(jq -r '.app_state.gov.voting_params.voting_period' $genesis_file) +if [ "$voting_period_value" != "null" ]; then + cat <<< $(jq --arg new_voting_period "$new_voting_period" '.app_state.gov.voting_params.voting_period = $new_voting_period' $genesis_file) > $genesis_file +fi + +voting_period_value=$(jq -r '.app_state.council.params.voting_period' $genesis_file) +if [ "$voting_period_value" != "null" ]; then + cat <<< $(jq --arg new_voting_period "$new_voting_period" '.app_state.council.params.voting_period = $new_voting_period' $genesis_file) > $genesis_file +fi diff --git a/scripts/test_script/start_cosmovisor.sh b/scripts/test_script/start_cosmovisor.sh new file mode 100755 index 000000000..9163fdeae --- /dev/null +++ b/scripts/test_script/start_cosmovisor.sh @@ -0,0 +1,5 @@ +echo "export DAEMON_NAME=bandd" >> ~/.profile +echo "export DAEMON_HOME=$HOME/.band" >> ~/.profile +source ~/.profile + +cosmovisor run start