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.
This commit is contained in:
4 files changed
+124
-119
No files matched your search
@@ -0,0 +1,30 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user