mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
8a63c83283
This commit renames and modifies the CommitSignature message to more closely match the CommitSig message defined within the current set of draft specifications. The major change within the new message is that we now longer explicitly specify the update log index of the remote node that this signature covers. This is due to the fact the revocation message now also double as acknowledgements of the remote parties recevied commitment update messages.
33 lines
804 B
Go
33 lines
804 B
Go
package lnwire
|
|
|
|
import (
|
|
"bytes"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestCommitSigEncodeDecode(t *testing.T) {
|
|
commitSignature := &CommitSig{
|
|
ChannelPoint: *outpoint1,
|
|
CommitSig: commitSig,
|
|
}
|
|
|
|
// Next encode the CS message into an empty bytes buffer.
|
|
var b bytes.Buffer
|
|
if err := commitSignature.Encode(&b, 0); err != nil {
|
|
t.Fatalf("unable to encode CommitSig: %v", err)
|
|
}
|
|
|
|
// Deserialize the encoded EG message into a new empty struct.
|
|
commitSignature2 := &CommitSig{}
|
|
if err := commitSignature2.Decode(&b, 0); err != nil {
|
|
t.Fatalf("unable to decode CommitSig: %v", err)
|
|
}
|
|
|
|
// Assert equality of the two instances.
|
|
if !reflect.DeepEqual(commitSignature, commitSignature2) {
|
|
t.Fatalf("encode/decode error messages don't match %#v vs %#v",
|
|
commitSignature, commitSignature2)
|
|
}
|
|
}
|