package nostr import ( "testing" ) func TestKindConstants(t *testing.T) { // Verify constants match NIP-01 spec tests := []struct { name string kind int value int }{ {"Metadata", KindMetadata, 0}, {"TextNote", KindTextNote, 1}, {"ContactList", KindContactList, 3}, {"EncryptedDM", KindEncryptedDM, 4}, {"Deletion", KindDeletion, 5}, {"Repost", KindRepost, 6}, {"Reaction", KindReaction, 7}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if tt.kind != tt.value { t.Errorf("Kind%s = %d, want %d", tt.name, tt.kind, tt.value) } }) } } func TestIsRegular(t *testing.T) { tests := []struct { kind int want bool }{ {0, false}, // Metadata - replaceable {1, true}, // TextNote - regular {3, false}, // ContactList - replaceable {4, true}, // EncryptedDM - regular {5, true}, // Deletion - regular {1000, true}, // Regular range {9999, true}, // Regular range {10000, false}, // Replaceable range {19999, false}, // Replaceable range {20000, false}, // Ephemeral range {29999, false}, // Ephemeral range {30000, false}, // Addressable range {39999, false}, // Addressable range {40000, true}, // Back to regular } for _, tt := range tests { t.Run("kind_"+string(rune(tt.kind)), func(t *testing.T) { if got := IsRegular(tt.kind); got != tt.want { t.Errorf("IsRegular(%d) = %v, want %v", tt.kind, got, tt.want) } }) } } func TestIsReplaceable(t *testing.T) { tests := []struct { kind int want bool }{ {0, true}, // Metadata {1, false}, // TextNote {3, true}, // ContactList {10000, true}, // Replaceable range start {15000, true}, // Replaceable range middle {19999, true}, // Replaceable range end {20000, false}, // Ephemeral range {30000, false}, // Addressable range } for _, tt := range tests { t.Run("kind_"+string(rune(tt.kind)), func(t *testing.T) { if got := IsReplaceable(tt.kind); got != tt.want { t.Errorf("IsReplaceable(%d) = %v, want %v", tt.kind, got, tt.want) } }) } } func TestIsEphemeral(t *testing.T) { tests := []struct { kind int want bool }{ {1, false}, // TextNote {19999, false}, // Replaceable range {20000, true}, // Ephemeral range start {25000, true}, // Ephemeral range middle {29999, true}, // Ephemeral range end {30000, false}, // Addressable range } for _, tt := range tests { t.Run("kind_"+string(rune(tt.kind)), func(t *testing.T) { if got := IsEphemeral(tt.kind); got != tt.want { t.Errorf("IsEphemeral(%d) = %v, want %v", tt.kind, got, tt.want) } }) } } func TestIsAddressable(t *testing.T) { tests := []struct { kind int want bool }{ {1, false}, // TextNote {29999, false}, // Ephemeral range {30000, true}, // Addressable range start {35000, true}, // Addressable range middle {39999, true}, // Addressable range end {40000, false}, // Beyond addressable range } for _, tt := range tests { t.Run("kind_"+string(rune(tt.kind)), func(t *testing.T) { if got := IsAddressable(tt.kind); got != tt.want { t.Errorf("IsAddressable(%d) = %v, want %v", tt.kind, got, tt.want) } }) } }