-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #294 from White-Whale-Defi-Platform/v4.1.x/test-to…
…ken-factory test: `v4.1.x` test token factory
- Loading branch information
Showing
11 changed files
with
411 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ bin | |
*/.DS_Store | ||
|
||
|
||
mytestnet | ||
data | ||
screenlog.0 | ||
_build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Tests | ||
|
||
This folder contains the integration tests that should run successfully each time a new core release is created. | ||
|
||
At the moment, there are four tests defined that can be run with `make integration-test-all`. The breakdown of each test is as follows: | ||
|
||
- [init-test-framework](./start.sh): build the core and spin up two nodes with their own genesis event and some accounts preloaded with funds. | ||
- [test-relayer](./relayer/): connect the two blockchains with a relayer opening a channel between both of them. | ||
- [test-ica](./ica/delegate.sh): using the relayer, this test creates an interchain account and delegates funds using an interchain message. | ||
- [test-ibc-hooks](./ibc-hooks/increment.sh): deploys a slightly modified [counter contract](./ibc-hooks/counter/) to chain test-2 and submits two requests from chain test-1 to validate that the contract received the funds and executed the wasm code correctly. | ||
- remove-ica-data: removes the data and kills the process when the integration tests are completed. | ||
|
||
## Development process | ||
|
||
This set of tests must run out of the box in Linux-based systems installing [GoLang 1.20](https://go.dev/), [jq](https://stedolan.github.io/jq/), [screen](https://www.geeksforgeeks.org/screen-command-in-linux-with-examples/) and [rly](https://github.com/cosmos/relayer). |
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,151 @@ | ||
#!/bin/bash | ||
|
||
BINARY=migalood | ||
CHAIN_DIR=$(pwd)/data | ||
CHAINID_1=test-1 | ||
CHAINID_2=test-2 | ||
|
||
### Custom genesis files | ||
DENOM=uwhale | ||
GENESIS_1=$CHAIN_DIR/$CHAINID_1/config/genesis.json | ||
TMP_GENESIS_1=$CHAIN_DIR/$CHAINID_1/config/genesis.json.tmp | ||
|
||
GENESIS_2=$CHAIN_DIR/$CHAINID_2/config/genesis.json | ||
TMP_GENESIS_2=$CHAIN_DIR/$CHAINID_2/config/genesis.json.tmp | ||
|
||
VAL_MNEMONIC_1="clock post desk civil pottery foster expand merit dash seminar song memory figure uniform spice circle try happy obvious trash crime hybrid hood cushion" | ||
VAL_MNEMONIC_2="angry twist harsh drastic left brass behave host shove marriage fall update business leg direct reward object ugly security warm tuna model broccoli choice" | ||
WALLET_MNEMONIC_1="banner spread envelope side kite person disagree path silver will brother under couch edit food venture squirrel civil budget number acquire point work mass" | ||
WALLET_MNEMONIC_2="veteran try aware erosion drink dance decade comic dawn museum release episode original list ability owner size tuition surface ceiling depth seminar capable only" | ||
WALLET_MNEMONIC_3="vacuum burst ordinary enact leaf rabbit gather lend left chase park action dish danger green jeans lucky dish mesh language collect acquire waste load" | ||
WALLET_MNEMONIC_4="open attitude harsh casino rent attitude midnight debris describe spare cancel crisp olive ride elite gallery leaf buffalo sheriff filter rotate path begin soldier" | ||
RLY_MNEMONIC_1="alley afraid soup fall idea toss can goose become valve initial strong forward bright dish figure check leopard decide warfare hub unusual join cart" | ||
RLY_MNEMONIC_2="record gift you once hip style during joke field prize dust unique length more pencil transfer quit train device arrive energy sort steak upset" | ||
|
||
P2PPORT_1=16656 | ||
P2PPORT_2=26656 | ||
RPCPORT_1=16657 | ||
RPCPORT_2=26657 | ||
RESTPORT_1=1316 | ||
RESTPORT_2=1317 | ||
ROSETTA_1=8080 | ||
ROSETTA_2=8081 | ||
GRPCPORT_1=8090 | ||
GRPCPORT_2=9090 | ||
GRPCWEB_1=8091 | ||
GRPCWEB_2=9091 | ||
|
||
# Stop if it is already running | ||
if pgrep -x "$BINARY" >/dev/null; then | ||
echo "Terminating $BINARY..." | ||
killall $BINARY | ||
fi | ||
|
||
echo "Removing previous data..." | ||
rm -rf $CHAIN_DIR/$CHAINID_1 &> /dev/null | ||
rm -rf $CHAIN_DIR/$CHAINID_2 &> /dev/null | ||
|
||
# Add directories for both chains, exit if an error occurs | ||
if ! mkdir -p $CHAIN_DIR/$CHAINID_1 2>/dev/null; then | ||
echo "Failed to create chain folder. Aborting..." | ||
exit 1 | ||
fi | ||
|
||
if ! mkdir -p $CHAIN_DIR/$CHAINID_2 2>/dev/null; then | ||
echo "Failed to create chain folder. Aborting..." | ||
exit 1 | ||
fi | ||
|
||
echo "Initializing $CHAINID_1 & $CHAINID_2..." | ||
$BINARY init test --home $CHAIN_DIR/$CHAINID_1 --chain-id=$CHAINID_1 &> /dev/null | ||
$BINARY init test --home $CHAIN_DIR/$CHAINID_2 --chain-id=$CHAINID_2 &> /dev/null | ||
|
||
echo "Adding genesis accounts..." | ||
echo $VAL_MNEMONIC_1 | $BINARY keys add val1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test | ||
echo $VAL_MNEMONIC_2 | $BINARY keys add val2 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test | ||
echo $WALLET_MNEMONIC_1 | $BINARY keys add wallet1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test | ||
echo $WALLET_MNEMONIC_2 | $BINARY keys add wallet2 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test | ||
echo $WALLET_MNEMONIC_3 | $BINARY keys add wallet3 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test | ||
echo $WALLET_MNEMONIC_4 | $BINARY keys add wallet4 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test | ||
echo $RLY_MNEMONIC_1 | $BINARY keys add rly1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test | ||
echo $RLY_MNEMONIC_2 | $BINARY keys add rly2 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test | ||
|
||
VAL1_ADDR=$($BINARY keys show val1 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) | ||
VAL2_ADDR=$($BINARY keys show val2 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) | ||
WALLET1_ADDR=$($BINARY keys show wallet1 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) | ||
WALLET2_ADDR=$($BINARY keys show wallet2 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) | ||
WALLET3_ADDR=$($BINARY keys show wallet3 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) | ||
WALLET4_ADDR=$($BINARY keys show wallet4 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) | ||
RLY1_ADDR=$($BINARY keys show rly1 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) | ||
RLY2_ADDR=$($BINARY keys show rly2 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) | ||
|
||
$BINARY add-genesis-account $VAL1_ADDR "1000000000000${DENOM}" --home $CHAIN_DIR/$CHAINID_1 | ||
$BINARY add-genesis-account $VAL2_ADDR "1000000000000${DENOM}" --home $CHAIN_DIR/$CHAINID_2 | ||
$BINARY add-genesis-account $WALLET1_ADDR "1000000000000${DENOM}" --home $CHAIN_DIR/$CHAINID_1 | ||
$BINARY add-genesis-account $WALLET2_ADDR "1000000000000${DENOM}" --home $CHAIN_DIR/$CHAINID_2 | ||
$BINARY add-genesis-account $WALLET3_ADDR "1000000000000${DENOM}" --vesting-amount "10000000000${DENOM}" --vesting-start-time $(date +%s) --vesting-end-time $(($(date '+%s') + 100000023)) --home $CHAIN_DIR/$CHAINID_1 | ||
$BINARY add-genesis-account $WALLET4_ADDR "1000000000000${DENOM}" --vesting-amount "10000000000${DENOM}" --vesting-start-time $(date +%s) --vesting-end-time $(($(date '+%s') + 100000023)) --home $CHAIN_DIR/$CHAINID_2 | ||
$BINARY add-genesis-account $RLY1_ADDR "1000000000000${DENOM}" --home $CHAIN_DIR/$CHAINID_1 | ||
$BINARY add-genesis-account $RLY2_ADDR "1000000000000${DENOM}" --home $CHAIN_DIR/$CHAINID_2 | ||
|
||
echo "Creating and collecting gentx..." | ||
$BINARY gentx val1 7000000000uwhale --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --keyring-backend test | ||
$BINARY gentx val2 7000000000uwhale --home $CHAIN_DIR/$CHAINID_2 --chain-id $CHAINID_2 --keyring-backend test | ||
$BINARY collect-gentxs --home $CHAIN_DIR/$CHAINID_1 &> /dev/null | ||
$BINARY collect-gentxs --home $CHAIN_DIR/$CHAINID_2 &> /dev/null | ||
|
||
echo "Changing defaults and ports in app.toml and config.toml files..." | ||
sed -i -e 's#"tcp://0.0.0.0:26656"#"tcp://localhost:'"$P2PPORT_1"'"#g' $CHAIN_DIR/$CHAINID_1/config/config.toml | ||
sed -i -e 's#"tcp://127.0.0.1:26657"#"tcp://localhost:'"$RPCPORT_1"'"#g' $CHAIN_DIR/$CHAINID_1/config/config.toml | ||
sed -i -e 's#"tcp://localhost:26657"#"tcp://localhost:'"$RPCPORT_1"'"#g' $CHAIN_DIR/$CHAINID_1/config/client.toml | ||
sed -i -e 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAIN_DIR/$CHAINID_1/config/config.toml | ||
sed -i -e 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAIN_DIR/$CHAINID_1/config/config.toml | ||
sed -i -e 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/$CHAINID_1/config/config.toml | ||
sed -i -e 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml | ||
sed -i -e 's/swagger = false/swagger = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml | ||
sed -i -e 's#"tcp://localhost:1317"#"tcp://localhost:'"$RESTPORT_1"'"#g' $CHAIN_DIR/$CHAINID_1/config/app.toml | ||
sed -i -e 's#":8080"#":'"$ROSETTA_1"'"#g' $CHAIN_DIR/$CHAINID_1/config/app.toml | ||
sed -i -e 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml | ||
|
||
|
||
sed -i -e 's#"tcp://0.0.0.0:26656"#"tcp://localhost:'"$P2PPORT_2"'"#g' $CHAIN_DIR/$CHAINID_2/config/config.toml | ||
sed -i -e 's#"tcp://127.0.0.1:26657"#"tcp://localhost:'"$RPCPORT_2"'"#g' $CHAIN_DIR/$CHAINID_2/config/config.toml | ||
sed -i -e 's#"tcp://localhost:26657"#"tcp://localhost:'"$RPCPORT_2"'"#g' $CHAIN_DIR/$CHAINID_2/config/client.toml | ||
sed -i -e 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAIN_DIR/$CHAINID_2/config/config.toml | ||
sed -i -e 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAIN_DIR/$CHAINID_2/config/config.toml | ||
sed -i -e 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/$CHAINID_2/config/config.toml | ||
sed -i -e 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAINID_2/config/app.toml | ||
sed -i -e 's/swagger = false/swagger = true/g' $CHAIN_DIR/$CHAINID_2/config/app.toml | ||
sed -i -e 's#"tcp://localhost:1317"#"tcp://localhost:'"$RESTPORT_2"'"#g' $CHAIN_DIR/$CHAINID_2/config/app.toml | ||
sed -i -e 's#":8080"#":'"$ROSETTA_2"'"#g' $CHAIN_DIR/$CHAINID_2/config/app.toml | ||
sed -i -e 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' $CHAIN_DIR/$CHAINID_2/config/app.toml | ||
|
||
|
||
echo "Chaning genesis.json..." | ||
sed -i -e 's/"voting_period": "172800s"/"voting_period": "10s"/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json | ||
sed -i -e 's/"voting_period": "172800s"/"voting_period": "10s"/g' $CHAIN_DIR/$CHAINID_2/config/genesis.json | ||
sed -i -e 's/"reward_delay_time": "604800s"/"reward_delay_time": "0s"/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json | ||
sed -i -e 's/"reward_delay_time": "604800s"/"reward_delay_time": "0s"/g' $CHAIN_DIR/$CHAINID_2/config/genesis.json | ||
|
||
|
||
# Update the genesis file | ||
update_test_genesis () { | ||
jq "$1" $GENESIS_1 > $TMP_GENESIS_1 && mv $TMP_GENESIS_1 $GENESIS_1 | ||
jq "$1" $GENESIS_2 > $TMP_GENESIS_2 && mv $TMP_GENESIS_2 $GENESIS_2 | ||
} | ||
|
||
update_test_genesis ".app_state[\"staking\"][\"params\"][\"bond_denom\"]=\"$DENOM\"" | ||
update_test_genesis ".app_state[\"mint\"][\"params\"][\"mint_denom\"]=\"$DENOM\"" | ||
update_test_genesis ".app_state[\"crisis\"][\"constant_fee\"][\"denom\"]=\"$DENOM\"" | ||
update_test_genesis ".app_state[\"gov\"][\"deposit_params\"][\"min_deposit\"][0][\"denom\"]=\"$DENOM\"" | ||
update_test_genesis ".app_state[\"tokenfactory\"][\"params\"][\"denom_creation_fee\"][0][\"denom\"]=\"$DENOM\"" | ||
|
||
|
||
# Starting the chain | ||
echo "Starting $CHAINID_1 in $CHAIN_DIR..." | ||
echo "Creating log file at $CHAIN_DIR/$CHAINID_1.log" | ||
$BINARY start --log_level trace --log_format json --home $CHAIN_DIR/$CHAINID_1 --pruning=nothing --grpc.address="0.0.0.0:$GRPCPORT_1" --grpc-web.address="0.0.0.0:$GRPCWEB_1" > $CHAIN_DIR/$CHAINID_1.log 2>&1 & | ||
|
||
echo "Starting $CHAINID_2 in $CHAIN_DIR..." | ||
echo "Creating log file at $CHAIN_DIR/$CHAINID_2.log" | ||
$BINARY start --log_level trace --log_format json --home $CHAIN_DIR/$CHAINID_2 --pruning=nothing --grpc.address="0.0.0.0:$GRPCPORT_2" --grpc-web.address="0.0.0.0:$GRPCWEB_2" > $CHAIN_DIR/$CHAINID_2.log 2>&1 & |
21 changes: 21 additions & 0 deletions
21
scripts/tests/relayer/interchain-acc-config/chains/test-1.json
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,21 @@ | ||
{ | ||
"type": "cosmos", | ||
"value": { | ||
"key": "testkey", | ||
"chain-id": "test-1", | ||
"rpc-addr": "http://localhost:16657", | ||
"grpc-addr": "", | ||
"account-prefix": "migaloo", | ||
"keyring-backend": "test", | ||
"default-denom": "uwhale", | ||
"gas-adjustment": 1.5, | ||
"gas-prices": "100uwhale", | ||
"coin-type": 118, | ||
"debug": true, | ||
"timeout": "10s", | ||
"output-format": "json", | ||
"sign-mode": "direct", | ||
"trusting-period": "330h", | ||
"gas": 900000 | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
scripts/tests/relayer/interchain-acc-config/chains/test-2.json
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,21 @@ | ||
{ | ||
"type": "cosmos", | ||
"value": { | ||
"key": "testkey", | ||
"chain-id": "test-2", | ||
"rpc-addr": "http://localhost:26657", | ||
"grpc-addr": "", | ||
"account-prefix": "migaloo", | ||
"keyring-backend": "test", | ||
"default-denom": "uwhale", | ||
"gas-adjustment": 1.5, | ||
"gas-prices": "100uwhale", | ||
"coin-type": 118, | ||
"debug": true, | ||
"timeout": "10s", | ||
"output-format": "json", | ||
"sign-mode": "direct", | ||
"trusting-period": "330h", | ||
"gas": 900000 | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
scripts/tests/relayer/interchain-acc-config/paths/test1-test2.json
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,18 @@ | ||
{ | ||
"src": { | ||
"chain-id": "test-1", | ||
"client-id": "", | ||
"connection-id": "", | ||
"channel-id": "" | ||
}, | ||
"dst": { | ||
"chain-id": "test-2", | ||
"client-id": "", | ||
"connection-id": "", | ||
"channel-id": "" | ||
}, | ||
"src-channel-filter": { | ||
"rule": "", | ||
"channel-list": [] | ||
} | ||
} |
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,49 @@ | ||
#!/bin/bash | ||
|
||
echo "" | ||
echo "##################" | ||
echo "# Create relayer #" | ||
echo "##################" | ||
echo "" | ||
|
||
# Configure predefined mnemonic pharses | ||
BINARY=rly | ||
CHAIN_DIR=$(pwd)/data | ||
CHAINID_1=test-1 | ||
CHAINID_2=test-2 | ||
RELAYER_DIR=/relayer | ||
MNEMONIC_1="alley afraid soup fall idea toss can goose become valve initial strong forward bright dish figure check leopard decide warfare hub unusual join cart" | ||
MNEMONIC_2="record gift you once hip style during joke field prize dust unique length more pencil transfer quit train device arrive energy sort steak upset" | ||
|
||
# Ensure rly is installed | ||
if ! [ -x "$(command -v $BINARY)" ]; then | ||
echo "$BINARY is required to run this script..." | ||
echo "You can download at https://github.com/cosmos/relayer" | ||
exit 1 | ||
fi | ||
|
||
echo "Initializing $BINARY..." | ||
$BINARY config init --home $CHAIN_DIR/$RELAYER_DIR | ||
|
||
echo "Adding configurations for both chains..." | ||
$BINARY chains add-dir ./scripts/tests/relayer/interchain-acc-config/chains --home $CHAIN_DIR/$RELAYER_DIR | ||
$BINARY paths add $CHAINID_1 $CHAINID_2 test1-test2 --file ./scripts/tests/relayer/interchain-acc-config/paths/test1-test2.json --home $CHAIN_DIR/$RELAYER_DIR | ||
|
||
echo "Restoring accounts..." | ||
$BINARY keys restore $CHAINID_1 testkey "$MNEMONIC_1" --home $CHAIN_DIR/$RELAYER_DIR | ||
$BINARY keys restore $CHAINID_2 testkey "$MNEMONIC_2" --home $CHAIN_DIR/$RELAYER_DIR | ||
|
||
echo "Creating clients and a connection..." | ||
$BINARY tx connection test1-test2 --home $CHAIN_DIR/$RELAYER_DIR | ||
|
||
echo "Creating a channel..." | ||
$BINARY tx channel test1-test2 --home $CHAIN_DIR/$RELAYER_DIR | ||
|
||
echo "Starting to listen relayer..." | ||
$BINARY start test1-test2 -p events -b 100 --home $CHAIN_DIR/$RELAYER_DIR > $CHAIN_DIR/relayer.log 2>&1 & | ||
|
||
echo "" | ||
echo "############################" | ||
echo "# SUCCESS: Relayer created #" | ||
echo "############################" | ||
echo "" |
Oops, something went wrong.