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

lightningnetwork / lnd / 13980275562

20 Mar 2025 10:06PM UTC coverage: 58.6% (-10.2%) from 68.789%
13980275562

Pull #9623

github

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

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

26603 existing lines in 443 files now uncovered.

96807 of 165200 relevant lines covered (58.6%)

1.82 hits per line

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

0.0
/lnwire/pong.go
1
package lnwire
2

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

8
        "pgregory.net/rapid"
9
)
10

11
// MaxPongBytes is the maximum number of extra bytes a pong can be requested to
12
// send. The type of the message (19) takes 2 bytes, the length field takes up
13
// 2 bytes, leaving 65531 bytes.
14
const MaxPongBytes = 65531
15

16
// ErrMaxPongBytesExceeded indicates that the NumPongBytes field from the ping
17
// message has exceeded MaxPongBytes.
18
var ErrMaxPongBytesExceeded = fmt.Errorf("pong bytes exceeded")
19

20
// PongPayload is a set of opaque bytes sent in response to a ping message.
21
type PongPayload []byte
22

23
// Pong defines a message which is the direct response to a received Ping
24
// message. A Pong reply indicates that a connection is still active. The Pong
25
// reply to a Ping message should contain the nonce carried in the original
26
// Pong message.
27
type Pong struct {
28
        // PongBytes is a set of opaque bytes that corresponds to the
29
        // NumPongBytes defined in the ping message that this pong is
30
        // replying to.
31
        PongBytes PongPayload
32
}
33

34
// NewPong returns a new Pong message.
35
func NewPong(pongBytes []byte) *Pong {
×
36
        return &Pong{
×
37
                PongBytes: pongBytes,
×
38
        }
×
39
}
×
40

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

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

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

50
// Decode deserializes a serialized Pong message stored in the passed io.Reader
51
// observing the specified protocol version.
52
//
53
// This is part of the lnwire.Message interface.
UNCOV
54
func (p *Pong) Decode(r io.Reader, pver uint32) error {
×
UNCOV
55
        return ReadElements(r,
×
UNCOV
56
                &p.PongBytes,
×
UNCOV
57
        )
×
UNCOV
58
}
×
59

60
// Encode serializes the target Pong into the passed io.Writer observing the
61
// protocol version specified.
62
//
63
// This is part of the lnwire.Message interface.
UNCOV
64
func (p *Pong) Encode(w *bytes.Buffer, pver uint32) error {
×
UNCOV
65
        return WritePongPayload(w, p.PongBytes)
×
UNCOV
66
}
×
67

68
// MsgType returns the integer uniquely identifying this message type on the
69
// wire.
70
//
71
// This is part of the lnwire.Message interface.
UNCOV
72
func (p *Pong) MsgType() MessageType {
×
UNCOV
73
        return MsgPong
×
UNCOV
74
}
×
75

76
// SerializedSize returns the serialized size of the message in bytes.
77
//
78
// This is part of the lnwire.SizeableMessage interface.
NEW
79
func (p *Pong) SerializedSize() (uint32, error) {
×
NEW
80
        return MessageSerializedSize(p)
×
NEW
81
}
×
82

83
// RandTestMessage populates the message with random data suitable for testing.
84
// It uses the rapid testing framework to generate random values.
85
//
86
// This is part of the TestMessage interface.
NEW
87
func (p *Pong) RandTestMessage(t *rapid.T) Message {
×
NEW
88
        payloadLen := rapid.IntRange(0, 1000).Draw(t, "pongPayloadLength")
×
NEW
89
        payload := rapid.SliceOfN(rapid.Byte(), payloadLen, payloadLen).Draw(
×
NEW
90
                t, "pongPayload",
×
NEW
91
        )
×
NEW
92

×
NEW
93
        return &Pong{
×
NEW
94
                PongBytes: payload,
×
NEW
95
        }
×
NEW
96
}
×
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