upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tests/common
AgeCommit message (Collapse)Author
2026-02-26chore: apply cargo fmt and fix clippy warningsDanConwayDev
Fix pre-existing clippy lints: - &PathBuf -> &Path in audit_cleanup.rs - too_many_arguments on process_newly_available_git_data, process_purgatory_announcements, and HttpService::new - clone_on_copy for PublicKey (Copy type) in purgatory cleanup loop
2026-02-23persist and restore announcement events across graceful restartsDanConwayDev
Extends purgatory persistence to include announcement purgatory entries. On graceful shutdown, non-soft-expired announcements are serialised to purgatory-state.json alongside state/PR/expired events; on startup they are restored, skipping any entry whose bare repo path no longer exists. Updates purgatory-design.md to reflect that purgatory persists through graceful shutdown and documents the new PurgatoryState disk format. Adds create_announcement_event helper to purgatory_helpers and three new integration tests in purgatory_persistence covering the full save/restore cycle, missing-repo skip, and the combined roundtrip with all entry types.
2026-02-23refactor: replace inline purgatory sync registration with timer-only approachDanConwayDev
Remove the redundant inline kind-30617 registration block from the sync event loop and the three is_generic/recompute_new_sync_filters_for_relay calls from confirm_batch error paths. The purgatory announcement sync timer (run_purgatory_announcement_sync) is now the sole registration path. Consolidate NGIT_SYNC_BATCH_WINDOW_MS and NGIT_PURGATORY_SYNC_INTERVAL_MS into a single NGIT_TEST=1 flag that sets both timers to 200ms, replacing two ad-hoc env vars with one reusable test-mode flag.
2026-02-23test: update sync tests to set up git data for purgatory flowDanConwayDev
All sync tests now create a local git repo, send announcement + state event to the source relay, and push git data to release both from purgatory before the syncing relay starts bootstrap sync.
2026-02-18test: update run_sync_test to use push_to_relay for purgatory flowDanConwayDev
Previously run_sync_test used a SmartGitServer external to the relay, but never pushed to the source relay itself. With the announcement purgatory feature, announcements stay in purgatory until git data arrives. By using push_to_relay to the source relay, both the announcement and state event are released from purgatory before the syncing relay starts, allowing the announcement to be synced.
2026-02-18test: rewrite PR sync tests to reflect purgatory-first announcement flowDanConwayDev
The tests now correctly reflect the actual purgatory behavior: 1. Announcement goes to purgatory (StateOnly) - not immediately accepted 2. State event goes to purgatory 3. Git push promotes announcement to Full and releases state event 4. PR event is sent AFTER announcement promotion (accepted since repo is Full) 5. PR commit push releases PR event from purgatory This matches the design: announcements require git data validation before being promoted to the database, which means PR events can only be accepted for repos with promoted announcements. Also routes relay stdout to /tmp/relay-{port}.log for easier debugging.
2026-01-19fix: archive_read_only creates bare repos for archived announcementsDanConwayDev
Combined Accept and AcceptArchive match arms in builder.rs to ensure bare repositories are created for both cases. Previously AcceptArchive had duplicate code that didn't call ensure_bare_repository(). Also includes: - Config fix: effective_git_data_path() respects explicit paths with memory backend - TestRelay: Added git_data_path() and archive config support for testing - Integration tests for archive_read_only behavior
2026-01-12feat: add uploadpack.allowFilter support for GRASP-01 complianceDanConwayDev
Add mandatory uploadpack.allowFilter capability to support partial clones and fetches as required by GRASP-01 specification. This enables efficient git operations for bandwidth-constrained clients (e.g., browser-based git clients like git-natural-api). Changes: - Add uploadpack.allowFilter=true to git subprocess configuration - Update SmartGitServer test helper with filter support - Add integration tests for filter capability advertisement and functionality - Update documentation to reflect filter as required capability Tests verify: - Filter capability is advertised in info/refs - Filtered clones with blob:none work correctly - Filtered fetches with tree:0 work correctly
2026-01-09fix: eliminate port binding race condition in SimpleGitServerDanConwayDev
SimpleGitServer had a TOCTOU race where find_free_port() would bind a port, immediately release it, then the caller would try to bind it - allowing another process to grab the port in between. This caused intermittent test failures. Changed to bind the port once and keep it bound while converting from std to tokio listener, matching the pattern already used in SmartGitServer. Deleted the now-unused find_free_port() helper function.
2026-01-09chore: cargo fmtDanConwayDev
2026-01-09Fix sync tests after Syncing status introductionDanConwayDev
- Fix relay_connected() helper to check v >= 2 (Syncing/Connected states) - Fix unit test to use status value 3 (Connected) instead of 1 (Connecting) - Fix clippy warning: use .to_vec() instead of .iter().cloned().collect() All 61 sync integration tests now passing. All 238 unit tests passing. Clippy clean.
2026-01-08refactor: replace hardcoded Kind constants with rust-nostr variantsDanConwayDev
- Replace KIND_REPOSITORY_ANNOUNCEMENT with Kind::GitRepoAnnouncement - Replace KIND_REPOSITORY_STATE with Kind::RepoState - Replace KIND_PR with Kind::GitPullRequest - Replace KIND_PR_UPDATE with Kind::GitPullRequestUpdate - Replace KIND_USER_GRASP_LIST with Kind::GitUserGraspList - Replace KIND_PATCH with Kind::GitPatch - Replace KIND_ISSUE with Kind::GitIssue - Replace KIND_COMMENT with Kind::Comment - Replace all Kind::Custom(30617|30618|1617|1618|1619|1621|1111|10317) patterns - Remove all hardcoded KIND_* constants from events.rs - Update all match statements to use Kind enum directly - Update all filter builders to use Kind variants - Update all test helpers and assertions Benefits: - Type safety: compiler prevents wrong kind numbers - Readability: Kind::GitRepoAnnouncement is self-documenting - Maintainability: single source of truth (rust-nostr) - IDE support: full autocompletion and refactoring - Standards: aligns with rust-nostr best practices Files modified: 21 Constants removed: 9 Patterns replaced: 100+ Tests passing: 222/222
2026-01-08chore: upgrade nostr-* packages to rev 4767ad13DanConwayDev
- Update nostr-relay-builder, nostr-sdk, nostr-lmdb to latest revision - Update grasp-audit nostr-sdk dependency - Fix clippy warnings: - Replace .clone() with std::slice::from_ref() in src/git/sync.rs - Change &PathBuf to &Path in tests/common/git_server.rs - Replace vec![] with array literal in src/purgatory/sync/functions.rs - Update PR_TEST_COMMIT_HASH in grasp-audit due to event generation changes All 249 tests passing, no breaking changes required.
2026-01-08chore: cargo fmtDanConwayDev
2026-01-08test: disable GPG signing in all test helpersDanConwayDev
Prevent GPG signing prompts (including Yubikey activation) during test runs by explicitly disabling commit.gpgsign and tag.gpgsign in all test repository creation helpers. Modified: - tests/common/purgatory_helpers.rs: create_test_repo_with_commit() - src/git/mod.rs: create_test_repo_with_commit() - src/purgatory/helpers.rs: create_test_repo_with_commit() All test repositories now have GPG signing disabled regardless of global git configuration.
2026-01-07test: fix hanging unit tests issueDanConwayDev
2026-01-07test: add WIP SmartHttpServer to testDanConwayDev
2026-01-07test: added purgatory git data sync intergration tests agregating from ↵DanConwayDev
mulitple git servers
2026-01-07test: add SimpleGitServer helper for dumb HTTP git servingDanConwayDev
Add a test helper that serves git repositories over HTTP using git's dumb HTTP protocol. This enables integration tests that need to fetch git data from an external URL without requiring a full git HTTP backend. Features: - Creates bare clone of source repository - Runs git update-server-info to generate required metadata - Serves static files over HTTP using hyper - Automatic cleanup on drop - Path traversal protection Tests included: - Server starts and stops correctly - info/refs endpoint is accessible - git ls-remote works against server - git fetch works against server - Path traversal is blocked This helper will be used in Phase 3 to test PR clone tag sync, where the PR event's clone URL points to an external git server that is NOT an ngit-grasp relay.
2026-01-07test: add test_pr_event_syncs_from_remoteDanConwayDev
2026-01-07test: add test_state_event_syncs_from_remote integration testDanConwayDev
Implements Phase 3 of the purgatory sync integration test plan. Key changes: - Add immediate sync triggering for sync-received events that go to purgatory (instead of default 3-minute delay for user-submitted events) - TestRelay now respects RUST_LOG environment variable for debugging - New test verifies end-to-end flow: state event syncs from source relay, enters purgatory, git data is fetched from source's clone URL, and event is released and served
2026-01-07fix: include npub in clone URLs generated by create_repo_announcementDanConwayDev
The clone URL format should be http://{domain}/{npub}/{identifier}.git but was missing the npub segment. This caused git push authorization to fail because the URL didn't match the expected repository path.
2026-01-07Add purgatory sync test helpersDanConwayDev
Add tests/common/purgatory_helpers.rs with utilities for purgatory sync integration tests: - Git repository setup helpers (create_test_repo_with_commit, add_commit_to_repo, create_branch) for deterministic test commits - State event creation (create_state_event) for kind 30618 events with refs/heads/*, refs/tags/*, and HEAD tags - PR event creation (create_pr_event) for kind 1618 events with a and c tags - Purgatory state inspection helpers (wait_for_event_served, verify_event_not_served) for polling event availability - Git ref verification (check_ref_at_commit) for validating remote refs - Push helper (push_to_relay) for pushing local repos to relay All helpers include comprehensive unit tests verifying correct tag structure and git operations.
2026-01-02test: fix issue kind numberDanConwayDev
2025-12-22chore: cargo fmt and clippyDanConwayDev
2025-12-19Simplify sync metrics to track only newly saved eventsDanConwayDev
Replace broken event counting that occurred before duplicate/policy checks with accurate tracking of events that are new, accepted, and saved. Changes: - Added ProcessResult enum to track event processing outcomes - Modified process_event_static() to return ProcessResult - Replaced events_total (with source labels) with events_synced_total - Removed gap_events_total and event_source module - Removed eose_received flag (EOSE is per-subscription, not suitable) - Updated all tests to use new simplified API The new ngit_sync_events_synced_total metric only counts events that: 1. Are new (not duplicates) 2. Pass write policy validation 3. Are successfully saved to database All 165 tests pass (124 lib + 41 integration)
2025-12-18refactor: migrate historic_sync.rs tests to use run_sync_test() helperDanConwayDev
- Refactored all 4 tests in historic_sync.rs to use run_sync_test() - Tests maintain same logic and assertions, only setup simplified - Moved run_sync_test() and SyncTestResult outside #[cfg(test)] module - Updated validation to allow empty event slices (for announcement-only tests) - All 4 historic_sync tests passing (test_bootstrap_syncs_existing_layer2_events, test_relay_replays_events_after_restart, test_announcement_not_listing_relay_is_not_synced, test_history_sync_without_negentropy) - Result: 39/40 tests passing (1 more than Phase 1 baseline of 38/40)
2025-12-18test: add unified run_sync_test() helper infrastructureDanConwayDev
Add SyncTestResult struct and run_sync_test() helper function to sync_helpers.rs for unified test setup. The helper automatically determines sync mode (historic vs live) based on which event slice has content. Features: - SyncTestResult: holds test fixtures (relays, keys, repo_coord) - run_sync_test(): unified setup for both historic and live sync tests - Panic guards for invalid usage (both slices or neither) - Unit tests for panic conditions Test results: 40 tests total, 38 passing (same as baseline) - 2 pre-existing metric test failures (unchanged from baseline) - All new panic condition tests passing - No regressions introduced
2025-12-18sync: turn off negentropy and fix some testsDanConwayDev
2025-12-11fix: resolve all fmt and clippy warningsDanConwayDev
Main lib (src/): - Add #[allow(dead_code)] for build_info field (stored to prevent Prometheus unregistration) - Add #[allow(dead_code)] for first_seen field (reserved for future rate limiting) - Replace .or_insert_with(RelaySyncNeeds::default) with .or_default() - Replace manual div_ceil implementations with .div_ceil(100) Test code (tests/): - Replace .expect(&format!(...)) with .unwrap_or_else(|_| panic!(...)) - Remove needless borrows in fetch_metrics() calls - Add #[allow(dead_code)] and #[allow(unused_imports)] to test helpers module grasp-audit: - Apply cargo fmt to fix formatting
2025-12-11sync: test sync works without negentropy and add disable option in syncDanConwayDev
2025-12-11sync: add sync_base_backoff_secs config for better testingDanConwayDev
2025-12-11fix(sync): improve metrics recording and connection failure detectionDanConwayDev
Changes: - Fix connection attempt metrics: record success/failure based on actual connection result instead of pre-emptively recording failure - Add health tracker integration on connection failure: call record_failure() and record_health_state() in error path - Add connection verification in relay_connection.rs: wait 500ms after connect() then verify is_connected() to detect silent failures - Add configurable disconnect check interval via NGIT_SYNC_DISCONNECT_CHECK_INTERVAL_SECS env var - Update TestRelay with fast test settings: startup_delay=0, jitter=0, disconnect_check_interval=1s - Add debug output to metrics tests for investigation Note: Tests may still fail due to 5-second base backoff in health tracker. A follow-up task will add NGIT_SYNC_BASE_BACKOFF_SECS config parameter to allow faster test cycles. Related: metrics-wiring-plan.md Tasks 1 & 2
2025-12-11Phase 1: Add ParsedMetrics and MetricsTestHarness infrastructureDanConwayDev
2025-12-11refactor: move metrics tests to tests/sync/ structure (Phase 7)DanConwayDev
2025-12-10test(sync): add wait_for_sync_connection helper for improved reliabilityDanConwayDev
2025-12-10refactor(tests): extract shared create_repo_announcement helperDanConwayDev
2025-12-10Phase 5: Migrate bootstrap and discovery testsDanConwayDev
Create organized test structure for proactive sync: tests/common/sync_helpers.rs (from Phase 4): - TestClient with retry logic for connect/send - Event builders: build_layer2_issue_event, build_layer3_comment_event - Tag variants (a/A/q for Layer 2, e/E/q for Layer 3) - wait_for_event_on_relay() assertion helper - repo_coord() utility function - Unit tests for all builders tests/sync/mod.rs: - Module organization for sync tests - Documentation of test categories tests/sync.rs: - Main test harness including common and sync modules tests/sync/bootstrap.rs: - test_bootstrap_syncs_existing_layer2_events (Test 1) - test_relay_replays_events_after_restart (Test 4) tests/sync/discovery.rs: - test_discovers_layer3_via_layer2 (Test 2) - test_layer2_discovery_with_chain (Test 3 - simplified) All 14 tests pass: cargo test --test sync
2025-12-10sync: fix connection registration issueDanConwayDev
2025-12-10improve sync designDanConwayDev
2025-12-08tests: discover and sync from relay in annocunement published directlyDanConwayDev
2025-12-05test: fix proactive sync basic testsDanConwayDev
2025-12-05rename sunc_bootstrap_relay_urlDanConwayDev
2025-12-05fix basic sync testsDanConwayDev
2025-12-04feat(sync): Phase 1 MVP - single relay proactive syncDanConwayDev
- Add src/sync/ module with SyncManager - Add NGIT_SYNC_RELAY_URL config option - Subscribe to kind 30617 on configured relay - Validate synced events through Nip34WritePolicy - Integration test with two TestRelay instances
2025-12-01fix cargo clippy and fmt warningsDanConwayDev
2025-11-21add repository creationDanConwayDev
2025-11-19fix some clippy fmt warningsDanConwayDev
2025-11-04fix: remove nix crate usage from test codeDanConwayDev
Replace nix::sys::signal usage with standard library process::kill(). This completes the removal of the unnecessary nix dev dependency. All tests passing: - NIP-01: 6 passed, 1 ignored - NIP-34: 12 passed, 1 ignored
2025-11-04test: migrate to TestRelay fixture pattern and add compliance docsDanConwayDev
- Remove unnecessary 'nix' dev dependency (Unix syscalls crate, not needed) - Migrate announcement tests to new TestRelay fixture pattern - Delete legacy test files (announcement_tests.rs, test_relay.sh) - Add comprehensive test documentation (docs/how-to/test-compliance.md) - Update README.md with new test commands - All 18 integration tests passing (NIP-01 + NIP-34) Benefits: - Automatic relay lifecycle management - No manual setup required - Pure Rust integration tests - Better developer experience - CI/CD ready