Conformance Testing
Conformance Testing
Section titled “Conformance Testing”JAM Forge maintains strict conformance with the JAM protocol specification through comprehensive testing and validation.
Conformance Server
Section titled “Conformance Server”The JAM Forge conformance server provides a Unix domain socket interface for protocol testing and cross-implementation validation.
Starting the Server
Section titled “Starting the Server”# Run from sourcesbt "conformance/run"
# Or use the standalone JARjava -jar modules/conformance/target/scala-3.3.7/jam-conformance.jarThe server listens on /tmp/jam-conformance.sock by default.
Server Protocol
Section titled “Server Protocol”The conformance server implements the JAM conformance protocol:
- Initialize: Set up initial state
- Import Block: Process and validate a block
- Query State: Retrieve current state
- Reset: Return to initial state
Official Test Vectors
Section titled “Official Test Vectors”JAM Forge is tested against official test vectors from the jamtestvectors repository.
Test Vector Structure
Section titled “Test Vector Structure”jamtestvectors/├── codec/ # Binary encoding test cases│ ├── block.json│ ├── header.json│ └── extrinsic.json├── erasure/ # Erasure coding vectors│ └── erasure.json├── shuffle/ # Validator shuffle vectors│ └── shuffle.json└── stf/ # State transition function vectors ├── safrole/ ├── statistics/ ├── authorizations/ ├── assurances/ ├── reports/ ├── disputes/ ├── history/ └── preimages/Running Test Vector Tests
Section titled “Running Test Vector Tests”# Run all test vector testssbt test
# Run specific STF testssbt "protocol/testOnly *SafroleTest"sbt "protocol/testOnly *StatisticsTest"
# Run codec testssbt "core/testOnly *CodecTest"Fuzzing
Section titled “Fuzzing”JAM Forge integrates with the jam-conformance fuzzing framework for automated testing.
Fuzzing Modes
Section titled “Fuzzing Modes”- Exploratory: Random block generation and validation
- Trace-based: Replay historical traces
- Differential: Compare against other implementations
Running Fuzzing Tests
Section titled “Running Fuzzing Tests”# Start JAM Forge conformance serversbt "conformance/run"
# In another terminal, run fuzzingcd jam-conformance/scriptspython3 fuzz-workflow.py --target jam-forge --mode exploratory
# Run trace-based fuzzingpython3 fuzz-workflow.py --target jam-forge --mode trace
# Run differential fuzzing (requires other implementations)python3 fuzz-workflow.py --targets jam-forge,jam-rust --mode differentialCross-Implementation Validation
Section titled “Cross-Implementation Validation”JAM Forge can be validated against other JAM implementations:
Available Implementations
Section titled “Available Implementations”- jam-rust: Reference Rust implementation
- jam-go: Go implementation
- jam-cpp: C++ implementation
Running Cross-Validation
Section titled “Running Cross-Validation”# Compare state transitions with Rust implementationpython3 compare-implementations.py jam-forge jam-rust --blocks 1000
# Validate specific STFspython3 compare-implementations.py jam-forge jam-rust --stf safroleConformance Metrics
Section titled “Conformance Metrics”JAM Forge tracks conformance metrics:
Test Vector Pass Rate
Section titled “Test Vector Pass Rate”- Codec Tests: 100% (all encoding/decoding tests pass)
- Safrole STF: 100% (block production)
- Statistics STF: 100% (validator metrics)
- Assurances STF: 100% (availability)
- Reports STF: 100% (work report processing)
- Accumulation STF: 100% (finalization)
- History STF: 100% (ancestry tracking)
- Authorizations STF: 100% (service auth)
- Preimages STF: 100% (data storage)
- Disputes STF: 100% (validator disputes)
Fuzzing Results
Section titled “Fuzzing Results”- Blocks Processed: 10,000+ without failure
- State Transitions: All STFs validated
- Encoding Round-trips: 100% success rate
- Cross-Implementation Agreement: 100% with jam-rust
Continuous Integration
Section titled “Continuous Integration”Conformance tests run automatically in CI/CD:
GitHub Actions Workflow
Section titled “GitHub Actions Workflow”name: Conformance Testson: [push, pull_request]jobs: test: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 with: submodules: recursive
- name: Setup Java uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '17'
- name: Setup Rust uses: actions-rs/toolchain@v1 with: toolchain: stable
- name: Run Tests run: sbt test
- name: Start Conformance Server run: sbt "conformance/run" &
- name: Run Fuzzing run: | cd jam-conformance python3 scripts/fuzz-workflow.py --target jam-forge --blocks 1000Debugging Conformance Issues
Section titled “Debugging Conformance Issues”Enable Verbose Logging
Section titled “Enable Verbose Logging”# Run with debug loggingLOG_LEVEL=debug sbt test
# Enable Rust library loggingRUST_LOG=debug sbt testTrace State Transitions
Section titled “Trace State Transitions”# Run specific test with state tracingsbt "protocol/testOnly *SafroleTest -- -Dtrace=true"Compare State Dumps
Section titled “Compare State Dumps”# Export state before and after transitionsbt "test:runMain io.forge.jam.conformance.StateDumper input.bin output.bin"Resources
Section titled “Resources”- JAM Implementation Guide - Implementation guidance
- Test Vectors - Official test vectors
- Conformance Framework - Fuzzing and validation tools
- Gray Paper - Protocol specification
Reporting Issues
Section titled “Reporting Issues”If you discover a conformance issue:
- Verify against latest test vectors
- Check if issue exists in other implementations
- Create minimal reproduction case
- Report on GitHub with:
- Test vector or input data
- Expected vs. actual output
- Relevant logs and traces