lnwire: rename HTLCAddRequest to UpdateAddHTLC

This commit is contained in:
Olaoluwa Osuntokun
2017-02-16 20:08:34 +08:00
parent 8a63c83283
commit ec02060c9f
4 changed files with 172 additions and 165 deletions

View 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)
}
}