From b7599826d2fc6f8cd7d3d32c18173e592ee319af Mon Sep 17 00:00:00 2001 From: Carlos Santiago Yanzon <27785807+bizk@users.noreply.github.com> Date: Tue, 26 Sep 2023 10:31:38 -0300 Subject: [PATCH] feat: cli test improvements (#44) * added makefile for docker image * added workflow and command * testing ci * testing ci * testing ci * testing ci * separated simapp step on workflow * concat 2 steps * added checkout * added checkout * small improvement on errors and fix on plugin deps * improvement over job steps * moved rosetta CLI exec to shell script * added rosetta install command to shell script * added rosetta install command to shell script * added rosetta install command to shell script * separated installation from rosetta-cli to another step * separated installation from rosetta-cli to another step * reduced CLI max indexc * added call to check for blockchain status * added await * added inmemory to rosetta cli * changed rosseta server and CLI ports to 8081 * fix check step * checking rosetta block endpoint * fix on plugin prefix * changed error message generation according to linter suggestions * fixed go.mod leaking dependencies issues * added step to use go version 1.21 * added wait for rosetta service * added wait time for simapp setup * increased index to 100 * increased index to 100 * added script to generate random TXs in the chain * updated git workflow * fixed typo * Changed sleep time * fixed script execution * changed data loading sh exec to makefile * added checkout for v4 * removed unused config file and added execution access to data.sh * fixed typo on command exec * defined shell environment variable * added submodule and moved cosmos-sdk to another folder inside the main one * debug * debug * fix typo * debug * debug * added SIMD environment variable * restructured workflow stage * small change on job name * updated sleep time to 2 minutes --- .github/workflows/rosetta-cli-test.yaml | 32 +++++++++++++++---- Makefile | 2 +- tests/rosetta-cli/data.sh | 29 +++++++++++++++++ .../rosetta-cli}/rosetta-cli-test.sh | 2 +- .../{config => rosetta-cli}/rosetta-cli.json | 2 +- 5 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 tests/rosetta-cli/data.sh rename {scripts => tests/rosetta-cli}/rosetta-cli-test.sh (83%) rename tests/{config => rosetta-cli}/rosetta-cli.json (98%) diff --git a/.github/workflows/rosetta-cli-test.yaml b/.github/workflows/rosetta-cli-test.yaml index 49a2692..6c9b031 100644 --- a/.github/workflows/rosetta-cli-test.yaml +++ b/.github/workflows/rosetta-cli-test.yaml @@ -12,30 +12,48 @@ permissions: contents: read jobs: - run-simapp: + rosetta-cli-test: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: '^1.21.1' - name: Get cosmos-sdk repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: cosmos/cosmos-sdk ref: main + path: './cosmos-sdk' - name: set up simapp - run: make build && export SIMD_BIN=./build/simd && make init-simapp + run: + cd cosmos-sdk && + make build && + export SIMD_BIN=./build/simd && + make init-simapp - name: Run simapp - run: ./build/simd start & + run: ./cosmos-sdk/build/simd start & + - name: Wait for simd to boot up for 2 mins and produce blocks + run: sleep 120s + shell: bash - name: Check blockchain status run: curl localhost:26657/status - - name: Checkout back to rosetta - uses: actions/checkout@v3 - name: Build Rosetta run: go mod tidy && make rosetta && make plugin - name: Run Rosetta service run: ./rosetta --blockchain "cosmos" --network "cosmos" --tendermint "tcp://localhost:26657" --addr "localhost:8081" --grpc "localhost:9090" & + - name: Wait for rosetta boot up for 30 secs + run: sleep 30s + shell: bash - name: Check rosetta status run: curl localhost:8081/block + - name: Generate wallets and transactions + run: + export SIMD_BIN=./cosmos-sdk/build/simd && + chmod +x ./tests/rosetta-cli/data.sh && + ./tests/rosetta-cli/data.sh + shell: bash - name: Test rosetta through Rosetta-cli - run: make rosetta-cli \ No newline at end of file + run: + make rosetta-cli + shell: bash \ No newline at end of file diff --git a/Makefile b/Makefile index 33983b2..bf1c812 100644 --- a/Makefile +++ b/Makefile @@ -35,4 +35,4 @@ docker: docker build . --tag rosetta rosetta-cli: - ./scripts/rosetta-cli-test.sh \ No newline at end of file + ./tests/rosetta-cli/rosetta-cli-test.sh \ No newline at end of file diff --git a/tests/rosetta-cli/data.sh b/tests/rosetta-cli/data.sh new file mode 100644 index 0000000..8328f6b --- /dev/null +++ b/tests/rosetta-cli/data.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +SIMD_BIN=${SIMD_BIN:=$(which simd 2>/dev/null)} + +if [ -z "$SIMD_BIN" ]; then echo "SIMD_BIN is not set. Make sure to run make install before"; exit 1; fi + +# Global variables +KEY_RING_BACKEND="test" +CHAIN_ID="demo" +amount_of_wallets=100 + +validator_address=$($SIMD_BIN keys show alice -a --keyring-backend "$KEY_RING_BACKEND") + +echo "[INFO] Generating wallets: $amount_of_wallets" +for ((index=0; index<"$amount_of_wallets"; index++)) +do + random_number=$((1 + RANDOM % 10000)) + + wallet_name="wallet-$random_number" + $SIMD_BIN keys add $wallet_name --keyring-backend "$KEY_RING_BACKEND" + wallet_address=$($SIMD_BIN keys show $wallet_name -a --keyring-backend "$KEY_RING_BACKEND") + echo "[DEBUG] Generated wallet: $wallet_name - $wallet_address" + + amount="$((RANDOM*10))stake" + echo "[DEBUG] Generating tx from validator: $validator_address sending $amount to $wallet_address" + $SIMD_BIN tx bank send "$validator_address" "$wallet_address" "$amount" --chain-id "$CHAIN_ID" --keyring-backend "$KEY_RING_BACKEND" -y + + sleep 1s # Wait so the TXs can happen in different blocks +done diff --git a/scripts/rosetta-cli-test.sh b/tests/rosetta-cli/rosetta-cli-test.sh similarity index 83% rename from scripts/rosetta-cli-test.sh rename to tests/rosetta-cli/rosetta-cli-test.sh index 859f224..2ea1bf1 100755 --- a/scripts/rosetta-cli-test.sh +++ b/tests/rosetta-cli/rosetta-cli-test.sh @@ -1,4 +1,4 @@ #!/bin/bash export PATH=${PATH}:`go env GOPATH`/bin go install github.com/coinbase/rosetta-cli@v0.10.0 -rosetta-cli check:data --in-memory-mode --configuration-file ./tests/config/rosetta-cli.json \ No newline at end of file +rosetta-cli check:data --in-memory-mode --configuration-file ./tests/rosetta-cli/rosetta-cli.json \ No newline at end of file diff --git a/tests/config/rosetta-cli.json b/tests/rosetta-cli/rosetta-cli.json similarity index 98% rename from tests/config/rosetta-cli.json rename to tests/rosetta-cli/rosetta-cli.json index a972e62..528738e 100644 --- a/tests/config/rosetta-cli.json +++ b/tests/rosetta-cli/rosetta-cli.json @@ -32,7 +32,7 @@ "results_output_file":"", "initial_balance_fetch_disabled":false, "end_conditions": { - "index": 2 + "index": 100 } }, "construction":null