Skip to content

Commit ffc1a1e

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 0221fc4 commit ffc1a1e

22 files changed

+1337
-4
lines changed

.github/workflows/test.yml

Lines changed: 53 additions & 3 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.
@@ -20,7 +21,7 @@ env:
2021
CARGO_TERM_COLOR: always
2122
CARGO_PROFILE_DEV_DEBUG: 1
2223
CARGO_PROFILE_RELEASE_DEBUG: 1
23-
RUST_BACKTRACE: short
24+
RUST_BACKTRACE: full
2425
CARGO_NET_RETRY: 10
2526
RUSTUP_MAX_RETRIES: 10
2627

@@ -57,11 +58,60 @@ 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 Suite
73+
runs-on: ubuntu-latest
74+
timeout-minutes: 60
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 Bun
96+
uses: oven-sh/setup-bun@v2
97+
- name: Install Quint
98+
run: bun install -g @informalsystems/quint
99+
- name: Login to GitHub Container Registry
100+
uses: docker/login-action@v3
101+
with:
102+
registry: ghcr.io
103+
username: ${{ github.actor }}
104+
password: ${{ secrets.GITHUB_TOKEN }}
105+
- name: Install Protoc
106+
uses: arduino/setup-protoc@v3
107+
with:
108+
repo-token: ${{ secrets.GITHUB_TOKEN }}
109+
- name: Setup Rust toolchain
110+
uses: actions-rust-lang/setup-rust-toolchain@v1
111+
with:
112+
toolchain: nightly
113+
- name: Install Foundry
114+
uses: foundry-rs/foundry-toolchain@v1
115+
- name: Run MBT suite
116+
run: make mbt-test
67117
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ members = [
77
"engine",
88
"utils",
99
"types",
10+
"tests/mbt",
11+
]
12+
13+
default-members = [
14+
"app",
15+
"cli",
16+
"engine",
17+
"utils",
18+
"types",
1019
]
1120

1221
[workspace.package]

Makefile

Lines changed: 13 additions & 1 deletion
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

@@ -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)