2016-05-31 01:45:44 +03:00
|
|
|
package lnwire
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSingleFundingOpenProofWire(t *testing.T) {
|
|
|
|
// First create a new SFOP message.
|
2016-12-27 08:23:45 +03:00
|
|
|
sfop := NewSingleFundingOpenProof(22, someChannelID)
|
2016-05-31 01:45:44 +03:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
}
|