mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-20 02:27:21 +01:00
eb490b8833
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.
36 lines
995 B
Go
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)
|
|
}
|
|
}
|