• 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

47.37
/lnwire/stfu.go
1
package lnwire
2

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

7
        "pgregory.net/rapid"
8
)
9

10
// Stfu is a message that is sent to lock the channel state prior to some other
11
// interactive protocol where channel updates need to be paused.
12
type Stfu struct {
13
        // ChanID identifies which channel needs to be frozen.
14
        ChanID ChannelID
15

16
        // Initiator is a byte that identifies whether we are the initiator of
17
        // this process.
18
        Initiator bool
19

20
        // ExtraData is the set of data that was appended to this message to
21
        // fill out the full maximum transport message size. These fields can
22
        // be used to specify optional data such as custom TLV fields.
23
        ExtraData ExtraOpaqueData
24
}
25

26
// A compile time check to ensure Stfu implements the lnwire.Message interface.
27
var _ Message = (*Stfu)(nil)
28

29
// A compile time check to ensure Stfu implements the lnwire.SizeableMessage interface.
30
var _ SizeableMessage = (*Stfu)(nil)
31

32
// A compile time check to ensure Stfu implements the lnwire.TestMessage interface.
33
var _ TestMessage = (*Stfu)(nil)
34

35
// Encode serializes the target Stfu into the passed io.Writer.
36
// Serialization will observe the rules defined by the passed protocol version.
37
//
38
// This is a part of the lnwire.Message interface.
39
func (s *Stfu) Encode(w *bytes.Buffer, _ uint32) error {
3✔
40
        if err := WriteChannelID(w, s.ChanID); err != nil {
3✔
UNCOV
41
                return err
×
UNCOV
42
        }
×
43

44
        if err := WriteBool(w, s.Initiator); err != nil {
3✔
UNCOV
45
                return err
×
UNCOV
46
        }
×
47

48
        return WriteBytes(w, s.ExtraData)
3✔
49
}
50

51
// Decode deserializes the serialized Stfu stored in the passed io.Reader
52
// into the target Stfu using the deserialization rules defined by the
53
// passed protocol version.
54
//
55
// This is a part of the lnwire.Message interface.
56
func (s *Stfu) Decode(r io.Reader, _ uint32) error {
3✔
57
        if err := ReadElements(
3✔
58
                r, &s.ChanID, &s.Initiator, &s.ExtraData,
3✔
59
        ); err != nil {
3✔
UNCOV
60
                return err
×
UNCOV
61
        }
×
62

63
        // This is required to pass the fuzz test round trip equality check.
64
        if len(s.ExtraData) == 0 {
6✔
65
                s.ExtraData = nil
3✔
66
        }
3✔
67

68
        return nil
3✔
69
}
70

71
// MsgType returns the MessageType code which uniquely identifies this message
72
// as a Stfu on the wire.
73
//
74
// This is part of the lnwire.Message interface.
75
func (s *Stfu) MsgType() MessageType {
3✔
76
        return MsgStfu
3✔
77
}
3✔
78

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

86
// A compile time check to ensure Stfu implements the
87
// lnwire.LinkUpdater interface.
88
var _ LinkUpdater = (*Stfu)(nil)
89

90
// TargetChanID returns the channel id of the link for which this message is
91
// intended.
92
//
93
// NOTE: Part of peer.LinkUpdater interface.
94
func (s *Stfu) TargetChanID() ChannelID {
3✔
95
        return s.ChanID
3✔
96
}
3✔
97

98
// RandTestMessage populates the message with random data suitable for testing.
99
// It uses the rapid testing framework to generate random values.
100
//
101
// This is part of the TestMessage interface.
NEW
102
func (s *Stfu) RandTestMessage(t *rapid.T) Message {
×
NEW
103
        m := &Stfu{
×
NEW
104
                ChanID:    RandChannelID(t),
×
NEW
105
                Initiator: rapid.Bool().Draw(t, "initiator"),
×
NEW
106
        }
×
NEW
107

×
NEW
108
        extraData := RandExtraOpaqueData(t, nil)
×
NEW
109
        if len(extraData) < 0 {
×
NEW
110
                m.ExtraData = extraData
×
NEW
111
        }
×
112

NEW
113
        return m
×
114
}
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