Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sov-rollup-starter.sh to CI #2

Merged
merged 4 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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