Version: 0.1.0
Status: Draft (Alpha)
This document defines the testing strategy for the Proof‑of‑Contribution Protocol Core.
- All protocol behavior is deterministic
- All implementations behave identically
- All scoring rules are reproducible
- All validators are predictable
- All proofs are consistent across environments
- Auditors can independently verify correctness
This strategy applies to all languages, implementations, and integrators.
Every test must assert that the same input always produces the same output.
Tests must avoid:
- External APIs
- Network calls
- System time
- Randomness
- Environment‑dependent behavior
JS, Python, and Rust implementations must produce identical results for the same fixtures.
Fixtures must be:
- Small
- Clear
- Versioned
- Easy to reason about
Tests must cover:
- Validation
- Scoring
- Proof generation
- Error handling
- Edge cases
- Versioning behavior
Test individual pure functions.
Examples:
- validateEvent()
- scoreEvent()
- generateProof()
- timestampSanityCheck()
- applyScoringRule()
Unit tests must:
- Use minimal fixtures
- Assert exact output shape
- Assert exact error messages
- Assert no side effects
Test the full pipeline end‑to‑end.
Flow:
Event → Validation → Scoring → Proof
Integration tests must:
- Use real fixtures
- Assert deterministic ordering
- Assert rule evaluation order
- Assert proof structure
These ensure all implementations behave identically.
Languages:
- JavaScript
- Python
- Rust
Each implementation must:
- Load the same fixtures
- Produce byte‑for‑byte identical JSON outputs
- Fail identically on invalid events
This is essential for ecosystem trust.
Every bug must produce a new test.
Regression tests must:
- Reproduce the bug
- Assert the fix
- Prevent future regressions
Security tests must cover:
- Replay protection
- Timestamp boundaries
- Invalid payloads
- Malformed events
- Rule injection attempts
- Validator bypass attempts
These tests ensure the protocol is safe for integrators.
Fixtures live in:
tests/fixtures/
Fixtures must include:
- Code commit
- Documentation update
- Governance vote
- RFC submission
- Community support
- Missing fields
- Invalid types
- Invalid timestamps
- Malformed payloads
- Boundary timestamps
- Empty payloads
- Unknown contribution types
- Multiple rules applying simultaneously
Every test must assert:
- Exact JSON structure
- Exact field names
- Exact score values
- Exact rule order
- Exact error messages
- Exact version numbers
Example:
json { "eventid": "evt001", "score": 5, "rulesapplied": ["codecommit_base"], "version": "0.1.0" }
No fuzzy matching.
No partial matching.
No approximate comparisons.
####:5. Versioning Tests
Tests must ensure:
- Rule versions are correct
- Breaking changes bump MAJOR version
- New rules bump MINOR version
- Fixes bump PATCH version
Versioning is part of determinism.
CI must:
- Run all tests
- Run linting
- Run type checks
- Run cross‑language conformance tests
- Fail on nondeterministic behavior
- Fail on missing tests
- Fail on untested rule changes
Minimum coverage:
- 90%+ for core modules
- 100% for scoring rules
- 100% for validators
- 100% for proof generation
Scoring rules and validators are protocol‑critical and must be fully covered.
If a test fails:
- No merges allowed
- Maintainers must investigate
- Root cause must be documented
- Regression test must be added
- Version bump must be evaluated
This deterministic test strategy is now ready for use by contributors, maintainers, auditors, and integrators.