• 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

52.78
/lnwire/update_fail_htlc.go
1
package lnwire
2

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

7
        "pgregory.net/rapid"
8
)
9

10
// OpaqueReason is an opaque encrypted byte slice that encodes the exact
11
// failure reason and additional some supplemental data. The contents of this
12
// slice can only be decrypted by the sender of the original HTLC.
13
type OpaqueReason []byte
14

15
// UpdateFailHTLC is sent by Alice to Bob in order to remove a previously added
16
// HTLC. Upon receipt of an UpdateFailHTLC the HTLC should be removed from the
17
// next commitment transaction, with the UpdateFailHTLC propagated backwards in
18
// the route to fully undo the HTLC.
19
type UpdateFailHTLC struct {
20
        // ChanID is the particular active channel that this
21
        // UpdateFailHTLC is bound to.
22
        ChanID ChannelID
23

24
        // ID references which HTLC on the remote node's commitment transaction
25
        // has timed out.
26
        ID uint64
27

28
        // Reason is an onion-encrypted blob that details why the HTLC was
29
        // failed. This blob is only fully decryptable by the initiator of the
30
        // HTLC message.
31
        Reason OpaqueReason
32

33
        // ExtraData is the set of data that was appended to this message to
34
        // fill out the full maximum transport message size. These fields can
35
        // be used to specify optional data such as custom TLV fields.
36
        ExtraData ExtraOpaqueData
37
}
38

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

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

47
// Decode deserializes a serialized UpdateFailHTLC message stored in the passed
48
// io.Reader observing the specified protocol version.
49
//
50
// This is part of the lnwire.Message interface.
51
func (c *UpdateFailHTLC) Decode(r io.Reader, pver uint32) error {
3✔
52
        return ReadElements(r,
3✔
53
                &c.ChanID,
3✔
54
                &c.ID,
3✔
55
                &c.Reason,
3✔
56
                &c.ExtraData,
3✔
57
        )
3✔
58
}
3✔
59

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

69
        if err := WriteUint64(w, c.ID); err != nil {
3✔
70
                return err
×
71
        }
×
72

73
        if err := WriteOpaqueReason(w, c.Reason); err != nil {
3✔
74
                return err
×
75
        }
×
76

77
        return WriteBytes(w, c.ExtraData)
3✔
78
}
79

80
// MsgType returns the integer uniquely identifying this message type on the
81
// wire.
82
//
83
// This is part of the lnwire.Message interface.
84
func (c *UpdateFailHTLC) MsgType() MessageType {
3✔
85
        return MsgUpdateFailHTLC
3✔
86
}
3✔
87

88
// SerializedSize returns the serialized size of the message in bytes.
89
//
90
// This is part of the lnwire.SizeableMessage interface.
NEW
91
func (c *UpdateFailHTLC) SerializedSize() (uint32, error) {
×
NEW
92
        return MessageSerializedSize(c)
×
NEW
93
}
×
94

95
// TargetChanID returns the channel id of the link for which this message is
96
// intended.
97
//
98
// NOTE: Part of peer.LinkUpdater interface.
99
func (c *UpdateFailHTLC) TargetChanID() ChannelID {
3✔
100
        return c.ChanID
3✔
101
}
3✔
102

103
// A compile time check to ensure UpdateFailHTLC implements the TestMessage interface.
104
var _ TestMessage = (*UpdateFailHTLC)(nil)
105

106
// RandTestMessage populates the message with random data suitable for testing.
107
// It uses the rapid testing framework to generate random values.
108
//
109
// This is part of the TestMessage interface.
NEW
110
func (c *UpdateFailHTLC) RandTestMessage(t *rapid.T) Message {
×
NEW
111
        return &UpdateFailHTLC{
×
NEW
112
                ChanID:    RandChannelID(t),
×
NEW
113
                ID:        rapid.Uint64().Draw(t, "id"),
×
NEW
114
                Reason:    RandOpaqueReason(t),
×
NEW
115
                ExtraData: RandExtraOpaqueData(t, nil),
×
NEW
116
        }
×
NEW
117
}
×
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