diff options
Diffstat (limited to 'internal/nostr/kinds_test.go')
| -rw-r--r-- | internal/nostr/kinds_test.go | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/internal/nostr/kinds_test.go b/internal/nostr/kinds_test.go deleted file mode 100644 index 2bf013d..0000000 --- a/internal/nostr/kinds_test.go +++ /dev/null | |||
| @@ -1,128 +0,0 @@ | |||
| 1 | package nostr | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "testing" | ||
| 5 | ) | ||
| 6 | |||
| 7 | func TestKindConstants(t *testing.T) { | ||
| 8 | // Verify constants match NIP-01 spec | ||
| 9 | tests := []struct { | ||
| 10 | name string | ||
| 11 | kind int | ||
| 12 | value int | ||
| 13 | }{ | ||
| 14 | {"Metadata", KindMetadata, 0}, | ||
| 15 | {"TextNote", KindTextNote, 1}, | ||
| 16 | {"ContactList", KindContactList, 3}, | ||
| 17 | {"EncryptedDM", KindEncryptedDM, 4}, | ||
| 18 | {"Deletion", KindDeletion, 5}, | ||
| 19 | {"Repost", KindRepost, 6}, | ||
| 20 | {"Reaction", KindReaction, 7}, | ||
| 21 | } | ||
| 22 | |||
| 23 | for _, tt := range tests { | ||
| 24 | t.Run(tt.name, func(t *testing.T) { | ||
| 25 | if tt.kind != tt.value { | ||
| 26 | t.Errorf("Kind%s = %d, want %d", tt.name, tt.kind, tt.value) | ||
| 27 | } | ||
| 28 | }) | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | func TestIsRegular(t *testing.T) { | ||
| 33 | tests := []struct { | ||
| 34 | kind int | ||
| 35 | want bool | ||
| 36 | }{ | ||
| 37 | {0, false}, // Metadata - replaceable | ||
| 38 | {1, true}, // TextNote - regular | ||
| 39 | {3, false}, // ContactList - replaceable | ||
| 40 | {4, true}, // EncryptedDM - regular | ||
| 41 | {5, true}, // Deletion - regular | ||
| 42 | {1000, true}, // Regular range | ||
| 43 | {9999, true}, // Regular range | ||
| 44 | {10000, false}, // Replaceable range | ||
| 45 | {19999, false}, // Replaceable range | ||
| 46 | {20000, false}, // Ephemeral range | ||
| 47 | {29999, false}, // Ephemeral range | ||
| 48 | {30000, false}, // Addressable range | ||
| 49 | {39999, false}, // Addressable range | ||
| 50 | {40000, true}, // Back to regular | ||
| 51 | } | ||
| 52 | |||
| 53 | for _, tt := range tests { | ||
| 54 | t.Run("kind_"+string(rune(tt.kind)), func(t *testing.T) { | ||
| 55 | if got := IsRegular(tt.kind); got != tt.want { | ||
| 56 | t.Errorf("IsRegular(%d) = %v, want %v", tt.kind, got, tt.want) | ||
| 57 | } | ||
| 58 | }) | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | func TestIsReplaceable(t *testing.T) { | ||
| 63 | tests := []struct { | ||
| 64 | kind int | ||
| 65 | want bool | ||
| 66 | }{ | ||
| 67 | {0, true}, // Metadata | ||
| 68 | {1, false}, // TextNote | ||
| 69 | {3, true}, // ContactList | ||
| 70 | {10000, true}, // Replaceable range start | ||
| 71 | {15000, true}, // Replaceable range middle | ||
| 72 | {19999, true}, // Replaceable range end | ||
| 73 | {20000, false}, // Ephemeral range | ||
| 74 | {30000, false}, // Addressable range | ||
| 75 | } | ||
| 76 | |||
| 77 | for _, tt := range tests { | ||
| 78 | t.Run("kind_"+string(rune(tt.kind)), func(t *testing.T) { | ||
| 79 | if got := IsReplaceable(tt.kind); got != tt.want { | ||
| 80 | t.Errorf("IsReplaceable(%d) = %v, want %v", tt.kind, got, tt.want) | ||
| 81 | } | ||
| 82 | }) | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | func TestIsEphemeral(t *testing.T) { | ||
| 87 | tests := []struct { | ||
| 88 | kind int | ||
| 89 | want bool | ||
| 90 | }{ | ||
| 91 | {1, false}, // TextNote | ||
| 92 | {19999, false}, // Replaceable range | ||
| 93 | {20000, true}, // Ephemeral range start | ||
| 94 | {25000, true}, // Ephemeral range middle | ||
| 95 | {29999, true}, // Ephemeral range end | ||
| 96 | {30000, false}, // Addressable range | ||
| 97 | } | ||
| 98 | |||
| 99 | for _, tt := range tests { | ||
| 100 | t.Run("kind_"+string(rune(tt.kind)), func(t *testing.T) { | ||
| 101 | if got := IsEphemeral(tt.kind); got != tt.want { | ||
| 102 | t.Errorf("IsEphemeral(%d) = %v, want %v", tt.kind, got, tt.want) | ||
| 103 | } | ||
| 104 | }) | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | func TestIsAddressable(t *testing.T) { | ||
| 109 | tests := []struct { | ||
| 110 | kind int | ||
| 111 | want bool | ||
| 112 | }{ | ||
| 113 | {1, false}, // TextNote | ||
| 114 | {29999, false}, // Ephemeral range | ||
| 115 | {30000, true}, // Addressable range start | ||
| 116 | {35000, true}, // Addressable range middle | ||
| 117 | {39999, true}, // Addressable range end | ||
| 118 | {40000, false}, // Beyond addressable range | ||
| 119 | } | ||
| 120 | |||
| 121 | for _, tt := range tests { | ||
| 122 | t.Run("kind_"+string(rune(tt.kind)), func(t *testing.T) { | ||
| 123 | if got := IsAddressable(tt.kind); got != tt.want { | ||
| 124 | t.Errorf("IsAddressable(%d) = %v, want %v", tt.kind, got, tt.want) | ||
| 125 | } | ||
| 126 | }) | ||
| 127 | } | ||
| 128 | } | ||
