diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-23 15:41:32 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-23 15:41:32 +0000 |
| commit | c54ce061d6d278cce8362d5af085808ca60c239b (patch) | |
| tree | ec967d6195d9f7ec4f061449596611afe3a0950f /tests/common/relay.rs | |
| parent | e0ad39a489b3398f8208713bf728db0cb11475b0 (diff) | |
| parent | 113928aa84894ea8f65c247d9987527e792b32a9 (diff) | |
feat: announcement purgatory
Extends purgatory to hold repository announcements until git data arrives,
preventing empty repositories from being served to clients.
When an announcement is received, a bare repo is created immediately and the
announcement is held in purgatory. It is only promoted and served once a git
push confirms real content exists. If no push arrives before expiry, the bare
repo is deleted and the announcement is silently discarded.
Key behaviours:
- Soft expiry: announcements are hidden from clients but kept alive while git
pushes are in progress, reviving on successful push
- Expiry is extended when a matching state event or git push is observed
- NIP-09 deletion events remove announcements from purgatory
- Purgatory state (announcements, state events, PR events, expired set) is
persisted to disk on graceful shutdown and restored on startup, with elapsed
downtime subtracted from expiry deadlines
- Purgatory announcements drive StateOnly sync in the sync system so state
events are fetched from listed relays before promotion
- SyncLevel added to RepoSyncIndex to distinguish purgatory repos (StateOnly)
from promoted repos (Full L2+L3 sync)
Diffstat (limited to 'tests/common/relay.rs')
| -rw-r--r-- | tests/common/relay.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/common/relay.rs b/tests/common/relay.rs index 227849a..b1e96cf 100644 --- a/tests/common/relay.rs +++ b/tests/common/relay.rs | |||
| @@ -204,7 +204,7 @@ impl TestRelay { | |||
| 204 | .env("NGIT_GIT_DATA_PATH", git_data_dir.path()) | 204 | .env("NGIT_GIT_DATA_PATH", git_data_dir.path()) |
| 205 | .env("NGIT_DATABASE_BACKEND", "memory") // Force in-memory database for isolation | 205 | .env("NGIT_DATABASE_BACKEND", "memory") // Force in-memory database for isolation |
| 206 | .env("NGIT_OWNER_NPUB", &test_npub) | 206 | .env("NGIT_OWNER_NPUB", &test_npub) |
| 207 | .env("NGIT_SYNC_BATCH_WINDOW_MS", "200") // Fast batch window for tests (200ms instead of 5s default) | 207 | .env("NGIT_TEST", "1") // Enable test mode: fast timers (200ms batch window, 200ms purgatory sync) |
| 208 | .env("NGIT_SYNC_STARTUP_DELAY_SECS", "0") // No startup delay for faster tests | 208 | .env("NGIT_SYNC_STARTUP_DELAY_SECS", "0") // No startup delay for faster tests |
| 209 | .env("NGIT_SYNC_STARTUP_JITTER_MS", "0") // No jitter for tests | 209 | .env("NGIT_SYNC_STARTUP_JITTER_MS", "0") // No jitter for tests |
| 210 | .env("NGIT_SYNC_DISCONNECT_CHECK_INTERVAL_SECS", "1") // Fast reconnect attempts for tests | 210 | .env("NGIT_SYNC_DISCONNECT_CHECK_INTERVAL_SECS", "1") // Fast reconnect attempts for tests |
| @@ -213,8 +213,15 @@ impl TestRelay { | |||
| 213 | "RUST_LOG", | 213 | "RUST_LOG", |
| 214 | std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string()), | 214 | std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string()), |
| 215 | ) // Use RUST_LOG from environment or default to info | 215 | ) // Use RUST_LOG from environment or default to info |
| 216 | .stdout(Stdio::null()) // Suppress stdout for cleaner test output | 216 | .stdout( |
| 217 | .stderr(Stdio::null()); // Suppress stderr for cleaner test output | 217 | std::fs::OpenOptions::new() |
| 218 | .create(true) | ||
| 219 | .append(true) | ||
| 220 | .open(format!("/tmp/relay-{}.log", port)) | ||
| 221 | .map(Stdio::from) | ||
| 222 | .unwrap_or(Stdio::null()), | ||
| 223 | ) | ||
| 224 | .stderr(Stdio::inherit()); // Inherit stderr for test output | ||
| 218 | 225 | ||
| 219 | // Add bootstrap relay URL if provided | 226 | // Add bootstrap relay URL if provided |
| 220 | if let Some(ref bootstrap_url) = bootstrap_relay_url { | 227 | if let Some(ref bootstrap_url) = bootstrap_relay_url { |