Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
chore: add e2e docker upgrade tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamle2 committed Jul 5, 2024
1 parent c28b045 commit 07c250c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions orai/scripts/e2e-docker-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ if ! [[ $evm_denom =~ "aorai" ]] ; then
fi

NODE_HOME=$VALIDATOR_HOME USER=validator1 WASM_PATH=$WASM_PATH bash $PWD/scripts/tests-0.42.1/test-gasless-docker.sh
NODE_HOME=$VALIDATOR_HOME USER=validator1 WASM_PATH=$WASM_PATH bash $PWD/scripts/tests-0.42.1/test-tokenfactory-docker.sh

echo "Tests Passed"
55 changes: 55 additions & 0 deletions orai/scripts/tests-0.42.1/test-tokenfactory-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

set -eu

CHAIN_ID=${CHAIN_ID:-testing}
USER=${USER:-tupt}
NODE_HOME=${NODE_HOME:-"$PWD/.oraid"}
ARGS="--from $USER --chain-id testing -y --keyring-backend test --fees 200orai --gas auto --gas-adjustment 1.5 -b block --home $NODE_HOME"
docker_command="docker-compose -f $PWD/docker-compose-e2e-upgrade.yml exec"
validator1_command="$docker_command validator1 bash -c"

# prepare a new contract for gasless
fee_params=`$validator1_command "oraid query tokenfactory params --output json | jq '.params.denom_creation_fee[0].denom'"`
if ! [[ $fee_params =~ "orai" ]] ; then
echo "The tokenfactory fee params is not orai"; exit 1
fi

# try creating a new denom
denom_name="usdt"
$validator1_command "oraid tx tokenfactory create-denom $denom_name $ARGS"

# try querying list denoms afterwards
user_address=`$validator1_command "oraid keys show $USER --home $NODE_HOME --keyring-backend test -a"`
first_denom_before_trim=`$validator1_command "oraid query tokenfactory denoms-from-creator $user_address --output json | jq '.denoms[0]'"`
first_denom=$(echo $first_denom_before_trim | tr -d '"')
echo "first denom: $first_denom"

if ! [[ $first_denom =~ "factory/$user_address/$denom_name" ]] ; then
echo "The tokenfactory denom does not match the created denom"; exit 1
fi

admin=`$validator1_command "oraid query tokenfactory denom-authority-metadata $first_denom --output json | jq '.authority_metadata.admin'"`
echo "admin: $admin"

if ! [[ $admin =~ $user_address ]] ; then
echo "The tokenfactory admin does not match the creator"; exit 1
fi

# try mint
$validator1_command "oraid tx tokenfactory mint 10$first_denom $ARGS"

# query balance after mint
tokenfactory_balance=`$validator1_command "oraid query bank balances $user_address --denom=$first_denom --output json | jq '.amount | tonumber'"`
if [[ $tokenfactory_balance -ne 10 ]] ; then
echo "The tokenfactory balance does not increase after mint"; exit 1
fi

# try burn
$validator1_command "oraid tx tokenfactory burn 10$first_denom $ARGS"
tokenfactory_balance=`$validator1_command "oraid query bank balances $user_address --denom=$first_denom --output json | jq '.amount | tonumber')"`
if [[ $tokenfactory_balance -ne 0 ]] ; then
echo "The tokenfactory balance does not decrease after burn"; exit 1
fi

echo "Tokenfactory tests passed!"
2 changes: 1 addition & 1 deletion orai/scripts/tests-0.42.1/test-tokenfactory.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -eux
set -eu

CHAIN_ID=${CHAIN_ID:-testing}
USER=${USER:-tupt}
Expand Down

0 comments on commit 07c250c

Please sign in to comment.