This document provides testing guidance for developers working on the Palpo project, covering test types, execution methods, and project-specific testing requirements.
- Test Types
- Running Tests
- Writing Tests
- Testing Tools
- CI/CD Pipeline
- Common Issues
- Reference Resources
Location: tests.rs modules within source files
Examples:
crates/core/src/metadata/tests.rs- Metadata testscrates/core/src/signatures/tests.rs- Signature verification testscrates/core/src/state/tests.rs- State resolution testscrates/core/src/state/event_auth/tests.rs- Event authorization tests
Characteristics:
- Test individual functions or modules
- Fast execution (seconds)
- No external dependencies required
Description: Official Matrix specification compliance test suite written in Go.
Location: tests/complement/
Contents:
- Client-Server API tests (CSAPI)
- Matrix Spec Change tests (MSC)
- Docker build configurations and startup scripts
Purpose: Verify that Palpo implementation complies with Matrix specifications.
Details: See tests/README.md and Complement repository.
Description: Another Matrix specification test framework providing additional compatibility verification.
Location: tests/sytest/
Contents:
sytest-whitelist- List of passed testssytest-blacklist- List of failed testsare-we-synapse-yet.py- Test result analysis tool
Purpose: Supplemental verification of Matrix specification compatibility.
# Run all tests
cargo test --all --all-features
# Run tests for a specific crate
cargo test -p palpo-core
# Run specific test
cargo test test_name
# Show test output (including println! etc.)
cargo test -- --nocapture
# Run tests without fast fail (show all failures)
cargo test --no-fail-fastPrerequisites:
- Install Docker
- Clone Complement repository
# Clone Complement
git clone https://github.com/matrix-org/complement.git ../complement
# Run tests
bash ./tests/complement.sh ../complement test.log test.jsonlTest Process:
- Build base Docker image (
complement-palpo-base) - Build test Docker image (
complement-palpo-test) - Run Go test suite
- Generate test logs (
test.log) and result files (test.jsonl)
Prerequisites:
- Install Docker
- Clone SyTest and configuration repositories
# Clone repositories
git clone https://github.com/matrix-org/sytest.git ../sytest
git clone https://github.com/palpo-im/sytest-palpo.git ../sytest-palpo
# Run tests
bash ./tests/run-sytest.shTest Output:
- Test logs stored in
tests/sytestout/logs/ - Use
tests/sytest/are-we-synapse-yet.pyto analyze results
Run complete quality checks before committing code:
# 1. Code formatting check
cargo fmt --all -- --check
# 2. Code formatting (auto-fix)
cargo +nightly fmt --all
# 3. Clippy static analysis
cargo clippy --all --all-features -- -D warnings
# 4. Build check
cargo check --all --bins --examples --tests
# 5. Release build check
cargo check --all --bins --examples --tests --release
# 6. Run all tests
cargo test --all --all-features --no-fail-fast
# 7. Spell check
typosAccording to CONTRIBUTING.md requirements:
-
Add tests for new features
- Add unit tests for new functions and modules
- Add integration tests for API endpoints
-
Test coverage
- Test success paths
- Test error paths
-
Use descriptive test names
- Test names should clearly indicate test content
Basic unit test structure:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_function_name() {
// Test success scenario
let result = function_to_test(valid_input);
assert!(result.is_ok());
// Test error scenario
let result = function_to_test(invalid_input);
assert!(result.is_err());
}
}The project provides test utility functions in crates/core/src/test_utils.rs:
Available Functions:
alice(),bob()- Create test usersroom_id()- Create test room IDevent_id()- Create test event IDto_pdu_event()- Create PDU eventTestStore- Mock event storagedo_check()- State resolution verificationINITIAL_EVENTS()- Initialize test events
Usage Example:
use crate::test_utils::{alice, bob, room_id};
#[test]
fn test_room_membership() {
let user = alice(); // Create test user Alice
let room = room_id(); // Create test room ID
let event = to_pdu_event(/* ... */); // Create PDU event
// Use test utility functions
let result = process_event(&event);
assert!(result.is_ok());
}The project uses insta for snapshot testing:
use insta::assert_snapshot;
#[test]
fn test_signature_output() {
let signature = generate_signature();
insta::assert_snapshot!(signature);
}Snapshot Testing Workflow:
# Run tests
cargo test
# If snapshots don't match, review differences
cargo insta review
# Accept new snapshots (if changes are expected)
cargo insta accept
# Reject changes
cargo insta rejectThe project uses .github/workflows/quality-control.yml for automated testing.
Trigger Conditions:
- Pull Request (opened, synchronized, reopened)
- Push to
mainbranch - Triggered only when the following files change:
**.rs- Rust source files**/Cargo.toml- Dependency configuration.github/workflows/**- Workflow configuration
Test Tasks:
- Spell Check (typos)
- Build Check
- Debug version:
cargo check --all --bins --examples --tests - Release version:
cargo check --all --bins --examples --tests --release
- Debug version:
- Run Tests
- Command:
cargo test --all --all-features --no-fail-fast -- --nocapture - Timeout: 40 minutes
- Command:
Test Environment:
- Operating System: Ubuntu Latest
- Rust Version: Stable
- Architecture: x86_64-unknown-linux-gnu
Issue: Tests require PostgreSQL but it's not installed or running.
Solution:
# Ubuntu/Debian
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql
# macOS
brew install postgresql
brew services start postgresqlIssue: Docker image build fails or doesn't exist.
Solution:
# Clean old images
docker rmi complement-palpo-base complement-palpo-test
# Re-run test script (will automatically rebuild)
bash ./tests/complement.sh ../complement test.log test.jsonlIssue: Some tests take too long to run.
Solution:
# Reduce concurrent threads
cargo test -- --test-threads=1 --nocapture
# Or run specific test
cargo test specific_test_nameIssue: insta snapshot tests fail.
Solution:
# Review snapshot differences
cargo insta review
# If changes are expected, accept new snapshots
cargo insta acceptIssue: Code doesn't comply with Clippy standards.
Solution:
# View detailed warnings
cargo clippy --all --all-features
# Auto-fix some issues
cargo clippy --fix --all --all-featuresNote: The project configures allowed warnings in Cargo.toml (such as result_large_err, type_complexity, etc.). Only unconfigured warnings will cause build failures.
Issue: typos tool detects spelling errors.
Solution:
# View spelling errors
typos
# If it's a proper noun, add to typos.toml configuration
# See typos.toml file in project root- CONTRIBUTING.md - Project contribution guide
- tests/README.md - Complement test documentation
- Rust Testing Documentation
- Complement Test Framework
- SyTest Test Framework
- Matrix Specification
Last Updated: 2026 Maintainer: Palpo Development Team