Skip to content

Commit

Permalink
add test_script for chain upgrading
Browse files Browse the repository at this point in the history
  • Loading branch information
colmazia committed Oct 5, 2023
1 parent f503e97 commit a068392
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 0 deletions.
16 changes: 16 additions & 0 deletions scripts/test_script/open_vote_proposal_25.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions scripts/test_script/runbook_24_25.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions scripts/test_script/runbook_25_26.sh
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions scripts/test_script/setup_chains.sh
Original file line number Diff line number Diff line change
@@ -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

20 changes: 20 additions & 0 deletions scripts/test_script/setup_voting_period.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions scripts/test_script/start_cosmovisor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
echo "export DAEMON_NAME=bandd" >> ~/.profile
echo "export DAEMON_HOME=$HOME/.band" >> ~/.profile
source ~/.profile

cosmovisor run start

0 comments on commit a068392

Please sign in to comment.