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/sync/historic_sync.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/sync/historic_sync.rs')
| -rw-r--r-- | tests/sync/historic_sync.rs | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/tests/sync/historic_sync.rs b/tests/sync/historic_sync.rs index aec2819..723b776 100644 --- a/tests/sync/historic_sync.rs +++ b/tests/sync/historic_sync.rs | |||
| @@ -224,34 +224,24 @@ async fn test_history_sync_without_negentropy() { | |||
| 224 | // Create keys | 224 | // Create keys |
| 225 | let keys = Keys::generate(); | 225 | let keys = Keys::generate(); |
| 226 | 226 | ||
| 227 | // Create announcement listing BOTH relay domains | 227 | // Set up announcement on source with git data |
| 228 | // This event will exist on source BEFORE syncing relay ever connects | 228 | // (purgatory requires git data before announcements are accepted) |
| 229 | let announcement = create_repo_announcement( | 229 | let domains = vec![source.domain(), syncing_domain.clone()]; |
| 230 | let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect(); | ||
| 231 | let (announcement, _git_dir) = setup_announcement_on_relay( | ||
| 232 | &source, | ||
| 230 | &keys, | 233 | &keys, |
| 231 | &[&source.domain(), &syncing_domain], | 234 | &domain_refs, |
| 232 | "test-repo-history-no-negentropy", | 235 | "test-repo-history-no-negentropy", |
| 233 | ); | 236 | ) |
| 237 | .await; | ||
| 234 | let announcement_id = announcement.id; | 238 | let announcement_id = announcement.id; |
| 235 | 239 | ||
| 236 | println!( | 240 | println!( |
| 237 | "Created announcement {} (kind {})", | 241 | "Announcement {} set up on source with git data (event exists BEFORE syncing relay connects)", |
| 238 | announcement_id, | 242 | announcement_id |
| 239 | announcement.kind.as_u16() | ||
| 240 | ); | 243 | ); |
| 241 | 244 | ||
| 242 | // Send announcement to source (event now exists BEFORE syncing relay connects) | ||
| 243 | let client = TestClient::new(source.url(), keys.clone()) | ||
| 244 | .await | ||
| 245 | .expect("Failed to connect to source"); | ||
| 246 | |||
| 247 | client | ||
| 248 | .send_event(&announcement) | ||
| 249 | .await | ||
| 250 | .expect("Failed to send announcement to source"); | ||
| 251 | println!("Announcement sent to source (event exists BEFORE syncing relay connects)"); | ||
| 252 | |||
| 253 | client.disconnect().await; | ||
| 254 | |||
| 255 | // Wait to ensure event is stored | 245 | // Wait to ensure event is stored |
| 256 | tokio::time::sleep(Duration::from_millis(500)).await; | 246 | tokio::time::sleep(Duration::from_millis(500)).await; |
| 257 | 247 | ||