lnd.xprv/lnwire/funding_locked_test.go
bryanvu eb490b8833 lnwire: add FundingLocked message
When the funding transaction has been confirmed, the FundingLocked
message is sent by the peers to each other so that the existence of the
newly funded channel can be announced to the network.

This commit also removes the SingleFundingOpenProof message.
2017-02-24 11:37:33 -08:00

36 lines
995 B
Go

package lnwire
import (
"bytes"
"reflect"
"testing"
)
func TestFundingLockedWire(t *testing.T) {
// First create a new FundingLocked message.
fl := NewFundingLocked(*outpoint1, someChannelID, pubKey)
// Next encode the FundingLocked message into an empty bytes buffer.
var b bytes.Buffer
if err := fl.Encode(&b, 0); err != nil {
t.Fatalf("unable to encode FundingLocked: %v", err)
}
// Check to ensure that the FundingLocked message is the correct size.
if uint32(b.Len()) > fl.MaxPayloadLength(0) {
t.Fatalf("length of FundingLocked message is too long: %v should be less than %v",
b.Len(), fl.MaxPayloadLength(0))
}
// Deserialize the encoded FundingLocked message into an empty struct.
fl2 := &FundingLocked{}
if err := fl2.Decode(&b, 0); err != nil {
t.Fatalf("unable to decode FundingLocked: %v", err)
}
// Assert equality of the two instances
if !reflect.DeepEqual(fl, fl2) {
t.Fatalf("encode/decode error messages don't match %#v vs %#v", fl, fl2)
}
}