• 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

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
45
// interface.
46
var _ SizeableMessage = (*Pong)(nil)
47

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

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

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

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

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

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

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