2015-12-30 16:38:57 +03:00
|
|
|
package lnwire
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2015-12-31 09:28:14 +03:00
|
|
|
var (
|
2016-01-17 04:14:35 +03:00
|
|
|
// funding response
|
2015-12-31 09:28:14 +03:00
|
|
|
fundingSignComplete = &FundingSignComplete{
|
|
|
|
ReservationID: uint64(12345678),
|
|
|
|
TxID: txid,
|
2015-12-31 11:25:00 +03:00
|
|
|
FundingTXSigs: ptrFundingTXSigs,
|
2015-12-30 16:38:57 +03:00
|
|
|
}
|
2015-12-31 09:28:14 +03:00
|
|
|
fundingSignCompleteSerializedString = "0000000000bc614efd95c6e5c9d5bcf9cfc7231b6a438e46c518c724d0b04b75cc8fddf84a254e3a02473045022100e7946d057c0b4cc4d3ea525ba156b429796858ebc543d75a6c6c2cbca732db6902202fea377c1f9fb98cd103cf5a4fba276a074b378d4227d15f5fa6439f1a6685bb4630440220235ee55fed634080089953048c3e3f7dc3a154fd7ad18f31dc08e05b7864608a02203bdd7d4e4d9a8162d4b511faf161f0bb16c45181187125017cd0c620c53876ca"
|
|
|
|
fundingSignCompleteSerializedMessage = "0709110b000000e6000000b80000000000bc614efd95c6e5c9d5bcf9cfc7231b6a438e46c518c724d0b04b75cc8fddf84a254e3a02473045022100e7946d057c0b4cc4d3ea525ba156b429796858ebc543d75a6c6c2cbca732db6902202fea377c1f9fb98cd103cf5a4fba276a074b378d4227d15f5fa6439f1a6685bb4630440220235ee55fed634080089953048c3e3f7dc3a154fd7ad18f31dc08e05b7864608a02203bdd7d4e4d9a8162d4b511faf161f0bb16c45181187125017cd0c620c53876ca"
|
|
|
|
)
|
2015-12-30 16:38:57 +03:00
|
|
|
|
2015-12-31 09:28:14 +03:00
|
|
|
func TestFundingSignCompleteEncodeDecode(t *testing.T) {
|
2016-01-17 04:14:35 +03:00
|
|
|
// All of these types being passed are of the message interface type
|
|
|
|
// Test serialization, runs: message.Encode(b, 0)
|
|
|
|
// Returns bytes
|
|
|
|
// Compares the expected serialized string from the original
|
2015-12-31 09:28:14 +03:00
|
|
|
s := SerializeTest(t, fundingSignComplete, fundingSignCompleteSerializedString, filename)
|
2015-12-30 16:38:57 +03:00
|
|
|
|
2016-01-17 04:14:35 +03:00
|
|
|
// Test deserialization, runs: message.Decode(s, 0)
|
|
|
|
// Makes sure the deserialized struct is the same as the original
|
2015-12-31 09:28:14 +03:00
|
|
|
newMessage := NewFundingSignComplete()
|
|
|
|
DeserializeTest(t, s, newMessage, fundingSignComplete)
|
2015-12-30 16:38:57 +03:00
|
|
|
|
2016-01-17 04:14:35 +03:00
|
|
|
// Test message using Message interface
|
|
|
|
// Serializes into buf: WriteMessage(buf, message, uint32(1), wire.TestNet3)
|
|
|
|
// Deserializes into msg: _, msg, _ , err := ReadMessage(buf, uint32(1), wire.TestNet3)
|
2015-12-31 09:28:14 +03:00
|
|
|
MessageSerializeDeserializeTest(t, fundingSignComplete, fundingSignCompleteSerializedMessage)
|
2015-12-30 16:38:57 +03:00
|
|
|
}
|