• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 13980885714

20 Mar 2025 10:53PM UTC coverage: 58.613% (-10.2%) from 68.789%
13980885714

Pull #9623

github

web-flow
Merge 9eaec1f7a into 09b674508
Pull Request #9623: Size msg test msg

0 of 1572 new or added lines in 42 files covered. (0.0%)

27755 existing lines in 442 files now uncovered.

96886 of 165299 relevant lines covered (58.61%)

1.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

37.84
/lnwire/reply_short_chan_ids_end.go
1
package lnwire
2

3
import (
4
        "bytes"
5
        "io"
6

7
        "github.com/btcsuite/btcd/chaincfg/chainhash"
8
        "pgregory.net/rapid"
9
)
10

11
// ReplyShortChanIDsEnd is a message that marks the end of a streaming message
12
// response to an initial QueryShortChanIDs message. This marks that the
13
// receiver of the original QueryShortChanIDs for the target chain has either
14
// sent all adequate responses it knows of, or doesn't know of any short chan
15
// ID's for the target chain.
16
type ReplyShortChanIDsEnd struct {
17
        // ChainHash denotes the target chain that we're respond to a short
18
        // chan ID query for.
19
        ChainHash chainhash.Hash
20

21
        // Complete will be set to 0 if we don't know of the chain that the
22
        // remote peer sent their query for. Otherwise, we'll set this to 1 in
23
        // order to indicate that we've sent all known responses for the prior
24
        // set of short chan ID's in the corresponding QueryShortChanIDs
25
        // message.
26
        Complete uint8
27

28
        // ExtraData is the set of data that was appended to this message to
29
        // fill out the full maximum transport message size. These fields can
30
        // be used to specify optional data such as custom TLV fields.
31
        ExtraData ExtraOpaqueData
32
}
33

34
// NewReplyShortChanIDsEnd creates a new empty ReplyShortChanIDsEnd message.
35
func NewReplyShortChanIDsEnd() *ReplyShortChanIDsEnd {
×
36
        return &ReplyShortChanIDsEnd{}
×
37
}
×
38

39
// A compile time check to ensure ReplyShortChanIDsEnd implements the
40
// lnwire.Message interface.
41
var _ Message = (*ReplyShortChanIDsEnd)(nil)
42

43
// A compile time check to ensure ReplyShortChanIDsEnd implements the
44
// lnwire.SizeableMessage interface.
45
var _ SizeableMessage = (*ReplyShortChanIDsEnd)(nil)
46

47
// A compile time check to ensure ReplyShortChanIDsEnd implements the
48
// lnwire.TestMessage interface.
49
var _ TestMessage = (*ReplyShortChanIDsEnd)(nil)
50

51
// Decode deserializes a serialized ReplyShortChanIDsEnd message stored in the
52
// passed io.Reader observing the specified protocol version.
53
//
54
// This is part of the lnwire.Message interface.
55
func (c *ReplyShortChanIDsEnd) Decode(r io.Reader, pver uint32) error {
3✔
56
        return ReadElements(r,
3✔
57
                c.ChainHash[:],
3✔
58
                &c.Complete,
3✔
59
                &c.ExtraData,
3✔
60
        )
3✔
61
}
3✔
62

63
// Encode serializes the target ReplyShortChanIDsEnd into the passed io.Writer
64
// observing the protocol version specified.
65
//
66
// This is part of the lnwire.Message interface.
67
func (c *ReplyShortChanIDsEnd) Encode(w *bytes.Buffer, pver uint32) error {
3✔
68
        if err := WriteBytes(w, c.ChainHash[:]); err != nil {
3✔
69
                return err
×
70
        }
×
71

72
        if err := WriteUint8(w, c.Complete); err != nil {
3✔
73
                return err
×
74
        }
×
75

76
        return WriteBytes(w, c.ExtraData)
3✔
77
}
78

79
// MsgType returns the integer uniquely identifying this message type on the
80
// wire.
81
//
82
// This is part of the lnwire.Message interface.
83
func (c *ReplyShortChanIDsEnd) MsgType() MessageType {
3✔
84
        return MsgReplyShortChanIDsEnd
3✔
85
}
3✔
86

87
// SerializedSize returns the serialized size of the message in bytes.
88
//
89
// This is part of the lnwire.SizeableMessage interface.
NEW
90
func (c *ReplyShortChanIDsEnd) SerializedSize() (uint32, error) {
×
NEW
91
        return MessageSerializedSize(c)
×
NEW
92
}
×
93

94
// RandTestMessage populates the message with random data suitable for testing.
95
// It uses the rapid testing framework to generate random values.
96
//
97
// This is part of the TestMessage interface.
NEW
98
func (c *ReplyShortChanIDsEnd) RandTestMessage(t *rapid.T) Message {
×
NEW
99
        var chainHash chainhash.Hash
×
NEW
100
        hashBytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(t, "chainHash")
×
NEW
101
        copy(chainHash[:], hashBytes)
×
NEW
102

×
NEW
103
        complete := uint8(rapid.IntRange(0, 1).Draw(t, "complete"))
×
NEW
104

×
NEW
105
        return &ReplyShortChanIDsEnd{
×
NEW
106
                ChainHash: chainHash,
×
NEW
107
                Complete:  complete,
×
NEW
108
                ExtraData: RandExtraOpaqueData(t, nil),
×
NEW
109
        }
×
NEW
110
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc