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

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

8
        "pgregory.net/rapid"
9
)
10

11
// DynReject is a message that is sent during a dynamic commitments negotiation
12
// process. It is sent by both parties to propose new channel parameters.
13
type DynReject struct {
14
        // ChanID identifies the channel whose parameters we are trying to
15
        // re-negotiate.
16
        ChanID ChannelID
17

18
        // UpdateRejections is a bit vector that specifies which of the
19
        // DynPropose parameters we wish to call out as being unacceptable.
20
        UpdateRejections RawFeatureVector
21

22
        // ExtraData is the set of data that was appended to this message to
23
        // fill out the full maximum transport message size. These fields can
24
        // be used to specify optional data such as custom TLV fields.
25
        //
26
        // NOTE: Since the fields in this structure are part of the TLV stream,
27
        // ExtraData will contain all TLV records _except_ the ones that are
28
        // present in earlier parts of this structure.
29
        ExtraData ExtraOpaqueData
30
}
31

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

36
// A compile time check to ensure DynReject implements the lnwire.SizeableMessage
37
// interface.
38
var _ SizeableMessage = (*DynReject)(nil)
39

40
// A compile time check to ensure DynReject implements the lnwire.TestMessage
41
// interface.
42
var _ TestMessage = (*DynReject)(nil)
43

44
// Encode serializes the target DynReject into the passed io.Writer.
45
// Serialization will observe the rules defined by the passed protocol version.
46
//
47
// This is a part of the lnwire.Message interface.
UNCOV
48
func (dr *DynReject) Encode(w *bytes.Buffer, _ uint32) error {
×
UNCOV
49
        if err := WriteChannelID(w, dr.ChanID); err != nil {
×
50
                return err
×
51
        }
×
52

UNCOV
53
        if err := WriteRawFeatureVector(w, &dr.UpdateRejections); err != nil {
×
54
                return err
×
55
        }
×
56

UNCOV
57
        return WriteBytes(w, dr.ExtraData)
×
58
}
59

60
// Decode deserializes the serialized DynReject stored in the passed io.Reader
61
// into the target DynReject using the deserialization rules defined by the
62
// passed protocol version.
63
//
64
// This is a part of the lnwire.Message interface.
UNCOV
65
func (dr *DynReject) Decode(r io.Reader, _ uint32) error {
×
UNCOV
66
        var extra ExtraOpaqueData
×
UNCOV
67

×
UNCOV
68
        if err := ReadElements(
×
UNCOV
69
                r, &dr.ChanID, &dr.UpdateRejections, &extra,
×
UNCOV
70
        ); err != nil {
×
UNCOV
71
                return err
×
UNCOV
72
        }
×
73

UNCOV
74
        if len(extra) != 0 {
×
UNCOV
75
                dr.ExtraData = extra
×
UNCOV
76
        }
×
77

UNCOV
78
        return nil
×
79
}
80

81
// MsgType returns the MessageType code which uniquely identifies this message
82
// as a DynReject on the wire.
83
//
84
// This is part of the lnwire.Message interface.
UNCOV
85
func (dr *DynReject) MsgType() MessageType {
×
UNCOV
86
        return MsgDynReject
×
UNCOV
87
}
×
88

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

96
// RandTestMessage populates the message with random data suitable for testing.
97
// It uses the rapid testing framework to generate random values.
98
//
99
// This is part of the TestMessage interface.
NEW
100
func (dr *DynReject) RandTestMessage(t *rapid.T) Message {
×
NEW
101
        featureVec := NewRawFeatureVector()
×
NEW
102

×
NEW
103
        numFeatures := rapid.IntRange(0, 8).Draw(t, "numRejections")
×
NEW
104
        for i := 0; i < numFeatures; i++ {
×
NEW
105
                bit := FeatureBit(
×
NEW
106
                        rapid.IntRange(0, 31).Draw(
×
NEW
107
                                t, fmt.Sprintf("rejectionBit-%d", i),
×
NEW
108
                        ),
×
NEW
109
                )
×
NEW
110
                featureVec.Set(bit)
×
NEW
111
        }
×
112

NEW
113
        var extraData ExtraOpaqueData
×
NEW
114
        randData := RandExtraOpaqueData(t, nil)
×
NEW
115
        if len(randData) > 0 {
×
NEW
116
                extraData = randData
×
NEW
117
        }
×
118

NEW
119
        return &DynReject{
×
NEW
120
                ChanID:           RandChannelID(t),
×
NEW
121
                UpdateRejections: *featureVec,
×
NEW
122
                ExtraData:        extraData,
×
NEW
123
        }
×
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