Files
next.orly.dev/pkg/encoders/kind/kinds_test.go
mleku 8add32bb78 Add relayinfo package and utility modules for NIP-11 support
Introduce the `relayinfo` package with `NIP-11` utilities, including `Fees`, `Limits`, and `NIPs` structures. Add utility modules for handling numbers, timestamps, and kinds. Integrate functionality for fetching and managing relay information.
2025-08-21 15:22:17 +01:00

37 lines
646 B
Go

package kind
import (
"testing"
"lol.mleku.dev/chk"
"lukechampine.com/frand"
)
func TestUnmarshalKindsArray(t *testing.T) {
k := &S{make([]*K, 100)}
for i := range k.K {
k.K[i] = New(uint16(frand.Intn(65535)))
}
var dst []byte
var err error
if dst = k.Marshal(dst); chk.E(err) {
t.Fatal(err)
}
k2 := &S{}
var rem []byte
if rem, err = k2.Unmarshal(dst); chk.E(err) {
return
}
if len(rem) > 0 {
t.Fatalf("failed to unmarshal, remnant afterwards '%s'", rem)
}
for i := range k.K {
if *k.K[i] != *k2.K[i] {
t.Fatalf(
"failed to unmarshal at element %d; got %x, expected %x",
i, k.K[i], k2.K[i],
)
}
}
}