From e7e02115649dd52230baba81a61113d322393e48 Mon Sep 17 00:00:00 2001 From: bkolad Date: Mon, 30 Oct 2023 09:41:46 +0100 Subject: [PATCH 1/4] Create sov-rollup-starter.sh --- README.md | 39 ++++++++++++++++++++++------------- crates/rollup/Makefile | 3 +++ sov-rollup-starter.sh | 47 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 14 deletions(-) create mode 100755 sov-rollup-starter.sh diff --git a/README.md b/README.md index 1165fdc..05bb650 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. Change the working directory: +```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. Verify the Token Supply -```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 From 0251439ba677c782814a5a8fd8e1feaac478b42e Mon Sep 17 00:00:00 2001 From: bkolad Date: Mon, 30 Oct 2023 10:08:12 +0100 Subject: [PATCH 2/4] Test readme in CI --- .github/workflows/rust.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0ca2ef4..f4d69b4 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 demo-rollup-readme.sh && ./demo-rollup-readme.sh From 39fa55fc40ffaa42904ab8bc328ca25779819fd6 Mon Sep 17 00:00:00 2001 From: bkolad Date: Mon, 30 Oct 2023 10:14:22 +0100 Subject: [PATCH 3/4] Update readme --- .github/workflows/rust.yml | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f4d69b4..200e34a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -28,4 +28,4 @@ jobs: - name: Run tests run: cargo test --verbose - name: Run README.md - run: chmod +x demo-rollup-readme.sh && ./demo-rollup-readme.sh + run: chmod +x sov-rollup-starter.sh && ./demo-rollup-readme.sh diff --git a/README.md b/README.md index 05bb650..cca183c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This package is a convenient starting point for building a rollup using the Sove $ cd crates/rollup/ ``` -#### 2. Change the working directory: +#### 2. Cleanup database: ```sh,test-ci $ make clean-db ``` @@ -32,7 +32,7 @@ $ make test-create-token $ make test-bank-supply-of ``` -#### 6. Verify the Token Supply +#### 6. The output of the above script: ```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 From ad8e8f9168d831ea5f79f8532883a0b30a7946ea Mon Sep 17 00:00:00 2001 From: bkolad Date: Mon, 30 Oct 2023 10:20:38 +0100 Subject: [PATCH 4/4] Fix CI --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 200e34a..08bc13d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -28,4 +28,4 @@ jobs: - name: Run tests run: cargo test --verbose - name: Run README.md - run: chmod +x sov-rollup-starter.sh && ./demo-rollup-readme.sh + run: chmod +x sov-rollup-starter.sh && ./sov-rollup-starter.sh