Skip to content

Commit

Permalink
feat: cli test improvements (#44)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bizk committed Sep 26, 2023
1 parent 634a81a commit b759982
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 10 deletions.
32 changes: 25 additions & 7 deletions .github/workflows/rosetta-cli-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
run:
make rosetta-cli
shell: bash
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ docker:
docker build . --tag rosetta

rosetta-cli:
./scripts/rosetta-cli-test.sh
./tests/rosetta-cli/rosetta-cli-test.sh
29 changes: 29 additions & 0 deletions tests/rosetta-cli/data.sh
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
export PATH=${PATH}:`go env GOPATH`/bin
go install github.com/coinbase/[email protected]
rosetta-cli check:data --in-memory-mode --configuration-file ./tests/config/rosetta-cli.json
rosetta-cli check:data --in-memory-mode --configuration-file ./tests/rosetta-cli/rosetta-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"results_output_file":"",
"initial_balance_fetch_disabled":false,
"end_conditions": {
"index": 2
"index": 100
}
},
"construction":null
Expand Down

0 comments on commit b759982

Please sign in to comment.