tinyrelayfile
tinyrelay/internal/event/compatibility_test.go/

internal/event/compatibility_test.go raw
1package event
2
3import (
4 "reflect"
5 "testing"
6
7 "github.com/FelineStateMachine/tinyrelay/protocol/nostr"
8)
9
10func TestCompatibilityPreservesPublicTypeIdentity(t *testing.T) {
11 if reflect.TypeOf(Event{}).PkgPath() != reflect.TypeOf(nostr.Event{}).PkgPath() || reflect.TypeOf(Filter{}).PkgPath() != reflect.TypeOf(nostr.Filter{}).PkgPath() {
12 t.Fatal("compatibility values must alias the public types")
13 }
14}
15
16func TestPrivateKindClassificationAndSearchCompatibility(t *testing.T) {
17 if !IsPrivate(4) || IsPrivate(KIND_DM) {
18 t.Fatal("kind classification mismatch")
19 }
20 for _, kind := range []int{4, 13, KIND_WRAP, 21059, KIND_NOSTR_CONNECT, KIND_PUSH_REGISTRATION} {
21 e := Event{Kind: kind, Content: "hello world"}
22 if Matches(Filter{Search: "hello"}, e) {
23 t.Errorf("private kind %d matched content search", kind)
24 }
25 if !Matches(Filter{Search: "lang:en"}, e) || !Matches(Filter{}, e) {
26 t.Errorf("private kind %d changed non-content matching", kind)
27 }
28 }
29 if !Matches(Filter{Search: "HELLO"}, Event{Kind: 1, Content: "hello world"}) {
30 t.Fatal("public content no longer matches")
31 }
32}

About

ownerc01503e8035f
visibilitypublic
headd730679639bf

Maintainers

  • c01503e8035f owner
  • ba1b5beed5b5 agent hermes

Clone

  • https://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git

Refs