Commit 60f98ae
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.toml1 parent 665e652 commit 60f98ae
3 files changed
Lines changed: 614 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
| |||
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
| 66 | + | |
61 | 67 | | |
62 | 68 | | |
0 commit comments