Skip to content

Commit 60f98ae

Browse files
committed
test(wasm-challenge): add comprehensive WASM challenge integration tests with 5-validator consensus
Add 18 integration tests in tests/wasm_challenge_tests.rs covering: WASM Module Tests (3): - Compilation of term-challenge WASM binary via WasmRuntime - Instantiation with InstanceConfig and InMemoryStorageBackend - Verification of expected exports (memory) Challenge Lifecycle Tests (6): - Sudo owner adds challenge with real WASM binary - Sudo owner removes challenge and verifies cleanup - Non-sudo key rejected via signed message authorization check - Challenge persistence in sled storage (save/load roundtrip) - State hash changes on challenge add/remove - Challenge deletion from storage Consensus Tests (4): - 5-validator ConsensusEngine setup with quorum=3 - Leader creates proposal with ChallengeSubmission type - StateManager add/remove challenges - Challenge survives epoch transitions Full Pipeline Tests (5): - Multiple challenges lifecycle (add 3, remove selectively) - Full evaluation pipeline: add -> persist -> load -> compile -> instantiate - All 5 validators instantiate WASM from stored challenge - Full PBFT round: proposal -> pre-prepare -> handle_proposal -> prepares - State serialization/deserialization roundtrip with WASM challenge Key implementation details: - Each ConsensusEngine gets its own ValidatorSet for correct leader identity - Uses ChallengeSubmission (not ConfigUpdate) to avoid sudo auth at consensus level - Real 302KB term-challenge WASM binary loaded via include_bytes!() - Added wasm-runtime-interface and sha2 dependencies to tests/Cargo.toml
1 parent 665e652 commit 60f98ae

3 files changed

Lines changed: 614 additions & 0 deletions

File tree

Cargo.lock

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

tests/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,17 @@ path = "blockchain_state_tests.rs"
4040
name = "checkpoint_tests"
4141
path = "checkpoint_tests.rs"
4242

43+
[[test]]
44+
name = "wasm_challenge_tests"
45+
path = "wasm_challenge_tests.rs"
46+
4347
[dependencies]
4448
platform-core = { path = "../crates/core" }
4549
platform-storage = { path = "../crates/storage" }
4650
platform-p2p-consensus = { path = "../crates/p2p-consensus" }
4751
platform-bittensor = { path = "../crates/bittensor-integration" }
4852
platform-challenge-sdk = { path = "../crates/challenge-sdk" }
53+
wasm-runtime-interface = { path = "../crates/wasm-runtime-interface" }
4954

5055
tokio = { version = "1.40", features = ["full", "test-util"] }
5156
tempfile = "3.12"
@@ -58,5 +63,6 @@ rand = "0.8"
5863
lz4_flex = "0.11"
5964
hex = "0.4"
6065
bincode = "1.3"
66+
sha2 = { workspace = true }
6167
reqwest = { workspace = true }
6268
sp-core = { workspace = true }

0 commit comments

Comments
 (0)