Skip to content

Commit

Permalink
feat: test community fund
Browse files Browse the repository at this point in the history
  • Loading branch information
duvbell committed Jan 22, 2024
1 parent 268f2d3 commit 71e9bd9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
57 changes: 57 additions & 0 deletions scripts/create-community-pool-spend-msg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
BINARY=migalood
CONTINUE=${CONTINUE:-"false"}
HOME_DIR=$(pwd)/mytestnet
SCRIPTS_FOLDER=$(pwd)/scripts
ENV=${ENV:-""}

CHAIN_ID="localmigaloo"
KEYRING="test"
KEY="test0"
KEY1="test1"
KEY2="test2"
DENOM=${2:-uwhale}

COMMUNITY_POOL_AMOUNT=1000000000

## Test0 fund community pool
$BINARY tx distribution fund-community-pool $COMMUNITY_POOL_AMOUNT$DENOM --from $KEY --keyring-backend $KEYRING --chain-id $CHAIN_ID --home $HOME_DIR -y

## Show receipient balance before proposal.
recipient=$($BINARY keys show $KEY2 -a --keyring-backend $KEYRING --home $HOME_DIR)

PRE_AMOUNT=$($BINARY query bank balances $recipient --chain-id $CHAIN_ID --home $HOME_DIR -o json | jq -r ".balances[0].amount")
echo "Recipient: $recipient"
echo "Pre receipient amount: $PRE_AMOUNT"

## Test1 Create a community pool spend message, receipient is test2
proposal_file=$SCRIPTS_FOLDER/proposal.json
cat << EOF > $proposal_file
{
"title": "Community Spend: Liquid stake",
"description": "This proposal is to request funds for liquid staking development.",
"recipient": "$recipient",
"amount": "$COMMUNITY_POOL_AMOUNT$DENOM",
"deposit": "1000000$DENOM"
}
EOF

echo "Proposal file: $proposal_file"
sleep 3
$BINARY tx gov submit-legacy-proposal community-pool-spend $proposal_file --from test1 --keyring-backend test --chain-id $CHAIN_ID --home $HOME_DIR -y


## Validator vote yes
sleep 3
$BINARY tx gov vote 1 yes --from test0 --keyring-backend test --chain-id $CHAIN_ID --home $HOME_DIR -y

## Check recipient balance after proposal.
sleep 20
POST_AMOUNT=$($BINARY query bank balances $recipient --chain-id $CHAIN_ID --home $HOME_DIR -o json | jq -r ".balances[0].amount")
## assert post amount
EXPECTED_POST_AMOUNT=$((PRE_AMOUNT + COMMUNITY_POOL_AMOUNT))
if [ "$POST_AMOUNT" -eq "$EXPECTED_POST_AMOUNT" ]; then
echo "Post recipient amount is as expected: $POST_AMOUNT"
else
echo "Error: Post recipient amount $POST_AMOUNT does not match expected amount $EXPECTED_POST_AMOUNT"
exit 1
fi
1 change: 1 addition & 0 deletions scripts/local_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ update_test_genesis '.app_state["staking"]["params"]["bond_denom"]="'$DENOM'"'
# enable rest server and swagger
$SED_BINARY -i '0,/enable = false/s//enable = true/' $HOME_DIR/config/app.toml
$SED_BINARY -i 's/swagger = false/swagger = true/' $HOME_DIR/config/app.toml
$SED_BINARY -i -e 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' $HOME_DIR/config/app.toml

# Sign genesis transaction
$BINARY gentx $KEY "1000000${DENOM}" --commission-rate=$COMMISSION_RATE --commission-max-rate=$COMMISSION_MAX_RATE --keyring-backend $KEYRING --chain-id $CHAIN_ID --home $HOME_DIR
Expand Down
7 changes: 7 additions & 0 deletions scripts/proposal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"title": "Community Spend: Liquid stake",
"description": "This proposal is to request funds for liquid staking development.",
"recipient": "migaloo1yun4uk2psqkzxghfrfmfkvdpnn7ujwymhpsttc",
"amount": "1000000000uwhale",
"deposit": "1000000uwhale"
}

0 comments on commit 71e9bd9

Please sign in to comment.