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