diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-07 15:39:48 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-07 15:39:48 +0000 |
| commit | 1db877d53c4ff45971c69fecc5165c352ec316c9 (patch) | |
| tree | 4e63366e49430320117ac7d207b9c2f034f8f7b5 /src | |
| parent | 7dcbc84806e7b3000835eb9132dfc4e9003e382a (diff) | |
test: add test_state_event_syncs_from_remote integration test
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/purgatory/mod.rs | 3 | ||||
| -rw-r--r-- | src/sync/mod.rs | 34 |
2 files changed, 37 insertions, 0 deletions
diff --git a/src/purgatory/mod.rs b/src/purgatory/mod.rs index 7045923..894c941 100644 --- a/src/purgatory/mod.rs +++ b/src/purgatory/mod.rs | |||
| @@ -189,6 +189,8 @@ impl Purgatory { | |||
| 189 | /// | 189 | /// |
| 190 | /// Automatically enqueues the identifier for background sync with the default delay | 190 | /// Automatically enqueues the identifier for background sync with the default delay |
| 191 | /// (3 minutes), giving time for a git push to arrive after the nostr event. | 191 | /// (3 minutes), giving time for a git push to arrive after the nostr event. |
| 192 | /// For sync-triggered events, the SyncManager calls `enqueue_sync_immediate` separately | ||
| 193 | /// to override this delay. | ||
| 192 | /// | 194 | /// |
| 193 | /// # Arguments | 195 | /// # Arguments |
| 194 | /// * `event` - The state event (kind 30618) to hold | 196 | /// * `event` - The state event (kind 30618) to hold |
| @@ -210,6 +212,7 @@ impl Purgatory { | |||
| 210 | .push(entry); | 212 | .push(entry); |
| 211 | 213 | ||
| 212 | // Enqueue for background sync with default delay | 214 | // Enqueue for background sync with default delay |
| 215 | // (SyncManager will call enqueue_sync_immediate for sync-triggered events) | ||
| 213 | self.enqueue_sync_default(&identifier); | 216 | self.enqueue_sync_default(&identifier); |
| 214 | } | 217 | } |
| 215 | 218 | ||
diff --git a/src/sync/mod.rs b/src/sync/mod.rs index b56b6b7..7d60ea4 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs | |||
| @@ -1046,6 +1046,40 @@ impl SyncManager { | |||
| 1046 | } | 1046 | } |
| 1047 | } | 1047 | } |
| 1048 | 1048 | ||
| 1049 | // For sync-triggered events that go to purgatory, trigger immediate sync | ||
| 1050 | // (instead of the default 3-minute delay for user-submitted events) | ||
| 1051 | if result == ProcessResult::Purgatory { | ||
| 1052 | // State events (kind 30618) - extract identifier and trigger immediate sync | ||
| 1053 | if event.kind.as_u16() == 30618 { | ||
| 1054 | if let Some(identifier) = event.tags.iter().find_map(|tag| { | ||
| 1055 | let tag_vec = tag.clone().to_vec(); | ||
| 1056 | if tag_vec.len() >= 2 && tag_vec[0] == "d" { | ||
| 1057 | Some(tag_vec[1].clone()) | ||
| 1058 | } else { | ||
| 1059 | None | ||
| 1060 | } | ||
| 1061 | }) { | ||
| 1062 | tracing::debug!( | ||
| 1063 | event_id = %event.id, | ||
| 1064 | identifier = %identifier, | ||
| 1065 | "Triggering immediate sync for synced state event in purgatory" | ||
| 1066 | ); | ||
| 1067 | write_policy.purgatory().enqueue_sync_immediate(&identifier); | ||
| 1068 | } | ||
| 1069 | } | ||
| 1070 | // PR events (kind 1617/1618) - extract identifier from 'a' tag | ||
| 1071 | else if event.kind.as_u16() == 1617 || event.kind.as_u16() == 1618 { | ||
| 1072 | if let Some(identifier) = crate::git::sync::extract_identifier_from_pr_event(&event) { | ||
| 1073 | tracing::debug!( | ||
| 1074 | event_id = %event.id, | ||
| 1075 | identifier = %identifier, | ||
| 1076 | "Triggering immediate sync for synced PR event in purgatory" | ||
| 1077 | ); | ||
| 1078 | write_policy.purgatory().enqueue_sync_immediate(&identifier); | ||
| 1079 | } | ||
| 1080 | } | ||
| 1081 | } | ||
| 1082 | |||
| 1049 | // Track pagination state for this subscription | 1083 | // Track pagination state for this subscription |
| 1050 | if result == ProcessResult::Saved || result == ProcessResult::Duplicate { | 1084 | if result == ProcessResult::Saved || result == ProcessResult::Duplicate { |
| 1051 | let mut pending = pending_sync_index.write().await; | 1085 | let mut pending = pending_sync_index.write().await; |