Skip to content

Commit

Permalink
Merge pull request #2 from Sovereign-Labs/blaze/readme_exec
Browse files Browse the repository at this point in the history
Add sov-rollup-starter.sh to CI
  • Loading branch information
bkolad authored Oct 30, 2023
2 parents 0e4f534 + ad8e8f9 commit c8ca62c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -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}
```
3 changes: 3 additions & 0 deletions crates/rollup/Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
47 changes: 47 additions & 0 deletions sov-rollup-starter.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c8ca62c

Please sign in to comment.