forked from sei-protocol/sei-chain
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test for place order and time-locked token contract (s…
…ei-protocol#836) * Add integration test for place order and register contracts * Fix some comments * Add aws region * Add AWS keys and secret * Add integration test for token claim contract * Fix the workflow build file * Add more integration tests * Extend timeout * Fix migration testing logic * Change vote period to be 2 --------- Co-authored-by: Yiming Zang <yzang@twitter.com>
- Loading branch information
Showing
18 changed files
with
552 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
seidbin=$(which ~/go/bin/seid | tr -d '"') | ||
keyname=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].name" | tr -d '"') | ||
chainid=$($seidbin status | jq ".NodeInfo.network" | tr -d '"') | ||
seihome=$(git rev-parse --show-toplevel | tr -d '"') | ||
contract_name=$1 | ||
if [[ $# -ne 1 ]]; | ||
then | ||
echo "Need to provide a contract name (mars,saturn,venus)" | ||
exit 1 | ||
fi | ||
|
||
cd $seihome || exit | ||
echo "Deploying $contract_name contract..." | ||
|
||
# store | ||
echo "Storing contract..." | ||
store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/"$contract_name".wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json) | ||
contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value') | ||
echo "Got contract id $contract_id" | ||
|
||
# instantiate | ||
echo "Instantiating contract..." | ||
instantiate_result=$(printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=dex --output=json) | ||
contract_addr=$(echo "$instantiate_result" |jq -r '.logs[].events[].attributes[] | select(.key == "_contract_address").value') | ||
|
||
# register | ||
echo "Registering contract..." | ||
printf "12345678\n" | $seidbin tx dex register-contract "$contract_addr" "$contract_id" false true 100000000000 -y --from="$keyname" --chain-id="$chainid" --fees=100000000000usei --gas=500000 --broadcast-mode=block | ||
|
||
echo '{"batch_contract_pair":[{"contract_addr":"'$contract_addr'","pairs":[{"price_denom":"SEI","asset_denom":"ATOM","price_tick_size":"0.0000001", "quantity_tick_size":"0.0000001"}]}]}' > integration_test/contracts/"$contract_name"-pair.json | ||
contract_pair=$(printf "12345678\n" | $seidbin tx dex register-pairs integration_test/contracts/"$contract_name"-pair.json -y --from=$keyname --chain-id=$chainid --fees=10000000usei --gas=500000 --broadcast-mode=block --output=json) | ||
|
||
sleep 15s | ||
|
||
echo "Deployed contracts:" | ||
echo "$contract_addr" | ||
echo "$contract_addr" > $seihome/integration_test/contracts/"$contract_name"-addr.txt | ||
|
||
exit 0 |
90 changes: 90 additions & 0 deletions
90
integration_test/contracts/deploy_timelocked_token_contract.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/bin/bash | ||
|
||
seidbin=$(which ~/go/bin/seid | tr -d '"') | ||
keyname=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].name" | tr -d '"') | ||
chainid=$($seidbin status | jq ".NodeInfo.network" | tr -d '"') | ||
seihome=$(git rev-parse --show-toplevel | tr -d '"') | ||
migration=$1 | ||
|
||
# Prepare admin accounts | ||
echo "Preparing admin accounts..." | ||
printf "12345678\n" | $seidbin keys add admin1 | ||
printf "12345678\n" | $seidbin keys add admin2 | ||
printf "12345678\n" | $seidbin keys add admin3 | ||
printf "12345678\n" | $seidbin keys add admin4 | ||
printf "12345678\n" | $seidbin keys add op | ||
printf "12345678\n" | $seidbin keys add staking_reward_dest | ||
printf "12345678\n" | $seidbin keys add unlocked_dest | ||
key_admin1=$(printf "12345678\n" |$seidbin keys show admin1 -a) | ||
key_admin2=$(printf "12345678\n" |$seidbin keys show admin2 -a) | ||
key_admin3=$(printf "12345678\n" |$seidbin keys show admin3 -a) | ||
key_admin4=$(printf "12345678\n" |$seidbin keys show admin4 -a) | ||
key_op=$(printf "12345678\n" |$seidbin keys show op -a) | ||
key_staking=$(printf "12345678\n" |$seidbin keys show staking_reward_dest -a) | ||
key_unlock=$(printf "12345678\n" |$seidbin keys show unlocked_dest -a) | ||
printf "12345678\n" | $seidbin tx bank send admin "$key_admin1" 10000000usei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block | ||
printf "12345678\n" | $seidbin tx bank send admin "$key_admin2" 10000000usei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block | ||
printf "12345678\n" | $seidbin tx bank send admin "$key_admin3" 10000000usei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block | ||
printf "12345678\n" | $seidbin tx bank send admin "$key_admin4" 10000000usei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block | ||
printf "12345678\n" | $seidbin tx bank send admin "$key_op" 10000000usei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block | ||
printf "12345678\n" | $seidbin tx bank send admin "$key_staking" 10000000usei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block | ||
printf "12345678\n" | $seidbin tx bank send admin "$key_unlock" 10000000usei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block | ||
|
||
|
||
# Deploy goblin contract | ||
contract_name=goblin | ||
cd $seihome || exit | ||
echo "Deploying $contract_name contract..." | ||
|
||
# store | ||
echo "Storing contract..." | ||
store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/"$contract_name".wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json) | ||
contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value') | ||
echo "Got $contract_name contract id: $contract_id" | ||
|
||
# instantiate | ||
echo "Instantiating contract..." | ||
params='{"admins":["'$key_admin1'", "'$key_admin2'", "'$key_admin3'", "'$key_admin4'"], "max_voting_period": {"time":1800}, "admin_voting_threshold_percentage": 75}' | ||
instantiate_result=$(printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" "$params" -y --no-admin --amount=1500000usei --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=$contract_name --output=json) | ||
contract_addr=$(echo "$instantiate_result" |jq -r '.logs[].events[].attributes[] | select(.key == "_contract_address").value') | ||
echo "Instantiated $contract_name contract address: $contract_addr" | ||
echo "$contract_addr,$contract_id" > $seihome/integration_test/contracts/"$contract_name"-contract-addr.txt | ||
if [ -z "$contract_addr" ] | ||
then | ||
echo "Failed to deploy contract $contract_name" | ||
exit 1 | ||
fi | ||
|
||
# Deploy gringotts contract | ||
goblin_addr=$contract_addr | ||
if [ -z "$migration" ] | ||
then | ||
contract_name=gringotts | ||
else | ||
contract_name=gringotts_migrate | ||
fi | ||
cd $seihome || exit | ||
echo "Deploying $contract_name contract..." | ||
|
||
# store | ||
echo "Storing contract..." | ||
store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/"$contract_name".wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json) | ||
contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value') | ||
echo "Got $contract_name contract id: $contract_id" | ||
|
||
# instantiate | ||
echo "Instantiating contract..." | ||
VESTING_TIMESTAMPS='["1685480400000000000", "1685505600000000000"]' # nanoseconds since unix epoch | ||
VESTING_AMOUNTS='["1000000", "500000"]' # in usei | ||
params='{"admins":["'$key_admin1'", "'$key_admin2'", "'$key_admin3'", "'$key_admin4'"], "ops": ["'$key_op'"], "tranche": {"denom":"usei", "vesting_timestamps":'$VESTING_TIMESTAMPS', "vesting_amounts":'$VESTING_AMOUNTS', "unlocked_token_distribution_address": "'$key_unlock'", "staking_reward_distribution_address": "'$key_staking'"}, "max_voting_period": {"time":1800}, "admin_voting_threshold_percentage": 75}' | ||
instantiate_result=$(printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" "$params" -y --admin="$goblin_addr" --amount=1500000usei --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=$contract_name --output=json) | ||
contract_addr=$(echo "$instantiate_result" |jq -r '.logs[].events[].attributes[] | select(.key == "_contract_address").value') | ||
echo "Instantiated $contract_name contract address: $contract_addr" | ||
echo "$contract_addr,$contract_id" > $seihome/integration_test/contracts/"$contract_name"-contract-addr.txt | ||
if [ -z "$contract_addr" ] | ||
then | ||
echo "Failed to deploy contract $contract_name" | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Deploy mars contract | ||
./integration_test/contracts/deploy_dex_contract.sh mars | ||
contract_addr=$(tail -1 integration_test/contracts/mars-addr.txt) | ||
if [ -z "$contract_addr" ] | ||
then | ||
echo "Failed to deploy contract" | ||
exit 1 | ||
fi | ||
|
||
# Place orders | ||
echo "Place a new order" | ||
printf "12345678\n" | build/seid tx dex place-orders "$contract_addr" 'LONG?1.01?5?SEI?ATOM?LIMIT?{"leverage":"1","position_effect":"Open"}' --amount=1000000000usei -y --from=admin --chain-id=sei --fees=1000000usei --gas=50000000 --broadcast-mode=block | ||
sleep 15 | ||
echo "Verify order is placed successfully" | ||
result=$(build/seid q dex get-orders-by-id "$contract_addr" SEI ATOM 0 |grep "status:" |awk '{print $2}') | ||
if [ "$result" = "PLACED" ] | ||
then | ||
echo "Successfully placed an order" | ||
else | ||
echo "Failed to place an order" | ||
exit 1 | ||
fi | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Verify there are 4 validators | ||
NUM_VALIDATORS=$(build/seid q tendermint-validator-set |grep address |wc -l) | ||
if [[ "$NUM_VALIDATORS" -eq 4 ]]; | ||
then | ||
echo "Number validators is correct: $NUM_VALIDATORS" | ||
else | ||
exit 1 | ||
fi | ||
|
||
# Verify block height is keep increasing | ||
HEIGHT_1=$(build/seid status |jq -r .SyncInfo.latest_block_height) | ||
echo "Current height: $HEIGHT_1" | ||
sleep 15 | ||
HEIGHT_2=$(build/seid status |jq -r .SyncInfo.latest_block_height) | ||
echo "Current height: $HEIGHT_2" | ||
if [ "$HEIGHT_1" -ge "$HEIGHT_2" ]; | ||
then | ||
exit 1 | ||
fi | ||
echo "Startup test passed" | ||
exit 0 |
Oops, something went wrong.