diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0ca2ef4..08bc13d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -27,3 +27,5 @@ jobs: run: cargo build --verbose - name: Run tests run: cargo test --verbose + - name: Run README.md + run: chmod +x sov-rollup-starter.sh && ./sov-rollup-starter.sh diff --git a/README.md b/README.md index 1165fdc..cca183c 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,40 @@ - -# This is still work in progress. - This package is a convenient starting point for building a rollup using the Sovereign SDK: - # How to run the sov-rollup-starter: -1. `cd crates/rollup/` +#### 1. Change the working directory: + +```shell,test-ci +$ cd crates/rollup/ +``` -2. Starting the node: +#### 2. Cleanup database: +```sh,test-ci +$ make clean-db +``` + +#### 3. Starting the node: If you want to run a fresh rollup remove the `rollup-starter-data` folder. This will compile and start the rollup node: -```shell -cargo run --bin node +```shell,test-ci,bashtestmd:long-running,bashtestmd:wait-until=RPC +$ cargo run --bin node ``` +#### 4. In another shell run: + +```sh,test-ci +$ make test-create-token +``` -3. In another shell run: +#### 5. Test if token creation succeeded -```shell -make test-create-token +```sh,test-ci +$ make test-bank-supply-of ``` -4. Test if token creation succeeded +#### 6. The output of the above script: -```shell -make test-bank-supply-of +```bash,test-ci,bashtestmd:compare-output +$ curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"bank_supplyOf","params":["sov1zdwj8thgev2u3yyrrlekmvtsz4av4tp3m7dm5mx5peejnesga27svq9m72"],"id":1}' http://127.0.0.1:12345 +{"jsonrpc":"2.0","result":{"amount":1000},"id":1} ``` \ No newline at end of file diff --git a/crates/rollup/Makefile b/crates/rollup/Makefile index d9151e2..ef5991a 100644 --- a/crates/rollup/Makefile +++ b/crates/rollup/Makefile @@ -1,6 +1,9 @@ PROJECT_ROOT := $(shell git rev-parse --show-toplevel) SOV_CLI_REL_PATH := $(PROJECT_ROOT)/target/debug/starter-cli-wallet +clean-db: + rm -rf ../../rollup-starter-data + build-sov-cli: cargo build --bin starter-cli-wallet diff --git a/sov-rollup-starter.sh b/sov-rollup-starter.sh new file mode 100755 index 0000000..d635ed1 --- /dev/null +++ b/sov-rollup-starter.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +trap 'jobs -p | xargs -r kill' EXIT +echo 'Running: '\''cd crates/rollup/'\''' +cd crates/rollup/ +if [ $? -ne 0 ]; then + echo "Expected exit code 0, got $?" + exit 1 +fi +echo 'Running: '\''make clean-db'\''' +make clean-db +if [ $? -ne 0 ]; then + echo "Expected exit code 0, got $?" + exit 1 +fi +echo 'Running: '\''cargo run --bin node'\''' +cargo run --bin node & +sleep 20 +echo 'Running: '\''make test-create-token'\''' +make test-create-token +if [ $? -ne 0 ]; then + echo "Expected exit code 0, got $?" + exit 1 +fi +echo 'Running: '\''make test-bank-supply-of'\''' +make test-bank-supply-of +if [ $? -ne 0 ]; then + echo "Expected exit code 0, got $?" + exit 1 +fi +echo 'Running: '\''curl -X POST -H "Content-Type: application/json" -d '\''{"jsonrpc":"2.0","method":"bank_supplyOf","params":["sov1zdwj8thgev2u3yyrrlekmvtsz4av4tp3m7dm5mx5peejnesga27svq9m72"],"id":1}'\'' http://127.0.0.1:12345'\''' + +output=$(curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"bank_supplyOf","params":["sov1zdwj8thgev2u3yyrrlekmvtsz4av4tp3m7dm5mx5peejnesga27svq9m72"],"id":1}' http://127.0.0.1:12345) +expected='{"jsonrpc":"2.0","result":{"amount":1000},"id":1} +' +# Either of the two must be a substring of the other. This kinda protects us +# against whitespace differences, trimming, etc. +if ! [[ $output == *"$expected"* || $expected == *"$output"* ]]; then + echo "'$expected' not found in text:" + echo "'$output'" + exit 1 +fi + +if [ $? -ne 0 ]; then + echo "Expected exit code 0, got $?" + exit 1 +fi +echo "All tests passed!"; exit 0