Skip to content

Commit

Permalink
Merge branch 'main' into mkl-swaps-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
maltekliemann authored Feb 15, 2024
2 parents ee584fd + be75fa9 commit 8da160c
Show file tree
Hide file tree
Showing 38 changed files with 8,016 additions and 3,835 deletions.
269 changes: 269 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
name: Integration Tests

on:
push:
tags:
- '^v[0-9]+.[0-9]+.[0-9]+(-rc[0-9]+)?$'

env:
CARGO_TERM_COLOR: always

jobs:
build_parachain:
name: Build Parachain
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install build tools
run: ./scripts/init.sh

- name: Build Parachain
run: cargo build --release --features parachain

- name: Save runtime wasm
run: |
mkdir -p runtimes
cp target/release/wbuild/battery-station-runtime/battery_station_runtime.compact.compressed.wasm runtimes/;
cp target/release/wbuild/zeitgeist-runtime/zeitgeist_runtime.compact.compressed.wasm runtimes/;
- name: Upload runtimes
uses: actions/upload-artifact@v3.1.2
with:
name: runtimes
path: runtimes

- name: Save zeitgeist binary
run: |
mkdir -p binaries
cp target/release/zeitgeist binaries/;
- name: Upload binary
uses: actions/upload-artifact@v3.1.2
with:
name: binaries
path: binaries

zombienet_zndsl:
name: ZNDSL Tests
runs-on: ubuntu-20.04
needs: ["build_parachain"]
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install build tools
run: ./scripts/init.sh

- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: "pnpm"
cache-dependency-path: "./integration-tests/pnpm-lock.yaml"

- name: Install pnpm packages
run: |
cd integration-tests
pnpm install
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1

- name: Create local folders
run: |
mkdir -p target/release/wbuild/zeitgeist-runtime/
mkdir -p integration-tests/tmp
- name: Download runtime
uses: actions/download-artifact@v3.0.2
with:
name: runtimes
path: target/release/wbuild/zeitgeist-runtime/

- name: Download binary
uses: actions/download-artifact@v3.0.2
with:
name: binaries
path: target/release

- name: Display structure of downloaded files
run: ls -R
working-directory: target/

- name: Run ZNDSL integration tests
run: |
chmod uog+x target/release/zeitgeist
cd integration-tests
./scripts/download-polkadot.sh
./scripts/deploy-zombienet.sh --no-build --test
zombienet_zeitgeist_upgrade:
name: Zeitgeist Zombienet Post-Upgrade Tests
runs-on: ubuntu-20.04
needs: ["build_parachain"]
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install build tools
run: ./scripts/init.sh

- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: "pnpm"
cache-dependency-path: "./integration-tests/pnpm-lock.yaml"

- name: Install pnpm packages
run: |
cd integration-tests
pnpm install
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1

- name: Create local folders
run: |
mkdir -p target/release/wbuild/zeitgeist-runtime/
mkdir -p integration-tests/tmp
- name: Download runtime
uses: actions/download-artifact@v3.0.2
with:
name: runtimes
path: target/release/wbuild/zeitgeist-runtime/

- name: Download binary
uses: actions/download-artifact@v3.0.2
with:
name: binaries
path: target/release

- name: Display structure of downloaded files
run: ls -R
working-directory: target/

- name: Test zeitgeist runtime upgrade using Zombienet
run: |
chmod uog+x target/release/zeitgeist
cd integration-tests
pnpm exec moonwall test zombienet_zeitgeist_upgrade
chopsticks_battery_station_upgrade:
name: Battery Station Chopsticks Post-Upgrade Tests
runs-on: ubuntu-20.04
needs: ["build_parachain"]
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install build tools
run: ./scripts/init.sh

- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: "pnpm"
cache-dependency-path: "./integration-tests/pnpm-lock.yaml"

- name: Install pnpm packages
run: |
cd integration-tests
pnpm install
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1

- name: Create local folders
run: |
mkdir -p target/release/wbuild/battery-station-runtime/
mkdir -p integration-tests/tmp/node_logs
- name: Download runtime
uses: actions/download-artifact@v3.0.2
with:
name: runtimes
path: target/release/wbuild/battery-station-runtime/

- name: Display structure of downloaded files
run: ls -R
working-directory: target/

