upleb.uk

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

summaryrefslogtreecommitdiff
path: root/tests/sync/historic_sync.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-01-08 11:20:35 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-01-08 11:23:28 +0000
commit5d02ad6b893f9059044914c115d77cf9d8e589c3 (patch)
treeb727f9c44d2f2d4e203dc2344e4c9bd5144a77dd /tests/sync/historic_sync.rs
parent075307804bf66bba10f5bc55cb40e2e6a98a65ee (diff)
refactor: replace hardcoded Kind constants with rust-nostr variants
- 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
Diffstat (limited to 'tests/sync/historic_sync.rs')
-rw-r--r--tests/sync/historic_sync.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/tests/sync/historic_sync.rs b/tests/sync/historic_sync.rs
index c388a7f..aec2819 100644
--- a/tests/sync/historic_sync.rs
+++ b/tests/sync/historic_sync.rs
@@ -29,7 +29,7 @@ async fn test_bootstrap_syncs_existing_layer2_events() {
29 29
30 // Verify announcement synced to syncing relay 30 // Verify announcement synced to syncing relay
31 let filter = Filter::new() 31 let filter = Filter::new()
32 .kind(Kind::Custom(KIND_REPOSITORY_STATE)) 32 .kind(Kind::GitRepoAnnouncement)
33 .author(result.maintainer_keys.public_key()); 33 .author(result.maintainer_keys.public_key());
34 34
35 let synced = 35 let synced =
@@ -64,7 +64,7 @@ async fn test_relay_replays_events_after_restart() {
64 64
65 // Verify announcement synced on first run 65 // Verify announcement synced on first run
66 let filter = Filter::new() 66 let filter = Filter::new()
67 .kind(Kind::Custom(KIND_REPOSITORY_STATE)) 67 .kind(Kind::GitRepoAnnouncement)
68 .author(result.maintainer_keys.public_key()); 68 .author(result.maintainer_keys.public_key());
69 69
70 let synced_first = wait_for_event_on_relay( 70 let synced_first = wait_for_event_on_relay(
@@ -173,7 +173,7 @@ async fn test_announcement_not_listing_relay_is_not_synced() {
173 173
174 // Verify announcement did NOT sync to syncing relay 174 // Verify announcement did NOT sync to syncing relay
175 let filter = Filter::new() 175 let filter = Filter::new()
176 .kind(Kind::Custom(KIND_REPOSITORY_STATE)) 176 .kind(Kind::GitRepoAnnouncement)
177 .author(keys.public_key()); 177 .author(keys.public_key());
178 178
179 let synced = wait_for_event_on_relay(syncing.url(), filter, Duration::from_secs(2)).await; 179 let synced = wait_for_event_on_relay(syncing.url(), filter, Duration::from_secs(2)).await;
@@ -274,7 +274,7 @@ async fn test_history_sync_without_negentropy() {
274 274
275 // Verify announcement synced to syncing relay via HISTORY sync 275 // Verify announcement synced to syncing relay via HISTORY sync
276 let filter = Filter::new() 276 let filter = Filter::new()
277 .kind(Kind::Custom(KIND_REPOSITORY_STATE)) 277 .kind(Kind::GitRepoAnnouncement)
278 .author(keys.public_key()); 278 .author(keys.public_key());
279 279
280 let synced = wait_for_event_on_relay(syncing.url(), filter, Duration::from_secs(5)).await; 280 let synced = wait_for_event_on_relay(syncing.url(), filter, Duration::from_secs(5)).await;
@@ -339,7 +339,7 @@ async fn test_pagination_for_large_historic_sync() {
339 // Create 40 issue events to test pagination (with limit=10, threshold=7) 339 // Create 40 issue events to test pagination (with limit=10, threshold=7)
340 let repo_coord = format!( 340 let repo_coord = format!(
341 "{}:{}:{}", 341 "{}:{}:{}",
342 KIND_REPOSITORY_STATE, 342 Kind::GitRepoAnnouncement.as_u16(),
343 keys.public_key().to_hex(), 343 keys.public_key().to_hex(),
344 repo_id 344 repo_id
345 ); 345 );
@@ -416,16 +416,14 @@ async fn test_pagination_for_large_historic_sync() {
416 416
417 // Verify announcement synced 417 // Verify announcement synced
418 let announcement_filter = Filter::new() 418 let announcement_filter = Filter::new()
419 .kind(Kind::Custom(KIND_REPOSITORY_STATE)) 419 .kind(Kind::GitRepoAnnouncement)
420 .author(keys.public_key()); 420 .author(keys.public_key());
421 421
422 let announcement_synced = 422 let announcement_synced =
423 wait_for_event_on_relay(syncing.url(), announcement_filter, Duration::from_secs(3)).await; 423 wait_for_event_on_relay(syncing.url(), announcement_filter, Duration::from_secs(3)).await;
424 424
425 // Verify ALL 40 issues synced 425 // Verify ALL 40 issues synced
426 let issues_filter = Filter::new() 426 let issues_filter = Filter::new().kind(Kind::GitIssue).author(keys.public_key());
427 .kind(Kind::Custom(KIND_ISSUE))
428 .author(keys.public_key());
429 427
430 // Query for all issues 428 // Query for all issues
431 let temp_keys = Keys::generate(); 429 let temp_keys = Keys::generate();