lnd.xprv/lnwire/commit_sig_test.go
Olaoluwa Osuntokun 8a63c83283
lnwire: morph CommitSignature into CommitSig
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.
2017-02-21 01:42:23 -08:00

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