Testing Guide
Testing Guide
Section titled “Testing Guide”Testing Philosophy
Section titled “Testing Philosophy”The JAM Scala implementation uses multiple testing strategies to ensure correctness:
- Test Vector Compliance: Official
jamtestvectorsvalidate protocol conformance - Unit Tests: Component-level testing with ScalaTest
- Property-Based Testing: ScalaCheck for codec laws and invariants
- Integration Tests: End-to-end block import and state transitions
- Conformance Testing: Cross-implementation validation via fuzzing
Test Organization
Section titled “Test Organization”Module Structure
Section titled “Module Structure”modules/├── core/src/test/scala/│ ├── codec/ # Encoding/decoding tests│ ├── types/ # Type validation tests│ └── ShuffleTest.scala├── crypto/src/test/scala/│ ├── BandersnatchTest.scala│ ├── Ed25519Test.scala│ └── ErasureCodingTest.scala├── pvm/src/test/scala/│ ├── opcodes/ # Instruction tests│ └── execution/ # VM execution tests├── protocol/src/test/scala/│ ├── safrole/ # Safrole STF tests│ ├── statistics/ # Statistics STF tests│ └── traces/ # Full block import tests└── conformance/src/test/scala/ └── integration/ # Conformance server testsRunning Tests
Section titled “Running Tests”All Tests
Section titled “All Tests”# Run all tests across all modulessbt test
# Run with specific log levelLOG_LEVEL=debug sbt test
# Run with detailed outputsbt "testOnly * -- -oF"Module-Specific Tests
Section titled “Module-Specific Tests”# Run tests for a single modulesbt "core/test"sbt "crypto/test"sbt "protocol/test"sbt "pvm/test"sbt "conformance/test"Individual Test Classes
Section titled “Individual Test Classes”# Run a specific test classsbt "testOnly io.forge.jam.core.ShuffleTest"sbt "testOnly io.forge.jam.protocol.safrole.SafroleTransitionTest"
# Run multiple test classessbt "testOnly io.forge.jam.core.*CodecTest"Test Pattern Matching
Section titled “Test Pattern Matching”# Run tests matching a patternsbt "testOnly *Safrole*"sbt "testOnly *Codec*"
# Run tests in a specific packagesbt "testOnly io.forge.jam.protocol.statistics.*"Test Vectors
Section titled “Test Vectors”Official Test Vectors
Section titled “Official Test Vectors”Located in jamtestvectors/ submodule:
jamtestvectors/├── codec/ # Binary encoding test cases├── erasure/ # Erasure coding vectors├── shuffle/ # Validator shuffle vectors└── stf/ # State transition vectors ├── safrole/ ├── statistics/ ├── authorizations/ ├── assurances/ ├── reports/ ├── disputes/ ├── history/ └── preimages/Conformance Testing
Section titled “Conformance Testing”Local Conformance Server
Section titled “Local Conformance Server”The conformance server provides a Unix socket interface for testing:
# Start serversbt "conformance/run"
Running Conformance Tests
Section titled “Running Conformance Tests”# From jam-conformance directorycd jam-conformance/scripts
# Run fuzzing against Scala implementationpython3 fuzz-workflow.py --target jam-forge --mode exploratory
# Run with trace outputpython3 fuzz-workflow.py --target jam-forge --mode traceBenchmarking
Section titled “Benchmarking”Running Benchmarks
Section titled “Running Benchmarks”# Run benchmark suitesbt benchmark
# This executes TracesBenchmarkCoverage Goals
Section titled “Coverage Goals”- Core module: >90% line coverage
- Protocol module: >85% line coverage
- Crypto module: >80% (native code excluded)
- PVM module: >80% line coverage
Continuous Integration
Section titled “Continuous Integration”GitHub Actions
Section titled “GitHub Actions”Tests run automatically on:
- Push to main branch
- Pull requests
- Scheduled nightly builds