• 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

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
30
// interface.
31
var _ SizeableMessage = (*Stfu)(nil)
32

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

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

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

50
        return WriteBytes(w, s.ExtraData)
3✔
51
}
52

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

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

70
        return nil
3✔
71
}
72

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

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

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

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

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

×
NEW
110
        extraData := RandExtraOpaqueData(t, nil)
×
NEW
111
        if len(extraData) > 0 {
×
NEW
112
                m.ExtraData = extraData
×
NEW
113
        }
×
114

NEW
115
        return m
×
116
}
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