Skip to content

Commit d09bd51

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 9b46ba5 commit d09bd51

22 files changed

+1305
-4
lines changed

.github/workflows/test.yml

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