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.
This commit is contained in:
37
pkg/encoders/kind/kind_test.go
Normal file
37
pkg/encoders/kind/kind_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package kind
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"lol.mleku.dev/chk"
|
||||
|
||||
"lukechampine.com/frand"
|
||||
)
|
||||
|
||||
func TestMarshalUnmarshal(t *testing.T) {
|
||||
var err error
|
||||
k := make([]*K, 1000000)
|
||||
for i := range k {
|
||||
k[i] = New(uint16(frand.Intn(65535)))
|
||||
}
|
||||
mk := make([][]byte, len(k))
|
||||
for i := range mk {
|
||||
mk[i] = make([]byte, 0, 5) // 16 bits max 65535 = 5 characters
|
||||
}
|
||||
for i := range k {
|
||||
mk[i] = k[i].Marshal(mk[i])
|
||||
}
|
||||
k2 := make([]*K, len(k))
|
||||
for i := range k2 {
|
||||
k2[i] = New(0)
|
||||
}
|
||||
for i := range k2 {
|
||||
var r []byte
|
||||
if r, err = k2[i].Unmarshal(mk[i]); chk.E(err) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(r) != 0 {
|
||||
t.Fatalf("remainder after unmarshal: '%s'", r)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user