From 5d02ad6b893f9059044914c115d77cf9d8e589c3 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 8 Jan 2026 11:20:35 +0000 Subject: 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 --- tests/sync/live_sync.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'tests/sync/live_sync.rs') diff --git a/tests/sync/live_sync.rs b/tests/sync/live_sync.rs index 7fa08a0..8ee3119 100644 --- a/tests/sync/live_sync.rs +++ b/tests/sync/live_sync.rs @@ -115,7 +115,7 @@ async fn test_live_sync_layer2_events() { // 9. Wait and verify event syncs to relay_b let filter = Filter::new() - .kind(Kind::Custom(KIND_ISSUE)) + .kind(Kind::GitIssue) .author(keys.public_key()) .id(issue_id); @@ -237,7 +237,7 @@ async fn test_live_sync_layer3_events() { // 6. Now wait for issue to sync to relay_b (this triggers Layer 3 filter creation) tokio::time::sleep(Duration::from_secs(2)).await; - let issue_filter = Filter::new().kind(Kind::Custom(KIND_ISSUE)).id(issue_id); + let issue_filter = Filter::new().kind(Kind::GitIssue).id(issue_id); let issue_synced = wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(3)).await; println!("Issue synced to relay_b: {}", issue_synced); @@ -247,7 +247,7 @@ async fn test_live_sync_layer3_events() { // 7. Wait and verify comment syncs to relay_b let comment_filter = Filter::new() - .kind(Kind::Custom(KIND_COMMENT)) + .kind(Kind::Comment) .author(keys.public_key()) .id(comment_id); @@ -267,9 +267,7 @@ async fn test_live_sync_layer3_events() { client.connect().await; tokio::time::sleep(Duration::from_millis(500)).await; - let fetch_filter = Filter::new() - .kind(Kind::Custom(KIND_COMMENT)) - .id(comment_id); + let fetch_filter = Filter::new().kind(Kind::Comment).id(comment_id); if let Ok(events) = client .fetch_events(fetch_filter, Duration::from_secs(2)) @@ -418,9 +416,7 @@ async fn test_live_sync_event_ordering() { client.connect().await; tokio::time::sleep(Duration::from_millis(500)).await; - let filter = Filter::new() - .kind(Kind::Custom(KIND_ISSUE)) - .author(keys.public_key()); + let filter = Filter::new().kind(Kind::GitIssue).author(keys.public_key()); match client.fetch_events(filter, Duration::from_secs(3)).await { Ok(events) => { -- cgit v1.2.3