lnwire: add tests to check payload estimates for channel announcements

This commit is contained in:
Olaoluwa Osuntokun 2016-12-24 14:49:52 -06:00
parent 3dc8cd5659
commit 1b0a0b6538
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 14 additions and 0 deletions

@ -28,6 +28,13 @@ func TestChannelAnnoucementEncodeDecode(t *testing.T) {
t.Fatalf("unable to encode ChannelAnnouncement: %v", err)
}
// Ensure the max payload estimate is correct.
serializedLength := uint32(b.Len())
if serializedLength != ca.MaxPayloadLength(0) {
t.Fatalf("payload length estimate is incorrect: expected %v "+
"got %v", serializedLength, ca.MaxPayloadLength(0))
}
// Deserialize the encoded CA message into a new empty struct.
ca2 := &ChannelAnnouncement{}
if err := ca2.Decode(&b, 0); err != nil {

@ -24,6 +24,13 @@ func TestChannelUpdateAnnouncementEncodeDecode(t *testing.T) {
t.Fatalf("unable to encode ChannelUpdateAnnouncement: %v", err)
}
// Ensure the max payload estimate is correct.
serializedLength := uint32(b.Len())
if serializedLength != cua.MaxPayloadLength(0) {
t.Fatalf("payload length estimate is incorrect: expected %v "+
"got %v", serializedLength, cua.MaxPayloadLength(0))
}
// Deserialize the encoded CUA message into a new empty struct.
cua2 := &ChannelUpdateAnnouncement{}
if err := cua2.Decode(&b, 0); err != nil {