mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
cycle sender / receiver to bytes and back
This commit is contained in:
parent
c1212d1369
commit
3fecd67920
@ -10,7 +10,7 @@ import (
|
||||
func TestElkremBig(t *testing.T) {
|
||||
sndr := NewElkremSender(63, wire.DoubleSha256SH([]byte("elktest")))
|
||||
rcv := NewElkremReceiver(63)
|
||||
SenderSerdesTest(t, sndr)
|
||||
SenderSerdesTest(t, &sndr)
|
||||
for n := uint64(0); n < 10000; n++ {
|
||||
sha, err := sndr.Next()
|
||||
if err != nil {
|
||||
@ -28,8 +28,8 @@ func TestElkremBig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
SenderSerdesTest(t, sndr)
|
||||
ReceiverSerdesTest(t, rcv)
|
||||
SenderSerdesTest(t, &sndr)
|
||||
ReceiverSerdesTest(t, &rcv)
|
||||
for n := uint64(0); n < 10000; n += 500 {
|
||||
sha, err := rcv.AtIndex(n)
|
||||
if err != nil {
|
||||
|
@ -5,19 +5,19 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func ReceiverSerdesTest(t *testing.T, er ElkremReceiver) {
|
||||
b, err := er.ToBytes()
|
||||
func ReceiverSerdesTest(t *testing.T, rcv *ElkremReceiver) {
|
||||
b, err := rcv.ToBytes()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("Serialized receiver; %d bytes, hex:\n%x\n", len(b), b)
|
||||
|
||||
rcv2, err := ElkremReceiverFromBytes(b)
|
||||
*rcv, err = ElkremReceiverFromBytes(b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
b2, err := rcv2.ToBytes()
|
||||
b2, err := rcv.ToBytes()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -27,19 +27,19 @@ func ReceiverSerdesTest(t *testing.T, er ElkremReceiver) {
|
||||
}
|
||||
}
|
||||
|
||||
func SenderSerdesTest(t *testing.T, es ElkremSender) {
|
||||
b, err := es.ToBytes()
|
||||
func SenderSerdesTest(t *testing.T, sndr *ElkremSender) {
|
||||
b, err := sndr.ToBytes()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("Serialized sender; %d bytes, hex:\n%x\n", len(b), b)
|
||||
|
||||
sndr2, err := ElkremSenderFromBytes(b)
|
||||
*sndr, err = ElkremSenderFromBytes(b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
b2, err := sndr2.ToBytes()
|
||||
b2, err := sndr.ToBytes()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user