diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-08 11:20:35 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-08 11:23:28 +0000 |
| commit | 5d02ad6b893f9059044914c115d77cf9d8e589c3 (patch) | |
| tree | b727f9c44d2f2d4e203dc2344e4c9bd5144a77dd /tests/sync/live_sync.rs | |
| parent | 075307804bf66bba10f5bc55cb40e2e6a98a65ee (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/live_sync.rs')
| -rw-r--r-- | tests/sync/live_sync.rs | 14 |
1 files changed, 5 insertions, 9 deletions
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() { | |||
| 115 | 115 | ||
| 116 | // 9. Wait and verify event syncs to relay_b | 116 | // 9. Wait and verify event syncs to relay_b |
| 117 | let filter = Filter::new() | 117 | let filter = Filter::new() |
| 118 | .kind(Kind::Custom(KIND_ISSUE)) | 118 | .kind(Kind::GitIssue) |
| 119 | .author(keys.public_key()) | 119 | .author(keys.public_key()) |
| 120 | .id(issue_id); | 120 | .id(issue_id); |
| 121 | 121 | ||
| @@ -237,7 +237,7 @@ async fn test_live_sync_layer3_events() { | |||
| 237 | // 6. Now wait for issue to sync to relay_b (this triggers Layer 3 filter creation) | 237 | // 6. Now wait for issue to sync to relay_b (this triggers Layer 3 filter creation) |
| 238 | tokio::time::sleep(Duration::from_secs(2)).await; | 238 | tokio::time::sleep(Duration::from_secs(2)).await; |
| 239 | 239 | ||
| 240 | let issue_filter = Filter::new().kind(Kind::Custom(KIND_ISSUE)).id(issue_id); | 240 | let issue_filter = Filter::new().kind(Kind::GitIssue).id(issue_id); |
| 241 | let issue_synced = | 241 | let issue_synced = |
| 242 | wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(3)).await; | 242 | wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(3)).await; |
| 243 | println!("Issue synced to relay_b: {}", issue_synced); | 243 | println!("Issue synced to relay_b: {}", issue_synced); |
| @@ -247,7 +247,7 @@ async fn test_live_sync_layer3_events() { | |||
| 247 | 247 | ||
| 248 | // 7. Wait and verify comment syncs to relay_b | 248 | // 7. Wait and verify comment syncs to relay_b |
| 249 | let comment_filter = Filter::new() | 249 | let comment_filter = Filter::new() |
| 250 | .kind(Kind::Custom(KIND_COMMENT)) | 250 | .kind(Kind::Comment) |
| 251 | .author(keys.public_key()) | 251 | .author(keys.public_key()) |
| 252 | .id(comment_id); | 252 | .id(comment_id); |
| 253 | 253 | ||
| @@ -267,9 +267,7 @@ async fn test_live_sync_layer3_events() { | |||
| 267 | client.connect().await; | 267 | client.connect().await; |
| 268 | tokio::time::sleep(Duration::from_millis(500)).await; | 268 | tokio::time::sleep(Duration::from_millis(500)).await; |
| 269 | 269 | ||
| 270 | let fetch_filter = Filter::new() | 270 | let fetch_filter = Filter::new().kind(Kind::Comment).id(comment_id); |
| 271 | .kind(Kind::Custom(KIND_COMMENT)) | ||
| 272 | .id(comment_id); | ||
| 273 | 271 | ||
| 274 | if let Ok(events) = client | 272 | if let Ok(events) = client |
| 275 | .fetch_events(fetch_filter, Duration::from_secs(2)) | 273 | .fetch_events(fetch_filter, Duration::from_secs(2)) |
| @@ -418,9 +416,7 @@ async fn test_live_sync_event_ordering() { | |||
| 418 | client.connect().await; | 416 | client.connect().await; |
| 419 | tokio::time::sleep(Duration::from_millis(500)).await; | 417 | tokio::time::sleep(Duration::from_millis(500)).await; |
| 420 | 418 | ||
| 421 | let filter = Filter::new() | 419 | let filter = Filter::new().kind(Kind::GitIssue).author(keys.public_key()); |
| 422 | .kind(Kind::Custom(KIND_ISSUE)) | ||
| 423 | .author(keys.public_key()); | ||
| 424 | 420 | ||
| 425 | match client.fetch_events(filter, Duration::from_secs(3)).await { | 421 | match client.fetch_events(filter, Duration::from_secs(3)).await { |
| 426 | Ok(events) => { | 422 | Ok(events) => { |