• 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/update_fee.go
1
package lnwire
2

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

7
        "pgregory.net/rapid"
8
)
9

10
// UpdateFee is the message the channel initiator sends to the other peer if
11
// the channel commitment fee needs to be updated.
12
type UpdateFee struct {
13
        // ChanID is the channel that this UpdateFee is meant for.
14
        ChanID ChannelID
15

16
        // FeePerKw is the fee-per-kw on commit transactions that the sender of
17
        // this message wants to use for this channel.
18
        //
19
        // TODO(halseth): make SatPerKWeight when fee estimation is moved to
20
        // own package. Currently this will cause an import cycle.
21
        FeePerKw uint32
22

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

29
// NewUpdateFee creates a new UpdateFee message.
UNCOV
30
func NewUpdateFee(chanID ChannelID, feePerKw uint32) *UpdateFee {
×
UNCOV
31
        return &UpdateFee{
×
UNCOV
32
                ChanID:   chanID,
×
UNCOV
33
                FeePerKw: feePerKw,
×
UNCOV
34
        }
×
UNCOV
35
}
×
36

37
// A compile time check to ensure UpdateFee implements the lnwire.Message
38
// interface.
39
var _ Message = (*UpdateFee)(nil)
40

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

45
// Decode deserializes a serialized UpdateFee message stored in the passed
46
// io.Reader observing the specified protocol version.
47
//
48
// This is part of the lnwire.Message interface.
UNCOV
49
func (c *UpdateFee) Decode(r io.Reader, pver uint32) error {
×
UNCOV
50
        return ReadElements(r,
×
UNCOV
51
                &c.ChanID,
×
UNCOV
52
                &c.FeePerKw,
×
UNCOV
53
                &c.ExtraData,
×
UNCOV
54
        )
×
UNCOV
55
}
×
56

57
// Encode serializes the target UpdateFee into the passed io.Writer
58
// observing the protocol version specified.
59
//
60
// This is part of the lnwire.Message interface.
UNCOV
61
func (c *UpdateFee) Encode(w *bytes.Buffer, pver uint32) error {
×
UNCOV
62
        if err := WriteChannelID(w, c.ChanID); err != nil {
×
63
                return err
×
64
        }
×
65

UNCOV
66
        if err := WriteUint32(w, c.FeePerKw); err != nil {
×
67
                return err
×
68
        }
×
69

UNCOV
70
        return WriteBytes(w, c.ExtraData)
×
71
}
72

73
// MsgType returns the integer uniquely identifying this message type on the
74
// wire.
75
//
76
// This is part of the lnwire.Message interface.
UNCOV
77
func (c *UpdateFee) MsgType() MessageType {
×
UNCOV
78
        return MsgUpdateFee
×
UNCOV
79
}
×
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 (c *UpdateFee) SerializedSize() (uint32, error) {
×
NEW
85
        return MessageSerializedSize(c)
×
NEW
86
}
×
87

88
// TargetChanID returns the channel id of the link for which this message is
89
// intended.
90
//
91
// NOTE: Part of peer.LinkUpdater interface.
92
func (c *UpdateFee) TargetChanID() ChannelID {
×
93
        return c.ChanID
×
94
}
×
95

96
// A compile time check to ensure UpdateFee implements the TestMessage interface.
97
var _ TestMessage = (*UpdateFee)(nil)
98

99
// RandTestMessage populates the message with random data suitable for testing.
100
// It uses the rapid testing framework to generate random values.
101
//
102
// This is part of the TestMessage interface.
NEW
103
func (c *UpdateFee) RandTestMessage(t *rapid.T) Message {
×
NEW
104
        return &UpdateFee{
×
NEW
105
                ChanID:    RandChannelID(t),
×
NEW
106
                FeePerKw:  uint32(rapid.IntRange(1, 10000).Draw(t, "feePerKw")),
×
NEW
107
                ExtraData: RandExtraOpaqueData(t, nil),
×
NEW
108
        }
×
NEW
109
}
×
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