Skip to content

Commit 30d4d84

Browse files
committed
feat: add e2e test for change param proposal of tokenfactory
1 parent ea10995 commit 30d4d84

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"title": "Denom creation amount param change",
3+
"description": "Denom creation amount param change",
4+
"changes": [
5+
{
6+
"subspace": "tokenfactory",
7+
"key": "DenomCreationFee",
8+
"value": [
9+
{
10+
"amount": "1000",
11+
"denom": "orai"
12+
}
13+
]
14+
}
15+
],
16+
"deposit": "1000000000orai"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
set -ux
4+
5+
CHAIN_ID=${CHAIN_ID:-testing}
6+
USER="validator1"
7+
NODE_HOME=${NODE_HOME:-"$HOME/.oraid/validator1"}
8+
ARGS="--from $USER --chain-id $CHAIN_ID -y --keyring-backend test --gas auto --gas-adjustment 1.5 -b sync --home $NODE_HOME"
9+
VALIDATOR2_ARGS="--from validator2 --chain-id $CHAIN_ID -y --keyring-backend test --gas auto --gas-adjustment 1.5 -b sync --home $HOME/.oraid/validator2"
10+
HIDE_LOGS="/dev/null"
11+
12+
DEFAULT_AMOUNT=100000000
13+
CHANGE_AMOUNT=1000
14+
CHANGE_KEY="DenomCreationFee"
15+
CHANGE_VALUE="[{\"amount\":\"$CHANGE_AMOUNT\",\"denom\":\"orai\"}]"
16+
PROPOSAL_FILE=${PROPOSAL_FILE:-"$PWD/scripts/json/tokenfactory-proposal.json"}
17+
18+
fee_params_denom=$(oraid query tokenfactory params --output json | jq '.params.denom_creation_fee[0].denom')
19+
if ! [[ $fee_params_denom =~ "orai" ]]; then
20+
echo "Tokenfactory change params tests failed. The tokenfactory fee params denom is not orai"
21+
exit 1
22+
fi
23+
24+
fee_params_amount=$(oraid query tokenfactory params --output json | jq '.params.denom_creation_fee[0].amount | tonumber')
25+
if ! [[ $fee_params_amount =~ $DEFAULT_AMOUNT ]]; then
26+
echo "Tokenfactory change params tests failed. The tokenfactory fee params amount is not equal default amount"
27+
exit 1
28+
fi
29+
30+
update_proposal() {
31+
cat $PROPOSAL_FILE | jq "$1" >$PWD/scripts/json/temp_proposal.json && mv $PWD/scripts/json/temp_proposal.json $PROPOSAL_FILE
32+
}
33+
34+
# update amount proposal.json
35+
update_proposal ".changes[0].key=$CHANGE_KEY"
36+
update_proposal ".changes[0].value=$CHANGE_VALUE"
37+
38+
store_ret=$(oraid tx tokenfactory param-change $PROPOSAL_FILE $ARGS --output json)
39+
txhash=$(echo $store_ret | jq -r '.txhash')
40+
# sleep 2s before vote to wait for tx confirm
41+
sleep 2
42+
proposal_id=$(oraid query tx $txhash --output json | jq -r '.events[4].attributes[] | select(.key | contains("proposal_id")).value')
43+
oraid tx gov vote $proposal_id yes $ARGS > $HIDE_LOGS && oraid tx gov vote $proposal_id yes $VALIDATOR2_ARGS > $HIDE_LOGS
44+
45+
# sleep to wait til the proposal passes
46+
echo "Sleep til the proposal passes..."
47+
sleep 10
48+
49+
echo "Query new creation amount"
50+
fee_params_amount=$(oraid query tokenfactory params --output json | jq '.params.denom_creation_fee[0].amount | tonumber')
51+
if ! [[ $fee_params_amount =~ $CHANGE_AMOUNT ]]; then
52+
echo "Tokenfactory change params tests failed. The tokenfactory fee params change proposal is not passed"
53+
exit 1
54+
fi
55+
56+
echo "Token factory change param proposal test passed"

0 commit comments

Comments
 (0)