lnd.xprv/lnwire/single_funding_open_proof_test.go
Olaoluwa Osuntokun 98471256fa
lnwire: modify fundingOpen to include channel ID rather than SPV proof
This commit modifies the SingleFundingOpen message to include the
compact channel ID of the finalized transaction rather than a “fake”
SPV proof. This change is a stop-gap which allows us to implement
portions of BOLT07 without yet fully implementing all parts of BOLT[02,
03].
2016-12-27 16:44:25 -08:00

31 lines
779 B
Go

package lnwire
import (
"bytes"
"reflect"
"testing"
)
func TestSingleFundingOpenProofWire(t *testing.T) {
// First create a new SFOP message.
sfop := NewSingleFundingOpenProof(22, someChannelID)
// Next encode the SFOP message into an empty bytes buffer.
var b bytes.Buffer
if err := sfop.Encode(&b, 0); err != nil {
t.Fatalf("unable to encode SingleFundingSignComplete: %v", err)
}
// Deserialize the encoded SFOP message into a new empty struct.
sfop2 := &SingleFundingOpenProof{}
if err := sfop2.Decode(&b, 0); err != nil {
t.Fatalf("unable to decode SingleFundingOpenProof: %v", err)
}
// Assert equality of the two instances.
if !reflect.DeepEqual(sfop, sfop2) {
t.Fatalf("encode/decode error messages don't match %#v vs %#v",
sfop, sfop2)
}
}