Files
realy-protocol/pkg/signature/signature_test.go
mleku 4862dcf898 revision of protocol to be more concise and simple
more work to increase the use of RESTful path queries in general is required

simplicity of event format is definitely better now without unnecessary newlines (that are fine, but not great for reading) and the elimination of a bracket-like syntax for tags (they are just a list terminated by the content)
2025-02-22 12:08:00 -01:06

42 lines
738 B
Go

package signature
import (
"bytes"
"crypto/ed25519"
"crypto/rand"
"testing"
"protocol.realy.lol/pkg/separator"
)
func TestS_Marshal_Unmarshal(t *testing.T) {
var err error
for range 10 {
sig := make([]byte, ed25519.SignatureSize)
if _, err = rand.Read(sig); chk.E(err) {
t.Fatal(err)
}
var s1 *S
if s1, err = New(sig); chk.E(err) {
t.Fatal(err)
}
var o []byte
if o, err = s1.Marshal(nil); chk.E(err) {
t.Fatal(err)
}
o = separator.Add(o)
s2 := &S{}
var rem []byte
if rem, err = s2.Unmarshal(o); chk.E(err) {
t.Fatal(err)
}
if len(rem) > 0 {
log.I.F("%d %s", len(rem), rem)
}
if !bytes.Equal(sig, s2.Signature) {
t.Fatal("signature did not encode/decode faithfully")
}
}
}