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/nip77_negentropy.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/nip77_negentropy.rs')
| -rw-r--r-- | tests/nip77_negentropy.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tests/nip77_negentropy.rs b/tests/nip77_negentropy.rs index 5293754..fccfe67 100644 --- a/tests/nip77_negentropy.rs +++ b/tests/nip77_negentropy.rs | |||
| @@ -56,7 +56,7 @@ async fn test_nip77_negentropy_sync_finds_events() { | |||
| 56 | // Create a second event (issue referencing the repo) | 56 | // Create a second event (issue referencing the repo) |
| 57 | let repo_coord = format!( | 57 | let repo_coord = format!( |
| 58 | "{}:{}:{}", | 58 | "{}:{}:{}", |
| 59 | KIND_REPOSITORY_STATE, | 59 | Kind::GitRepoAnnouncement.as_u16(), |
| 60 | keys.public_key().to_hex(), | 60 | keys.public_key().to_hex(), |
| 61 | "test-repo-nip77" | 61 | "test-repo-nip77" |
| 62 | ); | 62 | ); |
| @@ -103,10 +103,9 @@ async fn test_nip77_negentropy_sync_finds_events() { | |||
| 103 | tokio::time::sleep(Duration::from_millis(500)).await; | 103 | tokio::time::sleep(Duration::from_millis(500)).await; |
| 104 | 104 | ||
| 105 | // 6. Perform negentropy sync with filter matching our events | 105 | // 6. Perform negentropy sync with filter matching our events |
| 106 | let filter = Filter::new().author(keys.public_key()).kinds(vec![ | 106 | let filter = Filter::new() |
| 107 | Kind::Custom(KIND_REPOSITORY_STATE), | 107 | .author(keys.public_key()) |
| 108 | Kind::Custom(KIND_ISSUE), | 108 | .kinds(vec![Kind::GitRepoAnnouncement, Kind::GitIssue]); |
| 109 | ]); | ||
| 110 | 109 | ||
| 111 | println!("Starting negentropy sync with filter: {:?}", filter); | 110 | println!("Starting negentropy sync with filter: {:?}", filter); |
| 112 | 111 | ||
| @@ -183,7 +182,7 @@ async fn test_nip77_negentropy_sync_empty_result() { | |||
| 183 | // 3. Sync with filter that won't match anything | 182 | // 3. Sync with filter that won't match anything |
| 184 | let filter = Filter::new() | 183 | let filter = Filter::new() |
| 185 | .author(keys.public_key()) // Random new key, no events exist | 184 | .author(keys.public_key()) // Random new key, no events exist |
| 186 | .kind(Kind::Custom(KIND_REPOSITORY_STATE)); | 185 | .kind(Kind::GitRepoAnnouncement); |
| 187 | 186 | ||
| 188 | println!("Starting negentropy sync with empty filter"); | 187 | println!("Starting negentropy sync with empty filter"); |
| 189 | 188 | ||