mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-12 14:12:27 +02:00
lnwire: rename HTLCAddRequest to UpdateAddHTLC
This commit is contained in:
39
lnwire/update_add_htlc_test.go
Normal file
39
lnwire/update_add_htlc_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package lnwire
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/roasbeef/btcutil"
|
||||
)
|
||||
|
||||
func TestUpdateAddHTLCEncodeDecode(t *testing.T) {
|
||||
// First create a new UPAH message.
|
||||
addReq := &UpdateAddHTLC{
|
||||
ChannelPoint: *outpoint1,
|
||||
ID: 99,
|
||||
Expiry: uint32(144),
|
||||
Amount: btcutil.Amount(123456000),
|
||||
PaymentHash: revHash,
|
||||
}
|
||||
copy(addReq.OnionBlob[:], bytes.Repeat([]byte{23}, OnionPacketSize))
|
||||
|
||||
// Next encode the HTLCAR message into an empty bytes buffer.
|
||||
var b bytes.Buffer
|
||||
if err := addReq.Encode(&b, 0); err != nil {
|
||||
t.Fatalf("unable to encode HTLCAddRequest: %v", err)
|
||||
}
|
||||
|
||||
// Deserialize the encoded UPAH message into a new empty struct.
|
||||
addReq2 := &UpdateAddHTLC{}
|
||||
if err := addReq2.Decode(&b, 0); err != nil {
|
||||
t.Fatalf("unable to decode HTLCAddRequest: %v", err)
|
||||
}
|
||||
|
||||
// Assert equality of the two instances.
|
||||
if !reflect.DeepEqual(addReq, addReq2) {
|
||||
t.Fatalf("encode/decode error messages don't match %#v vs %#v",
|
||||
addReq, addReq2)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user