Files
transit/signature/signature_test.go
2025-05-21 22:42:51 -01:06

32 lines
558 B
Go

package signature
import (
"bytes"
"encoding/json"
"testing"
"lukechampine.com/frand"
"github.com/mleku/transit/chk"
"github.com/mleku/transit/log"
)
func TestNew(t *testing.T) {
msg := frand.Bytes(Len)
i := New(msg)
var err error
var b []byte
if b, err = json.Marshal(&i); chk.E(err) {
t.Fatal(err)
}
log.I.F("encode %0x %d %s", i.Bytes, len(b), b)
i2 := &S{}
if err = json.Unmarshal(b, i2); chk.E(err) {
t.Fatal(err)
}
log.I.F("decode %0x", i2.Bytes)
if !bytes.Equal(i.Bytes, i2.Bytes) {
t.Fatal("failed to encode/decode")
}
}