• 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

52.38
/lnwire/update_fail_malformed_htlc.go
1
package lnwire
2

3
import (
4
        "bytes"
5
        "crypto/sha256"
6
        "io"
7

8
        "pgregory.net/rapid"
9
)
10

11
// UpdateFailMalformedHTLC is sent by either the payment forwarder or by
12
// payment receiver to the payment sender in order to notify it that the onion
13
// blob can't be parsed. For that reason we send this message instead of
14
// obfuscate the onion failure.
15
type UpdateFailMalformedHTLC struct {
16
        // ChanID is the particular active channel that this
17
        // UpdateFailMalformedHTLC is bound to.
18
        ChanID ChannelID
19

20
        // ID references which HTLC on the remote node's commitment transaction
21
        // has timed out.
22
        ID uint64
23

24
        // ShaOnionBlob hash of the onion blob on which can't be parsed by the
25
        // node in the payment path.
26
        ShaOnionBlob [sha256.Size]byte
27

28
        // FailureCode the exact reason why onion blob haven't been parsed.
29
        FailureCode FailCode
30

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

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

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

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

59
// Encode serializes the target UpdateFailMalformedHTLC into the passed
60
// io.Writer observing the protocol version specified.
61
//
62
// This is part of the lnwire.Message interface.
63
func (c *UpdateFailMalformedHTLC) Encode(w *bytes.Buffer,
64
        pver uint32) error {
3✔
65

3✔
66
        if err := WriteChannelID(w, c.ChanID); err != nil {
3✔
67
                return err
×
68
        }
×
69

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

74
        if err := WriteBytes(w, c.ShaOnionBlob[:]); err != nil {
3✔
75
                return err
×
76
        }
×
77

78
        if err := WriteFailCode(w, c.FailureCode); err != nil {
3✔
79
                return err
×
80
        }
×
81

82
        return WriteBytes(w, c.ExtraData)
3✔
83
}
84

85
// MsgType returns the integer uniquely identifying this message type on the
86
// wire.
87
//
88
// This is part of the lnwire.Message interface.
89
func (c *UpdateFailMalformedHTLC) MsgType() MessageType {
3✔
90
        return MsgUpdateFailMalformedHTLC
3✔
91
}
3✔
92

93
// SerializedSize returns the serialized size of the message in bytes.
94
//
95
// This is part of the lnwire.SizeableMessage interface.
NEW
96
func (c *UpdateFailMalformedHTLC) SerializedSize() (uint32, error) {
×
NEW
97
        return MessageSerializedSize(c)
×
NEW
98
}
×
99

100
// TargetChanID returns the channel id of the link for which this message is
101
// intended.
102
//
103
// NOTE: Part of peer.LinkUpdater interface.
104
func (c *UpdateFailMalformedHTLC) TargetChanID() ChannelID {
3✔
105
        return c.ChanID
3✔
106
}
3✔
107

108
// A compile time check to ensure UpdateFailMalformedHTLC implements the
109
// TestMessage interface.
110
var _ TestMessage = (*UpdateFailMalformedHTLC)(nil)
111

112
// RandTestMessage populates the message with random data suitable for testing.
113
// It uses the rapid testing framework to generate random values.
114
//
115
// This is part of the TestMessage interface.
NEW
116
func (c *UpdateFailMalformedHTLC) RandTestMessage(t *rapid.T) Message {
×
NEW
117
        return &UpdateFailMalformedHTLC{
×
NEW
118
                ChanID:       RandChannelID(t),
×
NEW
119
                ID:           rapid.Uint64().Draw(t, "id"),
×
NEW
120
                ShaOnionBlob: RandSHA256Hash(t),
×
NEW
121
                FailureCode:  RandFailCode(t),
×
NEW
122
                ExtraData:    RandExtraOpaqueData(t, nil),
×
NEW
123
        }
×
NEW
124
}
×
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