Skip to content

Commit 029e72f

Browse files
committed
test(mbt): Add Model Based Test for Emerald
This patch connects the newly added Quint specs to Emerald's code via the Quint Connect library.
1 parent 2748ced commit 029e72f

22 files changed

+1306
-4
lines changed

.github/workflows/test.yml

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
permissions:
1010
contents: read
11+
packages: read
1112

1213
# If new code is pushed to a PR branch, then cancel in progress workflows for that PR.
1314
# Ensures that we don't waste CI time, and returns results quicker.
@@ -23,6 +24,7 @@ env:
2324
RUST_BACKTRACE: short
2425
CARGO_NET_RETRY: 10
2526
RUSTUP_MAX_RETRIES: 10
27+
QUINT_VERBOSE: 1
2628

2729
jobs:
2830
unit:
@@ -57,11 +59,62 @@ jobs:
5759
- name: Run Forge build
5860
run: forge build
5961
if: steps.filter.outputs.code == 'true'
60-
- name: Run tests
62+
- name: Run unit tests
6163
run: |
6264
cargo nextest run \
6365
--workspace \
6466
--all-features \
6567
--no-fail-fast \
66-
--failure-output final
68+
--failure-output final \
69+
--filterset 'not package(emerald-mbt)'
70+
if: steps.filter.outputs.code == 'true'
71+
72+
mbt:
73+
name: MBT Tests
74+
runs-on: ubuntu-latest
75+
# XXX: Do not block on MBT initially until we gain confidence CI is not
76+
# flaky for any reason.
77+
continue-on-error: true
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v5
81+
with:
82+
submodules: recursive
83+
- id: filter
84+
uses: dorny/paths-filter@v3
85+
with:
86+
filters: |
87+
code:
88+
- '**/*.rs'
89+
- '**/*.qnt'
90+
- 'Makefile'
91+
- '**/Cargo.toml'
92+
- '**/Cargo.lock'
93+
- '**/*.sh'
94+
- '*/workflows/test.yml'
95+
- name: Setup Node.js
96+
uses: actions/setup-node@v4
97+
with:
98+
node-version: '22'
99+
- name: Install Quint
100+
run: npm install -g @informalsystems/quint
101+
- name: Login to GitHub Container Registry
102+
uses: docker/login-action@v3
103+
with:
104+
registry: ghcr.io
105+
username: ${{ github.actor }}
106+
password: ${{ secrets.GITHUB_TOKEN }}
107+
- name: Install Protoc
108+
uses: arduino/setup-protoc@v3
109+
with:
110+
repo-token: ${{ secrets.GITHUB_TOKEN }}
111+
- name: Setup Rust toolchain
112+
uses: actions-rust-lang/setup-rust-toolchain@v1
113+
- name: Install Foundry
114+
uses: foundry-rs/foundry-toolchain@v1
115+
- name: Run Forge build
116+
run: forge build
117+
if: steps.filter.outputs.code == 'true'
118+
- name: Run MBT tests
119+
run: make mbt-test
67120
if: steps.filter.outputs.code == 'true'

Cargo.lock

Lines changed: 131 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
"engine",
88
"utils",
99
"types",
10+
"tests/mbt",
1011
]
1112

1213
[workspace.package]

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all build release test docs docs-serve testnet-config testnet-reth-recreate testnet-reth-restart testnet-start sync testnet-node-stop testnet-node-restart testnet-stop testnet-clean clean-volumes clean-prometheus spam spam-contract
1+
.PHONY: all build release test docs docs-serve testnet-config testnet-reth-recreate testnet-reth-restart testnet-start sync testnet-node-stop testnet-node-restart testnet-stop testnet-clean clean-volumes clean-prometheus spam spam-contract mbt-test mbt-clean
22

33
all: build
44

@@ -12,7 +12,7 @@ release:
1212
cargo build --release
1313

1414
test:
15-
cargo test
15+
cargo test --workspace --exclude emerald-mbt
1616
forge test -vvv
1717

1818
# Docs
@@ -107,3 +107,15 @@ spam-contract:
107107
--time=60 \
108108
--rate=1000 \
109109
--rpc-url=127.0.0.1:8645
110+
111+
# Model-Based Testing (MBT)
112+
113+
TEST ?=
114+
115+
mbt-test: RETH_NODES=reth0 reth1 reth2
116+
mbt-test: testnet-config
117+
@echo "Running MBT tests..."
118+
@echo "Note: RETH will be automatically started and stopped for each test"
119+
cargo test --package emerald-mbt -- --nocapture --test-threads=1 $(TEST)
120+
121+
mbt-clean: testnet-clean

tests/mbt/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "emerald-mbt"
3+
version = { workspace = true }
4+
edition = { workspace = true }
5+
publish = false
6+
7+
[lints]
8+
workspace = true
9+
10+
[dependencies]
11+
emerald = { workspace = true }
12+
malachitebft-eth-types = { workspace = true }
13+
malachitebft-eth-engine = { workspace = true }
14+
malachitebft-eth-cli = { workspace = true }
15+
malachitebft-app-channel = { workspace = true }
16+
malachitebft-core-consensus = { workspace = true }
17+
18+
serde = { workspace = true }
19+
itf = { workspace = true }
20+
tokio = { workspace = true }
21+
22+
quint-connect = "0.1"
23+
anyhow = "1.0"
24+
bimap = "0.6.3"
25+
tempfile = "3.23.0"

0 commit comments

Comments
 (0)