- name: Battery Station post-upgrade tests using Chopsticks
run: |
cd integration-tests
pnpm exec moonwall test chopsticks_battery_station_upgrade
- name: Show chopsticks logs
if: ${{ failure() }}
run: |
cd integration-tests
ls -R tmp/node_logs/
cat tmp/node_logs/*.log | tail -n 1000
chopsticks_zeitgeist_upgrade:
name: Zeitgeist Chopsticks Post-Upgrade Tests
runs-on: ubuntu-20.04
needs: ["build_parachain"]
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install build tools
run: ./scripts/init.sh

- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: "pnpm"
cache-dependency-path: "./integration-tests/pnpm-lock.yaml"

- name: Install pnpm packages
run: |
cd integration-tests
pnpm install
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1

- name: Create local folders
run: |
mkdir -p target/release/wbuild/zeitgeist-runtime/
mkdir -p integration-tests/tmp/node_logs
- name: "Download runtime"
uses: actions/download-artifact@v3.0.2
with:
name: runtimes
path: target/release/wbuild/zeitgeist-runtime/

- name: Display structure of downloaded files
run: ls -R
working-directory: target/

- name: Zeitgeist post-upgrade tests using Chopsticks
run: |
cd integration-tests
pnpm exec moonwall test chopsticks_zeitgeist_upgrade
- name: Show chopsticks logs
if: ${{ failure() }}
run: |
cd integration-tests
ls -R tmp/node_logs/
cat tmp/node_logs/*.log | tail -n 1000
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,6 @@ dmypy.json
# Pyre type checker
.pyre/

/tmp
/integration-tests/tmp

/integration-tests/specs
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

# Zeitgeist: An Evolving Blockchain for Prediction Markets and Futarchy

![Rust](https://github.com/zeitgeistpm/zeitgeist/workflows/Rust/badge.svg)
![Rust](https://github.com/zeitgeistpm/zeitgeist/actions/workflows/rust.yml/badge.svg)
[![Codecov](https://codecov.io/gh/zeitgeistpm/zeitgeist/branch/main/graph/badge.svg)](https://codecov.io/gh/zeitgeistpm/zeitgeist)
[![Discord](https://img.shields.io/badge/discord-https%3A%2F%2Fdiscord.gg%2FMD3TbH3ctv-purple)](https://discord.gg/MD3TbH3ctv)
[![Discord](https://img.shields.io/badge/discord-https%3A%2F%2Fdiscord.gg%2FMD3TbH3ctv-purple)](https://discord.gg/XhAcFWYUej)
[![Telegram](https://img.shields.io/badge/telegram-https%3A%2F%2Ft.me%2Fzeitgeist__official-blue)](https://t.me/zeitgeist_official)

Zeitgeist is a decentralized network for creating, betting on, and resolving
Expand Down
22 changes: 18 additions & 4 deletions docs/STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ duplicating documentation.

- Exceed 70 lines of code per function only in exceptional circumstances. Aim
for less.
- No `while` in production. All `for` loops must have a maximum number of
passes.
- Prefer `for` loops over `while` loops. All loops (of any kind) must have a
maximum number of passes.
- Use depth checks when using recursion in production. Use recursion only if the
algorithm is defined using recursion.
- Avoid `mut` in production code if possible without much pain.
- Mark all extrinsics `transactional`, even if they satisfy
the verify-first/write-later principle.
- Mark all extrinsics `transactional`, even if they satisfy the
verify-first/write-later principle.
- Avoid indentation over five levels; never go over seven levels.
- All public functions must be documented. Documentation of `pub(crate)` and
private functions is optional but encouraged.
Expand Down Expand Up @@ -156,3 +156,17 @@ duplicating documentation.
- For larger modules, use one test file per extrinsic for unit tests. Make unit
tests as decoupled as possible from other modules. Place end-to-end and
integration tests in extra files.
- If possible, test unreachable code and states thought to be impossible using
the following schema:

```rust
// In code logic
zeitgeist_macros::unreachable_non_terminating!(condition, log_target, message)
```

```rust
// In test
#[test]
#[should_panic(expected = message)]
// Cause assertion
```
Loading

0 comments on commit 8da160c

Please sign in to comment.