lnd.xprv/lnwire/update_fulfill_htlc_test.go
Olaoluwa Osuntokun 5330513c7b
lnwire: morph HTLCSettleRequest into UpdateFufillHTLC
This commit modifies the prior HTLCSettleRequest to more closely match
the UpdateFufillHTLC defined within the specification. The only
semantic change is the move from a slice of pre-images (for “multi-sig”
LN) to a single payment preimage.
2017-02-21 01:42:32 -08:00

31 lines
804 B
Go

package lnwire
import (
"bytes"
"reflect"
"testing"
)
func TestUpdateFufillHTLCEncodeDecode(t *testing.T) {
// First create a new HTLCSR message.
settleReq := NewUpdateFufillHTLC(*outpoint1, 23, revHash)
// Next encode the HTLCSR message into an empty bytes buffer.
var b bytes.Buffer
if err := settleReq.Encode(&b, 0); err != nil {
t.Fatalf("unable to encode UpdateFufillHTLC: %v", err)
}
// Deserialize the encoded SFOP message into a new empty struct.
settleReq2 := &UpdateFufillHTLC{}
if err := settleReq2.Decode(&b, 0); err != nil {
t.Fatalf("unable to decode UpdateFufillHTLC: %v", err)
}
// Assert equality of the two instances.
if !reflect.DeepEqual(settleReq, settleReq2) {
t.Fatalf("encode/decode error messages don't match %#v vs %#v",
settleReq, settleReq2)
}
}