54b3541707
In this commit announcement signature message has been added which is needed when peers want to announce their channel to the rest of the network. This message acts as half proof carrier, nodes exchanges their half proofs with each other and after that they are able to construct the full proof.
35 lines
814 B
Go
35 lines
814 B
Go
package lnwire
|
|
|
|
import (
|
|
"bytes"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestAnnounceSignatureEncodeDecode(t *testing.T) {
|
|
ac := &AnnounceSignatures{
|
|
ChannelID: *outpoint1,
|
|
ShortChannelID: NewChanIDFromInt(1),
|
|
NodeSignature: someSig,
|
|
BitcoinSignature: someSig,
|
|
}
|
|
|
|
// Next encode the message into an empty bytes buffer.
|
|
var b bytes.Buffer
|
|
if err := ac.Encode(&b, 0); err != nil {
|
|
t.Fatalf("unable to encode AnnounceSignatures: %v", err)
|
|
}
|
|
|
|
// Deserialize the encoded message into a new empty struct.
|
|
ac2 := &AnnounceSignatures{}
|
|
if err := ac2.Decode(&b, 0); err != nil {
|
|
t.Fatalf("unable to decode AnnounceSignatures: %v", err)
|
|
}
|
|
|
|
// Assert equality of the two instances.
|
|
if !reflect.DeepEqual(ac, ac2) {
|
|
t.Fatalf("encode/decode error messages don't match %#v vs %#v",
|
|
ac, ac2)
|
|
}
|
|
}
|