5330513c7b
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.
31 lines
804 B
Go
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)
|
|
}
|
|
}
|