• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 16291181271

15 Jul 2025 10:47AM UTC coverage: 57.167% (-10.2%) from 67.349%
16291181271

Pull #9822

github

web-flow
Merge dabf3ae6a into 302551ade
Pull Request #9822: Refactor Payments Code (Head PR for refactor to make sure the itest pass)

650 of 2407 new or added lines in 25 files covered. (27.0%)

28129 existing lines in 454 files now uncovered.

98745 of 172731 relevant lines covered (57.17%)

1.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lnwire/test_message.go
1
package lnwire
2

3
import (
4
        "bytes"
5
        "fmt"
6
        "image/color"
7
        "math"
8

9
        "github.com/btcsuite/btcd/btcec/v2"
10
        "github.com/btcsuite/btcd/btcutil"
11
        "github.com/btcsuite/btcd/chaincfg/chainhash"
12
        "github.com/lightningnetwork/lnd/fn/v2"
13
        "github.com/lightningnetwork/lnd/tlv"
14
        "github.com/stretchr/testify/require"
15
        "pgregory.net/rapid"
16
)
17

18
// TestMessage is an interface that extends the base Message interface with a
19
// method to populate the message with random testing data.
20
type TestMessage interface {
21
        Message
22

23
        // RandTestMessage populates the message with random data suitable for
24
        // testing. It uses the rapid testing framework to generate random
25
        // values.
26
        RandTestMessage(t *rapid.T) Message
27
}
28

29
// A compile time check to ensure AcceptChannel implements the TestMessage
30
// interface.
31
var _ TestMessage = (*AcceptChannel)(nil)
32

33
// RandTestMessage populates the message with random data suitable for testing.
34
// It uses the rapid testing framework to generate random values.
35
//
36
// This is part of the TestMessage interface.
UNCOV
37
func (a *AcceptChannel) RandTestMessage(t *rapid.T) Message {
×
UNCOV
38
        var pendingChanID [32]byte
×
UNCOV
39
        pendingChanIDBytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(
×
UNCOV
40
                t, "pendingChanID",
×
UNCOV
41
        )
×
UNCOV
42
        copy(pendingChanID[:], pendingChanIDBytes)
×
UNCOV
43

×
UNCOV
44
        var channelType *ChannelType
×
UNCOV
45
        includeChannelType := rapid.Bool().Draw(t, "includeChannelType")
×
UNCOV
46
        includeLeaseExpiry := rapid.Bool().Draw(t, "includeLeaseExpiry")
×
UNCOV
47
        includeLocalNonce := rapid.Bool().Draw(t, "includeLocalNonce")
×
UNCOV
48

×
UNCOV
49
        if includeChannelType {
×
UNCOV
50
                channelType = RandChannelType(t)
×
UNCOV
51
        }
×
52

UNCOV
53
        var leaseExpiry *LeaseExpiry
×
UNCOV
54
        if includeLeaseExpiry {
×
UNCOV
55
                leaseExpiry = RandLeaseExpiry(t)
×
UNCOV
56
        }
×
57

UNCOV
58
        var localNonce OptMusig2NonceTLV
×
UNCOV
59
        if includeLocalNonce {
×
UNCOV
60
                nonce := RandMusig2Nonce(t)
×
UNCOV
61
                localNonce = tlv.SomeRecordT(
×
UNCOV
62
                        tlv.NewRecordT[NonceRecordTypeT, Musig2Nonce](nonce),
×
UNCOV
63
                )
×
UNCOV
64
        }
×
65

UNCOV
66
        return &AcceptChannel{
×
UNCOV
67
                PendingChannelID: pendingChanID,
×
UNCOV
68
                DustLimit: btcutil.Amount(
×
UNCOV
69
                        rapid.IntRange(100, 1000).Draw(t, "dustLimit"),
×
UNCOV
70
                ),
×
UNCOV
71
                MaxValueInFlight: MilliSatoshi(
×
UNCOV
72
                        rapid.IntRange(10000, 1000000).Draw(
×
UNCOV
73
                                t, "maxValueInFlight",
×
UNCOV
74
                        ),
×
UNCOV
75
                ),
×
UNCOV
76
                ChannelReserve: btcutil.Amount(
×
UNCOV
77
                        rapid.IntRange(1000, 10000).Draw(t, "channelReserve"),
×
UNCOV
78
                ),
×
UNCOV
79
                HtlcMinimum: MilliSatoshi(
×
UNCOV
80
                        rapid.IntRange(1, 1000).Draw(t, "htlcMinimum"),
×
UNCOV
81
                ),
×
UNCOV
82
                MinAcceptDepth: uint32(
×
UNCOV
83
                        rapid.IntRange(1, 10).Draw(t, "minAcceptDepth"),
×
UNCOV
84
                ),
×
UNCOV
85
                CsvDelay: uint16(
×
UNCOV
86
                        rapid.IntRange(144, 1000).Draw(t, "csvDelay"),
×
UNCOV
87
                ),
×
UNCOV
88
                MaxAcceptedHTLCs: uint16(
×
UNCOV
89
                        rapid.IntRange(10, 500).Draw(t, "maxAcceptedHTLCs"),
×
UNCOV
90
                ),
×
UNCOV
91
                FundingKey:            RandPubKey(t),
×
UNCOV
92
                RevocationPoint:       RandPubKey(t),
×
UNCOV
93
                PaymentPoint:          RandPubKey(t),
×
UNCOV
94
                DelayedPaymentPoint:   RandPubKey(t),
×
UNCOV
95
                HtlcPoint:             RandPubKey(t),
×
UNCOV
96
                FirstCommitmentPoint:  RandPubKey(t),
×
UNCOV
97
                UpfrontShutdownScript: RandDeliveryAddress(t),
×
UNCOV
98
                ChannelType:           channelType,
×
UNCOV
99
                LeaseExpiry:           leaseExpiry,
×
UNCOV
100
                LocalNonce:            localNonce,
×
UNCOV
101
                ExtraData:             RandExtraOpaqueData(t, nil),
×
UNCOV
102
        }
×
103
}
104

105
// A compile time check to ensure AnnounceSignatures1 implements the
106
// lnwire.TestMessage interface.
107
var _ TestMessage = (*AnnounceSignatures1)(nil)
108

109
// RandTestMessage populates the message with random data suitable for testing.
110
// It uses the rapid testing framework to generate random values.
111
//
112
// This is part of the TestMessage interface.
UNCOV
113
func (a *AnnounceSignatures1) RandTestMessage(t *rapid.T) Message {
×
UNCOV
114
        return &AnnounceSignatures1{
×
UNCOV
115
                ChannelID:        RandChannelID(t),
×
UNCOV
116
                ShortChannelID:   RandShortChannelID(t),
×
UNCOV
117
                NodeSignature:    RandSignature(t),
×
UNCOV
118
                BitcoinSignature: RandSignature(t),
×
UNCOV
119
                ExtraOpaqueData:  RandExtraOpaqueData(t, nil),
×
UNCOV
120
        }
×
UNCOV
121
}
×
122

123
// A compile time check to ensure AnnounceSignatures2 implements the
124
// lnwire.TestMessage interface.
125
var _ TestMessage = (*AnnounceSignatures2)(nil)
126

127
// RandTestMessage populates the message with random data suitable for testing.
128
// It uses the rapid testing framework to generate random values.
129
//
130
// This is part of the TestMessage interface.
UNCOV
131
func (a *AnnounceSignatures2) RandTestMessage(t *rapid.T) Message {
×
UNCOV
132
        return &AnnounceSignatures2{
×
UNCOV
133
                ChannelID:        RandChannelID(t),
×
UNCOV
134
                ShortChannelID:   RandShortChannelID(t),
×
UNCOV
135
                PartialSignature: *RandPartialSig(t),
×
UNCOV
136
                ExtraOpaqueData:  RandExtraOpaqueData(t, nil),
×
UNCOV
137
        }
×
UNCOV
138
}
×
139

140
// A compile time check to ensure ChannelAnnouncement1 implements the
141
// TestMessage interface.
142
var _ TestMessage = (*ChannelAnnouncement1)(nil)
143

144
// RandTestMessage populates the message with random data suitable for testing.
145
// It uses the rapid testing framework to generate random values.
146
//
147
// This is part of the TestMessage interface.
UNCOV
148
func (a *ChannelAnnouncement1) RandTestMessage(t *rapid.T) Message {
×
UNCOV
149
        // Generate Node IDs and Bitcoin keys (compressed public keys)
×
UNCOV
150
        node1PubKey := RandPubKey(t)
×
UNCOV
151
        node2PubKey := RandPubKey(t)
×
UNCOV
152
        bitcoin1PubKey := RandPubKey(t)
×
UNCOV
153
        bitcoin2PubKey := RandPubKey(t)
×
UNCOV
154

×
UNCOV
155
        // Convert to byte arrays
×
UNCOV
156
        var nodeID1, nodeID2, bitcoinKey1, bitcoinKey2 [33]byte
×
UNCOV
157
        copy(nodeID1[:], node1PubKey.SerializeCompressed())
×
UNCOV
158
        copy(nodeID2[:], node2PubKey.SerializeCompressed())
×
UNCOV
159
        copy(bitcoinKey1[:], bitcoin1PubKey.SerializeCompressed())
×
UNCOV
160
        copy(bitcoinKey2[:], bitcoin2PubKey.SerializeCompressed())
×
UNCOV
161

×
UNCOV
162
        // Ensure nodeID1 is numerically less than nodeID2
×
UNCOV
163
        // This is a requirement stated in the field description
×
UNCOV
164
        if bytes.Compare(nodeID1[:], nodeID2[:]) > 0 {
×
UNCOV
165
                nodeID1, nodeID2 = nodeID2, nodeID1
×
UNCOV
166
        }
×
167

168
        // Generate chain hash
UNCOV
169
        chainHash := RandChainHash(t)
×
UNCOV
170
        var hash chainhash.Hash
×
UNCOV
171
        copy(hash[:], chainHash[:])
×
UNCOV
172

×
UNCOV
173
        return &ChannelAnnouncement1{
×
UNCOV
174
                NodeSig1:        RandSignature(t),
×
UNCOV
175
                NodeSig2:        RandSignature(t),
×
UNCOV
176
                BitcoinSig1:     RandSignature(t),
×
UNCOV
177
                BitcoinSig2:     RandSignature(t),
×
UNCOV
178
                Features:        RandFeatureVector(t),
×
UNCOV
179
                ChainHash:       hash,
×
UNCOV
180
                ShortChannelID:  RandShortChannelID(t),
×
UNCOV
181
                NodeID1:         nodeID1,
×
UNCOV
182
                NodeID2:         nodeID2,
×
UNCOV
183
                BitcoinKey1:     bitcoinKey1,
×
UNCOV
184
                BitcoinKey2:     bitcoinKey2,
×
UNCOV
185
                ExtraOpaqueData: RandExtraOpaqueData(t, nil),
×
UNCOV
186
        }
×
187
}
188

189
// A compile time check to ensure ChannelAnnouncement2 implements the
190
// lnwire.TestMessage interface.
191
var _ TestMessage = (*ChannelAnnouncement2)(nil)
192

193
// RandTestMessage populates the message with random data suitable for testing.
194
// It uses the rapid testing framework to generate random values.
195
//
196
// This is part of the TestMessage interface.
UNCOV
197
func (c *ChannelAnnouncement2) RandTestMessage(t *rapid.T) Message {
×
UNCOV
198
        features := RandFeatureVector(t)
×
UNCOV
199
        shortChanID := RandShortChannelID(t)
×
UNCOV
200
        capacity := uint64(rapid.IntRange(1, 16777215).Draw(t, "capacity"))
×
UNCOV
201

×
UNCOV
202
        var nodeID1, nodeID2 [33]byte
×
UNCOV
203
        copy(nodeID1[:], RandPubKey(t).SerializeCompressed())
×
UNCOV
204
        copy(nodeID2[:], RandPubKey(t).SerializeCompressed())
×
UNCOV
205

×
UNCOV
206
        // Make sure nodeID1 is numerically less than nodeID2 (as per spec).
×
UNCOV
207
        if bytes.Compare(nodeID1[:], nodeID2[:]) > 0 {
×
UNCOV
208
                nodeID1, nodeID2 = nodeID2, nodeID1
×
UNCOV
209
        }
×
210

UNCOV
211
        chainHash := RandChainHash(t)
×
UNCOV
212
        var chainHashObj chainhash.Hash
×
UNCOV
213
        copy(chainHashObj[:], chainHash[:])
×
UNCOV
214

×
UNCOV
215
        msg := &ChannelAnnouncement2{
×
UNCOV
216
                Signature: RandSignature(t),
×
UNCOV
217
                ChainHash: tlv.NewPrimitiveRecord[tlv.TlvType0, chainhash.Hash](
×
UNCOV
218
                        chainHashObj,
×
UNCOV
219
                ),
×
UNCOV
220
                Features: tlv.NewRecordT[tlv.TlvType2, RawFeatureVector](
×
UNCOV
221
                        *features,
×
UNCOV
222
                ),
×
UNCOV
223
                ShortChannelID: tlv.NewRecordT[tlv.TlvType4, ShortChannelID](
×
UNCOV
224
                        shortChanID,
×
UNCOV
225
                ),
×
UNCOV
226
                Capacity: tlv.NewPrimitiveRecord[tlv.TlvType6, uint64](
×
UNCOV
227
                        capacity,
×
UNCOV
228
                ),
×
UNCOV
229
                NodeID1: tlv.NewPrimitiveRecord[tlv.TlvType8, [33]byte](
×
UNCOV
230
                        nodeID1,
×
UNCOV
231
                ),
×
UNCOV
232
                NodeID2: tlv.NewPrimitiveRecord[tlv.TlvType10, [33]byte](
×
UNCOV
233
                        nodeID2,
×
UNCOV
234
                ),
×
UNCOV
235
                ExtraOpaqueData: RandExtraOpaqueData(t, nil),
×
UNCOV
236
        }
×
UNCOV
237

×
UNCOV
238
        msg.Signature.ForceSchnorr()
×
UNCOV
239

×
UNCOV
240
        // Randomly include optional fields
×
UNCOV
241
        if rapid.Bool().Draw(t, "includeBitcoinKey1") {
×
UNCOV
242
                var bitcoinKey1 [33]byte
×
UNCOV
243
                copy(bitcoinKey1[:], RandPubKey(t).SerializeCompressed())
×
UNCOV
244
                msg.BitcoinKey1 = tlv.SomeRecordT(
×
UNCOV
245
                        tlv.NewPrimitiveRecord[tlv.TlvType12, [33]byte](
×
UNCOV
246
                                bitcoinKey1,
×
UNCOV
247
                        ),
×
UNCOV
248
                )
×
UNCOV
249
        }
×
250

UNCOV
251
        if rapid.Bool().Draw(t, "includeBitcoinKey2") {
×
UNCOV
252
                var bitcoinKey2 [33]byte
×
UNCOV
253
                copy(bitcoinKey2[:], RandPubKey(t).SerializeCompressed())
×
UNCOV
254
                msg.BitcoinKey2 = tlv.SomeRecordT(
×
UNCOV
255
                        tlv.NewPrimitiveRecord[tlv.TlvType14, [33]byte](
×
UNCOV
256
                                bitcoinKey2,
×
UNCOV
257
                        ),
×
UNCOV
258
                )
×
UNCOV
259
        }
×
260

UNCOV
261
        if rapid.Bool().Draw(t, "includeMerkleRootHash") {
×
UNCOV
262
                hash := RandSHA256Hash(t)
×
UNCOV
263
                var merkleRootHash [32]byte
×
UNCOV
264
                copy(merkleRootHash[:], hash[:])
×
UNCOV
265
                msg.MerkleRootHash = tlv.SomeRecordT(
×
UNCOV
266
                        tlv.NewPrimitiveRecord[tlv.TlvType16, [32]byte](
×
UNCOV
267
                                merkleRootHash,
×
UNCOV
268
                        ),
×
UNCOV
269
                )
×
UNCOV
270
        }
×
271

UNCOV
272
        return msg
×
273
}
274

275
// A compile time check to ensure ChannelReady implements the lnwire.TestMessage
276
// interface.
277
var _ TestMessage = (*ChannelReady)(nil)
278

279
// RandTestMessage populates the message with random data suitable for testing.
280
// It uses the rapid testing framework to generate random values.
281
//
282
// This is part of the TestMessage interface.
UNCOV
283
func (c *ChannelReady) RandTestMessage(t *rapid.T) Message {
×
UNCOV
284
        msg := &ChannelReady{
×
UNCOV
285
                ChanID:                 RandChannelID(t),
×
UNCOV
286
                NextPerCommitmentPoint: RandPubKey(t),
×
UNCOV
287
                ExtraData:              RandExtraOpaqueData(t, nil),
×
UNCOV
288
        }
×
UNCOV
289

×
UNCOV
290
        includeAliasScid := rapid.Bool().Draw(t, "includeAliasScid")
×
UNCOV
291
        includeNextLocalNonce := rapid.Bool().Draw(t, "includeNextLocalNonce")
×
UNCOV
292
        includeAnnouncementNodeNonce := rapid.Bool().Draw(
×
UNCOV
293
                t, "includeAnnouncementNodeNonce",
×
UNCOV
294
        )
×
UNCOV
295
        includeAnnouncementBitcoinNonce := rapid.Bool().Draw(
×
UNCOV
296
                t, "includeAnnouncementBitcoinNonce",
×
UNCOV
297
        )
×
UNCOV
298

×
UNCOV
299
        if includeAliasScid {
×
UNCOV
300
                scid := RandShortChannelID(t)
×
UNCOV
301
                msg.AliasScid = &scid
×
UNCOV
302
        }
×
303

UNCOV
304
        if includeNextLocalNonce {
×
UNCOV
305
                nonce := RandMusig2Nonce(t)
×
UNCOV
306
                msg.NextLocalNonce = SomeMusig2Nonce(nonce)
×
UNCOV
307
        }
×
308

UNCOV
309
        if includeAnnouncementNodeNonce {
×
UNCOV
310
                nonce := RandMusig2Nonce(t)
×
UNCOV
311
                msg.AnnouncementNodeNonce = tlv.SomeRecordT(
×
UNCOV
312
                        tlv.NewRecordT[tlv.TlvType0, Musig2Nonce](nonce),
×
UNCOV
313
                )
×
UNCOV
314
        }
×
315

UNCOV
316
        if includeAnnouncementBitcoinNonce {
×
UNCOV
317
                nonce := RandMusig2Nonce(t)
×
UNCOV
318
                msg.AnnouncementBitcoinNonce = tlv.SomeRecordT(
×
UNCOV
319
                        tlv.NewRecordT[tlv.TlvType2, Musig2Nonce](nonce),
×
UNCOV
320
                )
×
UNCOV
321
        }
×
322

UNCOV
323
        return msg
×
324
}
325

326
// A compile time check to ensure ChannelReestablish implements the
327
// lnwire.TestMessage interface.
328
var _ TestMessage = (*ChannelReestablish)(nil)
329

330
// RandTestMessage populates the message with random data suitable for testing.
331
// It uses the rapid testing framework to generate random values.
332
//
333
// This is part of the TestMessage interface.
UNCOV
334
func (a *ChannelReestablish) RandTestMessage(t *rapid.T) Message {
×
UNCOV
335
        msg := &ChannelReestablish{
×
UNCOV
336
                ChanID: RandChannelID(t),
×
UNCOV
337
                NextLocalCommitHeight: rapid.Uint64().Draw(
×
UNCOV
338
                        t, "nextLocalCommitHeight",
×
UNCOV
339
                ),
×
UNCOV
340
                RemoteCommitTailHeight: rapid.Uint64().Draw(
×
UNCOV
341
                        t, "remoteCommitTailHeight",
×
UNCOV
342
                ),
×
UNCOV
343
                LastRemoteCommitSecret:    RandPaymentPreimage(t),
×
UNCOV
344
                LocalUnrevokedCommitPoint: RandPubKey(t),
×
UNCOV
345
                ExtraData:                 RandExtraOpaqueData(t, nil),
×
UNCOV
346
        }
×
UNCOV
347

×
UNCOV
348
        // Randomly decide whether to include optional fields
×
UNCOV
349
        includeLocalNonce := rapid.Bool().Draw(t, "includeLocalNonce")
×
UNCOV
350
        includeDynHeight := rapid.Bool().Draw(t, "includeDynHeight")
×
UNCOV
351

×
UNCOV
352
        if includeLocalNonce {
×
UNCOV
353
                nonce := RandMusig2Nonce(t)
×
UNCOV
354
                msg.LocalNonce = SomeMusig2Nonce(nonce)
×
UNCOV
355
        }
×
356

UNCOV
357
        if includeDynHeight {
×
UNCOV
358
                height := DynHeight(rapid.Uint64().Draw(t, "dynHeight"))
×
UNCOV
359
                msg.DynHeight = fn.Some(height)
×
UNCOV
360
        }
×
361

UNCOV
362
        return msg
×
363
}
364

365
// A compile time check to ensure ChannelUpdate1 implements the TestMessage
366
// interface.
367
var _ TestMessage = (*ChannelUpdate1)(nil)
368

369
// RandTestMessage populates the message with random data suitable for testing.
370
// It uses the rapid testing framework to generate random values.
371
//
372
// This is part of the TestMessage interface.
UNCOV
373
func (a *ChannelUpdate1) RandTestMessage(t *rapid.T) Message {
×
UNCOV
374
        // Generate random message flags
×
UNCOV
375
        // Randomly decide whether to include max HTLC field
×
UNCOV
376
        includeMaxHtlc := rapid.Bool().Draw(t, "includeMaxHtlc")
×
UNCOV
377
        var msgFlags ChanUpdateMsgFlags
×
UNCOV
378
        if includeMaxHtlc {
×
UNCOV
379
                msgFlags |= ChanUpdateRequiredMaxHtlc
×
UNCOV
380
        }
×
381

382
        // Generate random channel flags
383
        // Randomly decide direction (node1 or node2)
UNCOV
384
        isNode2 := rapid.Bool().Draw(t, "isNode2")
×
UNCOV
385
        var chanFlags ChanUpdateChanFlags
×
UNCOV
386
        if isNode2 {
×
UNCOV
387
                chanFlags |= ChanUpdateDirection
×
UNCOV
388
        }
×
389

390
        // Randomly decide if channel is disabled
UNCOV
391
        isDisabled := rapid.Bool().Draw(t, "isDisabled")
×
UNCOV
392
        if isDisabled {
×
UNCOV
393
                chanFlags |= ChanUpdateDisabled
×
UNCOV
394
        }
×
395

396
        // Generate chain hash
UNCOV
397
        chainHash := RandChainHash(t)
×
UNCOV
398
        var hash chainhash.Hash
×
UNCOV
399
        copy(hash[:], chainHash[:])
×
UNCOV
400

×
UNCOV
401
        // Generate other random fields
×
UNCOV
402
        maxHtlc := MilliSatoshi(rapid.Uint64().Draw(t, "maxHtlc"))
×
UNCOV
403

×
UNCOV
404
        // If max HTLC flag is not set, we need to zero the value
×
UNCOV
405
        if !includeMaxHtlc {
×
UNCOV
406
                maxHtlc = 0
×
UNCOV
407
        }
×
408

409
        // Randomly decide if an inbound fee should be included.
410
        // By default, our extra opaque data will just be random TLV but if we
411
        // include an inbound fee, then we will also set the record in the
412
        // extra opaque data.
UNCOV
413
        var (
×
UNCOV
414
                customRecords, _ = RandCustomRecords(t, nil, false)
×
UNCOV
415
                inboundFee       tlv.OptionalRecordT[tlv.TlvType55555, Fee]
×
UNCOV
416
        )
×
UNCOV
417
        includeInboundFee := rapid.Bool().Draw(t, "includeInboundFee")
×
UNCOV
418
        if includeInboundFee {
×
UNCOV
419
                if customRecords == nil {
×
UNCOV
420
                        customRecords = make(CustomRecords)
×
UNCOV
421
                }
×
422

UNCOV
423
                inFeeBase := int32(
×
UNCOV
424
                        rapid.IntRange(-1000, 1000).Draw(t, "inFeeBase"),
×
UNCOV
425
                )
×
UNCOV
426
                inFeeProp := int32(
×
UNCOV
427
                        rapid.IntRange(-1000, 1000).Draw(t, "inFeeProp"),
×
UNCOV
428
                )
×
UNCOV
429
                fee := Fee{
×
UNCOV
430
                        BaseFee: inFeeBase,
×
UNCOV
431
                        FeeRate: inFeeProp,
×
UNCOV
432
                }
×
UNCOV
433
                inboundFee = tlv.SomeRecordT(
×
UNCOV
434
                        tlv.NewRecordT[tlv.TlvType55555, Fee](fee),
×
UNCOV
435
                )
×
UNCOV
436

×
UNCOV
437
                var b bytes.Buffer
×
UNCOV
438
                feeRecord := fee.Record()
×
UNCOV
439
                err := feeRecord.Encode(&b)
×
UNCOV
440
                require.NoError(t, err)
×
UNCOV
441

×
UNCOV
442
                customRecords[uint64(FeeRecordType)] = b.Bytes()
×
443
        }
444

UNCOV
445
        extraBytes, err := customRecords.Serialize()
×
UNCOV
446
        require.NoError(t, err)
×
UNCOV
447

×
UNCOV
448
        return &ChannelUpdate1{
×
UNCOV
449
                Signature:      RandSignature(t),
×
UNCOV
450
                ChainHash:      hash,
×
UNCOV
451
                ShortChannelID: RandShortChannelID(t),
×
UNCOV
452
                Timestamp: uint32(rapid.IntRange(0, 0x7FFFFFFF).Draw(
×
UNCOV
453
                        t, "timestamp"),
×
UNCOV
454
                ),
×
UNCOV
455
                MessageFlags: msgFlags,
×
UNCOV
456
                ChannelFlags: chanFlags,
×
UNCOV
457
                TimeLockDelta: uint16(rapid.IntRange(0, 65535).Draw(
×
UNCOV
458
                        t, "timelockDelta"),
×
UNCOV
459
                ),
×
UNCOV
460
                HtlcMinimumMsat: MilliSatoshi(rapid.Uint64().Draw(
×
UNCOV
461
                        t, "htlcMinimum"),
×
UNCOV
462
                ),
×
UNCOV
463
                BaseFee: uint32(rapid.IntRange(0, 0x7FFFFFFF).Draw(
×
UNCOV
464
                        t, "baseFee"),
×
UNCOV
465
                ),
×
UNCOV
466
                FeeRate: uint32(rapid.IntRange(0, 0x7FFFFFFF).Draw(
×
UNCOV
467
                        t, "feeRate"),
×
UNCOV
468
                ),
×
UNCOV
469
                HtlcMaximumMsat: maxHtlc,
×
UNCOV
470
                InboundFee:      inboundFee,
×
UNCOV
471
                ExtraOpaqueData: extraBytes,
×
UNCOV
472
        }
×
473
}
474

475
// A compile time check to ensure ChannelUpdate2 implements the
476
// lnwire.TestMessage interface.
477
var _ TestMessage = (*ChannelUpdate2)(nil)
478

479
// RandTestMessage populates the message with random data suitable for testing.
480
// It uses the rapid testing framework to generate random values.
481
//
482
// This is part of the TestMessage interface.
UNCOV
483
func (c *ChannelUpdate2) RandTestMessage(t *rapid.T) Message {
×
UNCOV
484
        shortChanID := RandShortChannelID(t)
×
UNCOV
485
        blockHeight := uint32(rapid.IntRange(0, 1000000).Draw(t, "blockHeight"))
×
UNCOV
486

×
UNCOV
487
        var disabledFlags ChanUpdateDisableFlags
×
UNCOV
488
        if rapid.Bool().Draw(t, "disableIncoming") {
×
UNCOV
489
                disabledFlags |= ChanUpdateDisableIncoming
×
UNCOV
490
        }
×
UNCOV
491
        if rapid.Bool().Draw(t, "disableOutgoing") {
×
UNCOV
492
                disabledFlags |= ChanUpdateDisableOutgoing
×
UNCOV
493
        }
×
494

UNCOV
495
        cltvExpiryDelta := uint16(rapid.IntRange(10, 200).Draw(
×
UNCOV
496
                t, "cltvExpiryDelta"),
×
UNCOV
497
        )
×
UNCOV
498

×
UNCOV
499
        htlcMinMsat := MilliSatoshi(rapid.IntRange(1, 10000).Draw(
×
UNCOV
500
                t, "htlcMinMsat"),
×
UNCOV
501
        )
×
UNCOV
502
        htlcMaxMsat := MilliSatoshi(rapid.IntRange(10000, 100000000).Draw(
×
UNCOV
503
                t, "htlcMaxMsat"),
×
UNCOV
504
        )
×
UNCOV
505
        feeBaseMsat := uint32(rapid.IntRange(0, 10000).Draw(t, "feeBaseMsat"))
×
UNCOV
506
        feeProportionalMillionths := uint32(rapid.IntRange(0, 10000).Draw(
×
UNCOV
507
                t, "feeProportionalMillionths"),
×
UNCOV
508
        )
×
UNCOV
509

×
UNCOV
510
        chainHash := RandChainHash(t)
×
UNCOV
511
        var chainHashObj chainhash.Hash
×
UNCOV
512
        copy(chainHashObj[:], chainHash[:])
×
UNCOV
513

×
UNCOV
514
        //nolint:ll
×
UNCOV
515
        msg := &ChannelUpdate2{
×
UNCOV
516
                Signature: RandSignature(t),
×
UNCOV
517
                ChainHash: tlv.NewPrimitiveRecord[tlv.TlvType0, chainhash.Hash](
×
UNCOV
518
                        chainHashObj,
×
UNCOV
519
                ),
×
UNCOV
520
                ShortChannelID: tlv.NewRecordT[tlv.TlvType2, ShortChannelID](
×
UNCOV
521
                        shortChanID,
×
UNCOV
522
                ),
×
UNCOV
523
                BlockHeight: tlv.NewPrimitiveRecord[tlv.TlvType4, uint32](
×
UNCOV
524
                        blockHeight,
×
UNCOV
525
                ),
×
UNCOV
526
                DisabledFlags: tlv.NewPrimitiveRecord[tlv.TlvType6, ChanUpdateDisableFlags]( //nolint:ll
×
UNCOV
527
                        disabledFlags,
×
UNCOV
528
                ),
×
UNCOV
529
                CLTVExpiryDelta: tlv.NewPrimitiveRecord[tlv.TlvType10, uint16](
×
UNCOV
530
                        cltvExpiryDelta,
×
UNCOV
531
                ),
×
UNCOV
532
                HTLCMinimumMsat: tlv.NewPrimitiveRecord[tlv.TlvType12, MilliSatoshi](
×
UNCOV
533
                        htlcMinMsat,
×
UNCOV
534
                ),
×
UNCOV
535
                HTLCMaximumMsat: tlv.NewPrimitiveRecord[tlv.TlvType14, MilliSatoshi](
×
UNCOV
536
                        htlcMaxMsat,
×
UNCOV
537
                ),
×
UNCOV
538
                FeeBaseMsat: tlv.NewPrimitiveRecord[tlv.TlvType16, uint32](
×
UNCOV
539
                        feeBaseMsat,
×
UNCOV
540
                ),
×
UNCOV
541
                FeeProportionalMillionths: tlv.NewPrimitiveRecord[tlv.TlvType18, uint32](
×
UNCOV
542
                        feeProportionalMillionths,
×
UNCOV
543
                ),
×
UNCOV
544
                ExtraOpaqueData: RandExtraOpaqueData(t, nil),
×
UNCOV
545
        }
×
UNCOV
546

×
UNCOV
547
        msg.Signature.ForceSchnorr()
×
UNCOV
548

×
UNCOV
549
        if rapid.Bool().Draw(t, "isSecondPeer") {
×
UNCOV
550
                msg.SecondPeer = tlv.SomeRecordT(
×
UNCOV
551
                        tlv.RecordT[tlv.TlvType8, TrueBoolean]{},
×
UNCOV
552
                )
×
UNCOV
553
        }
×
554

UNCOV
555
        return msg
×
556
}
557

558
// A compile time check to ensure ClosingComplete implements the
559
// lnwire.TestMessage interface.
560
var _ TestMessage = (*ClosingComplete)(nil)
561

562
// RandTestMessage populates the message with random data suitable for testing.
563
// It uses the rapid testing framework to generate random values.
564
//
565
// This is part of the TestMessage interface.
UNCOV
566
func (c *ClosingComplete) RandTestMessage(t *rapid.T) Message {
×
UNCOV
567
        msg := &ClosingComplete{
×
UNCOV
568
                ChannelID: RandChannelID(t),
×
UNCOV
569
                FeeSatoshis: btcutil.Amount(rapid.Int64Range(0, 1000000).Draw(
×
UNCOV
570
                        t, "feeSatoshis"),
×
UNCOV
571
                ),
×
UNCOV
572
                LockTime: rapid.Uint32Range(0, 0xffffffff).Draw(
×
UNCOV
573
                        t, "lockTime",
×
UNCOV
574
                ),
×
UNCOV
575
                CloseeScript: RandDeliveryAddress(t),
×
UNCOV
576
                CloserScript: RandDeliveryAddress(t),
×
UNCOV
577
                ExtraData:    RandExtraOpaqueData(t, nil),
×
UNCOV
578
        }
×
UNCOV
579

×
UNCOV
580
        includeCloserNoClosee := rapid.Bool().Draw(t, "includeCloserNoClosee")
×
UNCOV
581
        includeNoCloserClosee := rapid.Bool().Draw(t, "includeNoCloserClosee")
×
UNCOV
582
        includeCloserAndClosee := rapid.Bool().Draw(t, "includeCloserAndClosee")
×
UNCOV
583

×
UNCOV
584
        // Ensure at least one signature is present.
×
UNCOV
585
        if !includeCloserNoClosee && !includeNoCloserClosee &&
×
UNCOV
586
                !includeCloserAndClosee {
×
UNCOV
587

×
UNCOV
588
                // If all are false, enable at least one randomly.
×
UNCOV
589
                choice := rapid.IntRange(0, 2).Draw(t, "sigChoice")
×
UNCOV
590
                switch choice {
×
UNCOV
591
                case 0:
×
UNCOV
592
                        includeCloserNoClosee = true
×
UNCOV
593
                case 1:
×
UNCOV
594
                        includeNoCloserClosee = true
×
UNCOV
595
                case 2:
×
UNCOV
596
                        includeCloserAndClosee = true
×
597
                }
598
        }
599

UNCOV
600
        if includeCloserNoClosee {
×
UNCOV
601
                sig := RandSignature(t)
×
UNCOV
602
                msg.CloserNoClosee = tlv.SomeRecordT(
×
UNCOV
603
                        tlv.NewRecordT[tlv.TlvType1, Sig](sig),
×
UNCOV
604
                )
×
UNCOV
605
        }
×
606

UNCOV
607
        if includeNoCloserClosee {
×
UNCOV
608
                sig := RandSignature(t)
×
UNCOV
609
                msg.NoCloserClosee = tlv.SomeRecordT(
×
UNCOV
610
                        tlv.NewRecordT[tlv.TlvType2, Sig](sig),
×
UNCOV
611
                )
×
UNCOV
612
        }
×
613

UNCOV
614
        if includeCloserAndClosee {
×
UNCOV
615
                sig := RandSignature(t)
×
UNCOV
616
                msg.CloserAndClosee = tlv.SomeRecordT(
×
UNCOV
617
                        tlv.NewRecordT[tlv.TlvType3, Sig](sig),
×
UNCOV
618
                )
×
UNCOV
619
        }
×
620

UNCOV
621
        return msg
×
622
}
623

624
// A compile time check to ensure ClosingSig implements the lnwire.TestMessage
625
// interface.
626
var _ TestMessage = (*ClosingSig)(nil)
627

628
// RandTestMessage populates the message with random data suitable for testing.
629
// It uses the rapid testing framework to generate random values.
630
//
631
// This is part of the TestMessage interface.
UNCOV
632
func (c *ClosingSig) RandTestMessage(t *rapid.T) Message {
×
UNCOV
633
        msg := &ClosingSig{
×
UNCOV
634
                ChannelID:    RandChannelID(t),
×
UNCOV
635
                CloseeScript: RandDeliveryAddress(t),
×
UNCOV
636
                CloserScript: RandDeliveryAddress(t),
×
UNCOV
637
                ExtraData:    RandExtraOpaqueData(t, nil),
×
UNCOV
638
        }
×
UNCOV
639

×
UNCOV
640
        includeCloserNoClosee := rapid.Bool().Draw(t, "includeCloserNoClosee")
×
UNCOV
641
        includeNoCloserClosee := rapid.Bool().Draw(t, "includeNoCloserClosee")
×
UNCOV
642
        includeCloserAndClosee := rapid.Bool().Draw(t, "includeCloserAndClosee")
×
UNCOV
643

×
UNCOV
644
        // Ensure at least one signature is present.
×
UNCOV
645
        if !includeCloserNoClosee && !includeNoCloserClosee &&
×
UNCOV
646
                !includeCloserAndClosee {
×
UNCOV
647

×
UNCOV
648
                // If all are false, enable at least one randomly.
×
UNCOV
649
                choice := rapid.IntRange(0, 2).Draw(t, "sigChoice")
×
UNCOV
650
                switch choice {
×
UNCOV
651
                case 0:
×
UNCOV
652
                        includeCloserNoClosee = true
×
UNCOV
653
                case 1:
×
UNCOV
654
                        includeNoCloserClosee = true
×
UNCOV
655
                case 2:
×
UNCOV
656
                        includeCloserAndClosee = true
×
657
                }
658
        }
659

UNCOV
660
        if includeCloserNoClosee {
×
UNCOV
661
                sig := RandSignature(t)
×
UNCOV
662
                msg.CloserNoClosee = tlv.SomeRecordT(
×
UNCOV
663
                        tlv.NewRecordT[tlv.TlvType1, Sig](sig),
×
UNCOV
664
                )
×
UNCOV
665
        }
×
666

UNCOV
667
        if includeNoCloserClosee {
×
UNCOV
668
                sig := RandSignature(t)
×
UNCOV
669
                msg.NoCloserClosee = tlv.SomeRecordT(
×
UNCOV
670
                        tlv.NewRecordT[tlv.TlvType2, Sig](sig),
×
UNCOV
671
                )
×
UNCOV
672
        }
×
673

UNCOV
674
        if includeCloserAndClosee {
×
UNCOV
675
                sig := RandSignature(t)
×
UNCOV
676
                msg.CloserAndClosee = tlv.SomeRecordT(
×
UNCOV
677
                        tlv.NewRecordT[tlv.TlvType3, Sig](sig),
×
UNCOV
678
                )
×
UNCOV
679
        }
×
680

UNCOV
681
        return msg
×
682
}
683

684
// A compile time check to ensure ClosingSigned implements the
685
// lnwire.TestMessage interface.
686
var _ TestMessage = (*ClosingSigned)(nil)
687

688
// RandTestMessage populates the message with random data suitable for testing.
689
// It uses the rapid testing framework to generate random values.
690
//
691
// This is part of the TestMessage interface.
UNCOV
692
func (c *ClosingSigned) RandTestMessage(t *rapid.T) Message {
×
UNCOV
693
        // Generate a random boolean to decide whether to include CommitSig or
×
UNCOV
694
        // PartialSig Since they're mutually exclusive, when one is populated,
×
UNCOV
695
        // the other must be blank.
×
UNCOV
696
        usePartialSig := rapid.Bool().Draw(t, "usePartialSig")
×
UNCOV
697

×
UNCOV
698
        msg := &ClosingSigned{
×
UNCOV
699
                ChannelID: RandChannelID(t),
×
UNCOV
700
                FeeSatoshis: btcutil.Amount(
×
UNCOV
701
                        rapid.Int64Range(0, 1000000).Draw(t, "feeSatoshis"),
×
UNCOV
702
                ),
×
UNCOV
703
                ExtraData: RandExtraOpaqueData(t, nil),
×
UNCOV
704
        }
×
UNCOV
705

×
UNCOV
706
        if usePartialSig {
×
UNCOV
707
                sigBytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(
×
UNCOV
708
                        t, "sigScalar",
×
UNCOV
709
                )
×
UNCOV
710
                var s btcec.ModNScalar
×
UNCOV
711
                _ = s.SetByteSlice(sigBytes)
×
UNCOV
712

×
UNCOV
713
                msg.PartialSig = SomePartialSig(NewPartialSig(s))
×
UNCOV
714
                msg.Signature = Sig{}
×
UNCOV
715
        } else {
×
UNCOV
716
                msg.Signature = RandSignature(t)
×
UNCOV
717
        }
×
718

UNCOV
719
        return msg
×
720
}
721

722
// A compile time check to ensure CommitSig implements the lnwire.TestMessage
723
// interface.
724
var _ TestMessage = (*CommitSig)(nil)
725

726
// RandTestMessage populates the message with random data suitable for testing.
727
// It uses the rapid testing framework to generate random values.
728
//
729
// This is part of the TestMessage interface.
UNCOV
730
func (c *CommitSig) RandTestMessage(t *rapid.T) Message {
×
UNCOV
731
        cr, _ := RandCustomRecords(t, nil, true)
×
UNCOV
732
        sig := &CommitSig{
×
UNCOV
733
                ChanID:        RandChannelID(t),
×
UNCOV
734
                CommitSig:     RandSignature(t),
×
UNCOV
735
                CustomRecords: cr,
×
UNCOV
736
        }
×
UNCOV
737

×
UNCOV
738
        numHtlcSigs := rapid.IntRange(0, 20).Draw(t, "numHtlcSigs")
×
UNCOV
739
        htlcSigs := make([]Sig, numHtlcSigs)
×
UNCOV
740
        for i := 0; i < numHtlcSigs; i++ {
×
UNCOV
741
                htlcSigs[i] = RandSignature(t)
×
UNCOV
742
        }
×
743

UNCOV
744
        if len(htlcSigs) > 0 {
×
UNCOV
745
                sig.HtlcSigs = htlcSigs
×
UNCOV
746
        }
×
747

UNCOV
748
        includePartialSig := rapid.Bool().Draw(t, "includePartialSig")
×
UNCOV
749
        if includePartialSig {
×
UNCOV
750
                sigWithNonce := RandPartialSigWithNonce(t)
×
UNCOV
751
                sig.PartialSig = MaybePartialSigWithNonce(sigWithNonce)
×
UNCOV
752
        }
×
753

UNCOV
754
        return sig
×
755
}
756

757
// A compile time check to ensure Custom implements the lnwire.TestMessage
758
// interface.
759
var _ TestMessage = (*Custom)(nil)
760

761
// RandTestMessage populates the message with random data suitable for testing.
762
// It uses the rapid testing framework to generate random values.
763
//
764
// This is part of the TestMessage interface.
UNCOV
765
func (c *Custom) RandTestMessage(t *rapid.T) Message {
×
UNCOV
766
        msgType := MessageType(
×
UNCOV
767
                rapid.IntRange(int(CustomTypeStart), 65535).Draw(
×
UNCOV
768
                        t, "customMsgType",
×
UNCOV
769
                ),
×
UNCOV
770
        )
×
UNCOV
771

×
UNCOV
772
        dataLen := rapid.IntRange(0, 1000).Draw(t, "customDataLength")
×
UNCOV
773
        data := rapid.SliceOfN(rapid.Byte(), dataLen, dataLen).Draw(
×
UNCOV
774
                t, "customData",
×
UNCOV
775
        )
×
UNCOV
776

×
UNCOV
777
        msg, err := NewCustom(msgType, data)
×
UNCOV
778
        if err != nil {
×
779
                panic(fmt.Sprintf("Error creating custom message: %v", err))
×
780
        }
781

UNCOV
782
        return msg
×
783
}
784

785
// A compile time check to ensure DynAck implements the lnwire.TestMessage
786
// interface.
787
var _ TestMessage = (*DynAck)(nil)
788

789
// RandTestMessage populates the message with random data suitable for testing.
790
// It uses the rapid testing framework to generate random values.
791
//
792
// This is part of the TestMessage interface.
UNCOV
793
func (da *DynAck) RandTestMessage(t *rapid.T) Message {
×
UNCOV
794
        msg := &DynAck{
×
UNCOV
795
                ChanID:    RandChannelID(t),
×
UNCOV
796
                ExtraData: RandExtraOpaqueData(t, nil),
×
UNCOV
797
        }
×
UNCOV
798

×
UNCOV
799
        includeLocalNonce := rapid.Bool().Draw(t, "includeLocalNonce")
×
UNCOV
800

×
UNCOV
801
        if includeLocalNonce {
×
UNCOV
802
                msg.LocalNonce = fn.Some(RandMusig2Nonce(t))
×
UNCOV
803
        }
×
804

UNCOV
805
        return msg
×
806
}
807

808
// A compile time check to ensure DynPropose implements the lnwire.TestMessage
809
// interface.
810
var _ TestMessage = (*DynPropose)(nil)
811

812
// RandTestMessage populates the message with random data suitable for testing.
813
// It uses the rapid testing framework to generate random values.
814
//
815
// This is part of the TestMessage interface.
UNCOV
816
func (dp *DynPropose) RandTestMessage(t *rapid.T) Message {
×
UNCOV
817
        msg := &DynPropose{
×
UNCOV
818
                ChanID:    RandChannelID(t),
×
UNCOV
819
                ExtraData: RandExtraOpaqueData(t, nil),
×
UNCOV
820
        }
×
UNCOV
821

×
UNCOV
822
        // Randomly decide which optional fields to include
×
UNCOV
823
        includeDustLimit := rapid.Bool().Draw(t, "includeDustLimit")
×
UNCOV
824
        includeMaxValueInFlight := rapid.Bool().Draw(
×
UNCOV
825
                t, "includeMaxValueInFlight",
×
UNCOV
826
        )
×
UNCOV
827
        includeChannelReserve := rapid.Bool().Draw(t, "includeChannelReserve")
×
UNCOV
828
        includeCsvDelay := rapid.Bool().Draw(t, "includeCsvDelay")
×
UNCOV
829
        includeMaxAcceptedHTLCs := rapid.Bool().Draw(
×
UNCOV
830
                t, "includeMaxAcceptedHTLCs",
×
UNCOV
831
        )
×
UNCOV
832
        includeChannelType := rapid.Bool().Draw(t, "includeChannelType")
×
UNCOV
833

×
UNCOV
834
        // Generate random values for each included field
×
UNCOV
835
        if includeDustLimit {
×
UNCOV
836
                var rec tlv.RecordT[tlv.TlvType0, btcutil.Amount]
×
UNCOV
837
                val := btcutil.Amount(rapid.Uint32().Draw(t, "dustLimit"))
×
UNCOV
838
                rec.Val = val
×
UNCOV
839
                msg.DustLimit = tlv.SomeRecordT(rec)
×
UNCOV
840
        }
×
841

UNCOV
842
        if includeMaxValueInFlight {
×
UNCOV
843
                var rec tlv.RecordT[tlv.TlvType2, MilliSatoshi]
×
UNCOV
844
                val := MilliSatoshi(rapid.Uint64().Draw(t, "maxValueInFlight"))
×
UNCOV
845
                rec.Val = val
×
UNCOV
846
                msg.MaxValueInFlight = tlv.SomeRecordT(rec)
×
UNCOV
847
        }
×
848

UNCOV
849
        if includeChannelReserve {
×
UNCOV
850
                var rec tlv.RecordT[tlv.TlvType6, btcutil.Amount]
×
UNCOV
851
                val := btcutil.Amount(rapid.Uint32().Draw(t, "channelReserve"))
×
UNCOV
852
                rec.Val = val
×
UNCOV
853
                msg.ChannelReserve = tlv.SomeRecordT(rec)
×
UNCOV
854
        }
×
855

UNCOV
856
        if includeCsvDelay {
×
UNCOV
857
                csvDelay := msg.CsvDelay.Zero()
×
UNCOV
858
                val := rapid.Uint16().Draw(t, "csvDelay")
×
UNCOV
859
                csvDelay.Val = val
×
UNCOV
860
                msg.CsvDelay = tlv.SomeRecordT(csvDelay)
×
UNCOV
861
        }
×
862

UNCOV
863
        if includeMaxAcceptedHTLCs {
×
UNCOV
864
                maxHtlcs := msg.MaxAcceptedHTLCs.Zero()
×
UNCOV
865
                maxHtlcs.Val = rapid.Uint16().Draw(t, "maxAcceptedHTLCs")
×
UNCOV
866
                msg.MaxAcceptedHTLCs = tlv.SomeRecordT(maxHtlcs)
×
UNCOV
867
        }
×
868

UNCOV
869
        if includeChannelType {
×
UNCOV
870
                chanType := msg.ChannelType.Zero()
×
UNCOV
871
                chanType.Val = *RandChannelType(t)
×
UNCOV
872
                msg.ChannelType = tlv.SomeRecordT(chanType)
×
UNCOV
873
        }
×
874

UNCOV
875
        return msg
×
876
}
877

878
// A compile time check to ensure DynReject implements the lnwire.TestMessage
879
// interface.
880
var _ TestMessage = (*DynReject)(nil)
881

882
// RandTestMessage populates the message with random data suitable for testing.
883
// It uses the rapid testing framework to generate random values.
884
//
885
// This is part of the TestMessage interface.
UNCOV
886
func (dr *DynReject) RandTestMessage(t *rapid.T) Message {
×
UNCOV
887
        featureVec := NewRawFeatureVector()
×
UNCOV
888

×
UNCOV
889
        numFeatures := rapid.IntRange(0, 8).Draw(t, "numRejections")
×
UNCOV
890
        for i := 0; i < numFeatures; i++ {
×
UNCOV
891
                bit := FeatureBit(
×
UNCOV
892
                        rapid.IntRange(0, 31).Draw(
×
UNCOV
893
                                t, fmt.Sprintf("rejectionBit-%d", i),
×
UNCOV
894
                        ),
×
UNCOV
895
                )
×
UNCOV
896
                featureVec.Set(bit)
×
UNCOV
897
        }
×
898

UNCOV
899
        var extraData ExtraOpaqueData
×
UNCOV
900
        randData := RandExtraOpaqueData(t, nil)
×
UNCOV
901
        if len(randData) > 0 {
×
UNCOV
902
                extraData = randData
×
UNCOV
903
        }
×
904

UNCOV
905
        return &DynReject{
×
UNCOV
906
                ChanID:           RandChannelID(t),
×
UNCOV
907
                UpdateRejections: *featureVec,
×
UNCOV
908
                ExtraData:        extraData,
×
UNCOV
909
        }
×
910
}
911

912
// A compile time check to ensure DynCommit implements the lnwire.TestMessage
913
// interface.
914
var _ TestMessage = (*DynCommit)(nil)
915

916
// RandTestMessage populates the message with random data suitable for testing.
917
// It uses the rapid testing framework to generate random values.
918
//
919
// This is part of the TestMessage interface.
UNCOV
920
func (dc *DynCommit) RandTestMessage(t *rapid.T) Message {
×
UNCOV
921
        chanID := RandChannelID(t)
×
UNCOV
922

×
UNCOV
923
        da := &DynAck{
×
UNCOV
924
                ChanID: chanID,
×
UNCOV
925
        }
×
UNCOV
926

×
UNCOV
927
        dp := &DynPropose{
×
UNCOV
928
                ChanID: chanID,
×
UNCOV
929
        }
×
UNCOV
930

×
UNCOV
931
        // Randomly decide which optional fields to include
×
UNCOV
932
        includeDustLimit := rapid.Bool().Draw(t, "includeDustLimit")
×
UNCOV
933
        includeMaxValueInFlight := rapid.Bool().Draw(
×
UNCOV
934
                t, "includeMaxValueInFlight",
×
UNCOV
935
        )
×
UNCOV
936
        includeChannelReserve := rapid.Bool().Draw(t, "includeChannelReserve")
×
UNCOV
937
        includeCsvDelay := rapid.Bool().Draw(t, "includeCsvDelay")
×
UNCOV
938
        includeMaxAcceptedHTLCs := rapid.Bool().Draw(
×
UNCOV
939
                t, "includeMaxAcceptedHTLCs",
×
UNCOV
940
        )
×
UNCOV
941
        includeChannelType := rapid.Bool().Draw(t, "includeChannelType")
×
UNCOV
942

×
UNCOV
943
        // Generate random values for each included field
×
UNCOV
944
        if includeDustLimit {
×
UNCOV
945
                var rec tlv.RecordT[tlv.TlvType0, btcutil.Amount]
×
UNCOV
946
                val := btcutil.Amount(rapid.Uint32().Draw(t, "dustLimit"))
×
UNCOV
947
                rec.Val = val
×
UNCOV
948
                dp.DustLimit = tlv.SomeRecordT(rec)
×
UNCOV
949
        }
×
950

UNCOV
951
        if includeMaxValueInFlight {
×
UNCOV
952
                var rec tlv.RecordT[tlv.TlvType2, MilliSatoshi]
×
UNCOV
953
                val := MilliSatoshi(rapid.Uint64().Draw(t, "maxValueInFlight"))
×
UNCOV
954
                rec.Val = val
×
UNCOV
955
                dp.MaxValueInFlight = tlv.SomeRecordT(rec)
×
UNCOV
956
        }
×
957

UNCOV
958
        if includeChannelReserve {
×
UNCOV
959
                var rec tlv.RecordT[tlv.TlvType6, btcutil.Amount]
×
UNCOV
960
                val := btcutil.Amount(rapid.Uint32().Draw(t, "channelReserve"))
×
UNCOV
961
                rec.Val = val
×
UNCOV
962
                dp.ChannelReserve = tlv.SomeRecordT(rec)
×
UNCOV
963
        }
×
964

UNCOV
965
        if includeCsvDelay {
×
UNCOV
966
                csvDelay := dp.CsvDelay.Zero()
×
UNCOV
967
                val := rapid.Uint16().Draw(t, "csvDelay")
×
UNCOV
968
                csvDelay.Val = val
×
UNCOV
969
                dp.CsvDelay = tlv.SomeRecordT(csvDelay)
×
UNCOV
970
        }
×
971

UNCOV
972
        if includeMaxAcceptedHTLCs {
×
UNCOV
973
                maxHtlcs := dp.MaxAcceptedHTLCs.Zero()
×
UNCOV
974
                maxHtlcs.Val = rapid.Uint16().Draw(t, "maxAcceptedHTLCs")
×
UNCOV
975
                dp.MaxAcceptedHTLCs = tlv.SomeRecordT(maxHtlcs)
×
UNCOV
976
        }
×
977

UNCOV
978
        if includeChannelType {
×
UNCOV
979
                chanType := dp.ChannelType.Zero()
×
UNCOV
980
                chanType.Val = *RandChannelType(t)
×
UNCOV
981
                dp.ChannelType = tlv.SomeRecordT(chanType)
×
UNCOV
982
        }
×
983

UNCOV
984
        var extraData ExtraOpaqueData
×
UNCOV
985
        randData := RandExtraOpaqueData(t, nil)
×
UNCOV
986
        if len(randData) > 0 {
×
UNCOV
987
                extraData = randData
×
UNCOV
988
        }
×
989

UNCOV
990
        return &DynCommit{
×
UNCOV
991
                DynPropose: *dp,
×
UNCOV
992
                DynAck:     *da,
×
UNCOV
993
                ExtraData:  extraData,
×
UNCOV
994
        }
×
995
}
996

997
// A compile time check to ensure FundingCreated implements the TestMessage
998
// interface.
999
var _ TestMessage = (*FundingCreated)(nil)
1000

1001
// RandTestMessage populates the message with random data suitable for testing.
1002
// It uses the rapid testing framework to generate random values.
1003
//
1004
// This is part of the TestMessage interface.
UNCOV
1005
func (f *FundingCreated) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1006
        var pendingChanID [32]byte
×
UNCOV
1007
        pendingChanIDBytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(
×
UNCOV
1008
                t, "pendingChanID",
×
UNCOV
1009
        )
×
UNCOV
1010
        copy(pendingChanID[:], pendingChanIDBytes)
×
UNCOV
1011

×
UNCOV
1012
        includePartialSig := rapid.Bool().Draw(t, "includePartialSig")
×
UNCOV
1013
        var partialSig OptPartialSigWithNonceTLV
×
UNCOV
1014
        var commitSig Sig
×
UNCOV
1015

×
UNCOV
1016
        if includePartialSig {
×
UNCOV
1017
                sigWithNonce := RandPartialSigWithNonce(t)
×
UNCOV
1018
                partialSig = MaybePartialSigWithNonce(sigWithNonce)
×
UNCOV
1019

×
UNCOV
1020
                // When using partial sig, CommitSig should be empty/blank.
×
UNCOV
1021
                commitSig = Sig{}
×
UNCOV
1022
        } else {
×
UNCOV
1023
                commitSig = RandSignature(t)
×
UNCOV
1024
        }
×
1025

UNCOV
1026
        return &FundingCreated{
×
UNCOV
1027
                PendingChannelID: pendingChanID,
×
UNCOV
1028
                FundingPoint:     RandOutPoint(t),
×
UNCOV
1029
                CommitSig:        commitSig,
×
UNCOV
1030
                PartialSig:       partialSig,
×
UNCOV
1031
                ExtraData:        RandExtraOpaqueData(t, nil),
×
UNCOV
1032
        }
×
1033
}
1034

1035
// A compile time check to ensure FundingSigned implements the
1036
// lnwire.TestMessage interface.
1037
var _ TestMessage = (*FundingSigned)(nil)
1038

1039
// RandTestMessage populates the message with random data suitable for testing.
1040
// It uses the rapid testing framework to generate random values.
1041
//
1042
// This is part of the TestMessage interface.
UNCOV
1043
func (f *FundingSigned) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1044
        usePartialSig := rapid.Bool().Draw(t, "usePartialSig")
×
UNCOV
1045

×
UNCOV
1046
        msg := &FundingSigned{
×
UNCOV
1047
                ChanID:    RandChannelID(t),
×
UNCOV
1048
                ExtraData: RandExtraOpaqueData(t, nil),
×
UNCOV
1049
        }
×
UNCOV
1050

×
UNCOV
1051
        if usePartialSig {
×
UNCOV
1052
                sigWithNonce := RandPartialSigWithNonce(t)
×
UNCOV
1053
                msg.PartialSig = MaybePartialSigWithNonce(sigWithNonce)
×
UNCOV
1054

×
UNCOV
1055
                msg.CommitSig = Sig{}
×
UNCOV
1056
        } else {
×
UNCOV
1057
                msg.CommitSig = RandSignature(t)
×
UNCOV
1058
        }
×
1059

UNCOV
1060
        return msg
×
1061
}
1062

1063
// A compile time check to ensure GossipTimestampRange implements the
1064
// lnwire.TestMessage interface.
1065
var _ TestMessage = (*GossipTimestampRange)(nil)
1066

1067
// RandTestMessage populates the message with random data suitable for testing.
1068
// It uses the rapid testing framework to generate random values.
1069
//
1070
// This is part of the TestMessage interface.
UNCOV
1071
func (g *GossipTimestampRange) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1072
        var chainHash chainhash.Hash
×
UNCOV
1073
        hashBytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(t, "chainHash")
×
UNCOV
1074
        copy(chainHash[:], hashBytes)
×
UNCOV
1075

×
UNCOV
1076
        msg := &GossipTimestampRange{
×
UNCOV
1077
                ChainHash:      chainHash,
×
UNCOV
1078
                FirstTimestamp: rapid.Uint32().Draw(t, "firstTimestamp"),
×
UNCOV
1079
                TimestampRange: rapid.Uint32().Draw(t, "timestampRange"),
×
UNCOV
1080
                ExtraData:      RandExtraOpaqueData(t, nil),
×
UNCOV
1081
        }
×
UNCOV
1082

×
UNCOV
1083
        includeFirstBlockHeight := rapid.Bool().Draw(
×
UNCOV
1084
                t, "includeFirstBlockHeight",
×
UNCOV
1085
        )
×
UNCOV
1086
        includeBlockRange := rapid.Bool().Draw(t, "includeBlockRange")
×
UNCOV
1087

×
UNCOV
1088
        if includeFirstBlockHeight {
×
UNCOV
1089
                height := rapid.Uint32().Draw(t, "firstBlockHeight")
×
UNCOV
1090
                msg.FirstBlockHeight = tlv.SomeRecordT(
×
UNCOV
1091
                        tlv.RecordT[tlv.TlvType2, uint32]{Val: height},
×
UNCOV
1092
                )
×
UNCOV
1093
        }
×
1094

UNCOV
1095
        if includeBlockRange {
×
UNCOV
1096
                blockRange := rapid.Uint32().Draw(t, "blockRange")
×
UNCOV
1097
                msg.BlockRange = tlv.SomeRecordT(
×
UNCOV
1098
                        tlv.RecordT[tlv.TlvType4, uint32]{Val: blockRange},
×
UNCOV
1099
                )
×
UNCOV
1100
        }
×
1101

UNCOV
1102
        return msg
×
1103
}
1104

1105
// RandTestMessage populates the message with random data suitable for testing.
1106
// It uses the rapid testing framework to generate random values.
1107
//
1108
// This is part of the TestMessage interface.
UNCOV
1109
func (msg *Init) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1110
        global := NewRawFeatureVector()
×
UNCOV
1111
        local := NewRawFeatureVector()
×
UNCOV
1112

×
UNCOV
1113
        numGlobalFeatures := rapid.IntRange(0, 20).Draw(t, "numGlobalFeatures")
×
UNCOV
1114
        for i := 0; i < numGlobalFeatures; i++ {
×
UNCOV
1115
                bit := FeatureBit(
×
UNCOV
1116
                        rapid.IntRange(0, 100).Draw(
×
UNCOV
1117
                                t, fmt.Sprintf("globalFeatureBit%d", i),
×
UNCOV
1118
                        ),
×
UNCOV
1119
                )
×
UNCOV
1120
                global.Set(bit)
×
UNCOV
1121
        }
×
1122

UNCOV
1123
        numLocalFeatures := rapid.IntRange(0, 20).Draw(t, "numLocalFeatures")
×
UNCOV
1124
        for i := 0; i < numLocalFeatures; i++ {
×
UNCOV
1125
                bit := FeatureBit(
×
UNCOV
1126
                        rapid.IntRange(0, 100).Draw(
×
UNCOV
1127
                                t, fmt.Sprintf("localFeatureBit%d", i),
×
UNCOV
1128
                        ),
×
UNCOV
1129
                )
×
UNCOV
1130
                local.Set(bit)
×
UNCOV
1131
        }
×
1132

UNCOV
1133
        return NewInitMessage(global, local)
×
1134
}
1135

1136
// A compile time check to ensure KickoffSig implements the lnwire.TestMessage
1137
// interface.
1138
var _ TestMessage = (*KickoffSig)(nil)
1139

1140
// RandTestMessage populates the message with random data suitable for testing.
1141
// It uses the rapid testing framework to generate random values.
1142
//
1143
// This is part of the TestMessage interface.
UNCOV
1144
func (ks *KickoffSig) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1145
        return &KickoffSig{
×
UNCOV
1146
                ChanID:    RandChannelID(t),
×
UNCOV
1147
                Signature: RandSignature(t),
×
UNCOV
1148
                ExtraData: RandExtraOpaqueData(t, nil),
×
UNCOV
1149
        }
×
UNCOV
1150
}
×
1151

1152
// A compile time check to ensure NodeAnnouncement implements the
1153
// lnwire.TestMessage interface.
1154
var _ TestMessage = (*NodeAnnouncement)(nil)
1155

1156
// RandTestMessage populates the message with random data suitable for testing.
1157
// It uses the rapid testing framework to generate random values.
1158
//
1159
// This is part of the TestMessage interface.
UNCOV
1160
func (a *NodeAnnouncement) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1161
        // Generate random compressed public key for node ID
×
UNCOV
1162
        pubKey := RandPubKey(t)
×
UNCOV
1163
        var nodeID [33]byte
×
UNCOV
1164
        copy(nodeID[:], pubKey.SerializeCompressed())
×
UNCOV
1165

×
UNCOV
1166
        // Generate random RGB color
×
UNCOV
1167
        rgbColor := color.RGBA{
×
UNCOV
1168
                R: uint8(rapid.IntRange(0, 255).Draw(t, "rgbR")),
×
UNCOV
1169
                G: uint8(rapid.IntRange(0, 255).Draw(t, "rgbG")),
×
UNCOV
1170
                B: uint8(rapid.IntRange(0, 255).Draw(t, "rgbB")),
×
UNCOV
1171
        }
×
UNCOV
1172

×
UNCOV
1173
        return &NodeAnnouncement{
×
UNCOV
1174
                Signature: RandSignature(t),
×
UNCOV
1175
                Features:  RandFeatureVector(t),
×
UNCOV
1176
                Timestamp: uint32(rapid.IntRange(0, 0x7FFFFFFF).Draw(
×
UNCOV
1177
                        t, "timestamp"),
×
UNCOV
1178
                ),
×
UNCOV
1179
                NodeID:          nodeID,
×
UNCOV
1180
                RGBColor:        rgbColor,
×
UNCOV
1181
                Alias:           RandNodeAlias(t),
×
UNCOV
1182
                Addresses:       RandNetAddrs(t),
×
UNCOV
1183
                ExtraOpaqueData: RandExtraOpaqueData(t, nil),
×
UNCOV
1184
        }
×
UNCOV
1185
}
×
1186

1187
// A compile time check to ensure OpenChannel implements the TestMessage
1188
// interface.
1189
var _ TestMessage = (*OpenChannel)(nil)
1190

1191
// RandTestMessage populates the message with random data suitable for testing.
1192
// It uses the rapid testing framework to generate random values.
1193
//
1194
// This is part of the TestMessage interface.
UNCOV
1195
func (o *OpenChannel) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1196
        chainHash := RandChainHash(t)
×
UNCOV
1197
        var hash chainhash.Hash
×
UNCOV
1198
        copy(hash[:], chainHash[:])
×
UNCOV
1199

×
UNCOV
1200
        var pendingChanID [32]byte
×
UNCOV
1201
        pendingChanIDBytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(
×
UNCOV
1202
                t, "pendingChanID",
×
UNCOV
1203
        )
×
UNCOV
1204
        copy(pendingChanID[:], pendingChanIDBytes)
×
UNCOV
1205

×
UNCOV
1206
        includeChannelType := rapid.Bool().Draw(t, "includeChannelType")
×
UNCOV
1207
        includeLeaseExpiry := rapid.Bool().Draw(t, "includeLeaseExpiry")
×
UNCOV
1208
        includeLocalNonce := rapid.Bool().Draw(t, "includeLocalNonce")
×
UNCOV
1209

×
UNCOV
1210
        var channelFlags FundingFlag
×
UNCOV
1211
        if rapid.Bool().Draw(t, "announceChannel") {
×
UNCOV
1212
                channelFlags |= FFAnnounceChannel
×
UNCOV
1213
        }
×
1214

UNCOV
1215
        var localNonce OptMusig2NonceTLV
×
UNCOV
1216
        if includeLocalNonce {
×
UNCOV
1217
                nonce := RandMusig2Nonce(t)
×
UNCOV
1218
                localNonce = tlv.SomeRecordT(
×
UNCOV
1219
                        tlv.NewRecordT[NonceRecordTypeT, Musig2Nonce](nonce),
×
UNCOV
1220
                )
×
UNCOV
1221
        }
×
1222

UNCOV
1223
        var channelType *ChannelType
×
UNCOV
1224
        if includeChannelType {
×
UNCOV
1225
                channelType = RandChannelType(t)
×
UNCOV
1226
        }
×
1227

UNCOV
1228
        var leaseExpiry *LeaseExpiry
×
UNCOV
1229
        if includeLeaseExpiry {
×
UNCOV
1230
                leaseExpiry = RandLeaseExpiry(t)
×
UNCOV
1231
        }
×
1232

UNCOV
1233
        return &OpenChannel{
×
UNCOV
1234
                ChainHash:        hash,
×
UNCOV
1235
                PendingChannelID: pendingChanID,
×
UNCOV
1236
                FundingAmount: btcutil.Amount(
×
UNCOV
1237
                        rapid.IntRange(5000, 10000000).Draw(t, "fundingAmount"),
×
UNCOV
1238
                ),
×
UNCOV
1239
                PushAmount: MilliSatoshi(
×
UNCOV
1240
                        rapid.IntRange(0, 1000000).Draw(t, "pushAmount"),
×
UNCOV
1241
                ),
×
UNCOV
1242
                DustLimit: btcutil.Amount(
×
UNCOV
1243
                        rapid.IntRange(100, 1000).Draw(t, "dustLimit"),
×
UNCOV
1244
                ),
×
UNCOV
1245
                MaxValueInFlight: MilliSatoshi(
×
UNCOV
1246
                        rapid.IntRange(10000, 1000000).Draw(
×
UNCOV
1247
                                t, "maxValueInFlight",
×
UNCOV
1248
                        ),
×
UNCOV
1249
                ),
×
UNCOV
1250
                ChannelReserve: btcutil.Amount(
×
UNCOV
1251
                        rapid.IntRange(1000, 10000).Draw(t, "channelReserve"),
×
UNCOV
1252
                ),
×
UNCOV
1253
                HtlcMinimum: MilliSatoshi(
×
UNCOV
1254
                        rapid.IntRange(1, 1000).Draw(t, "htlcMinimum"),
×
UNCOV
1255
                ),
×
UNCOV
1256
                FeePerKiloWeight: uint32(
×
UNCOV
1257
                        rapid.IntRange(250, 10000).Draw(t, "feePerKw"),
×
UNCOV
1258
                ),
×
UNCOV
1259
                CsvDelay: uint16(
×
UNCOV
1260
                        rapid.IntRange(144, 1000).Draw(t, "csvDelay"),
×
UNCOV
1261
                ),
×
UNCOV
1262
                MaxAcceptedHTLCs: uint16(
×
UNCOV
1263
                        rapid.IntRange(10, 500).Draw(t, "maxAcceptedHTLCs"),
×
UNCOV
1264
                ),
×
UNCOV
1265
                FundingKey:            RandPubKey(t),
×
UNCOV
1266
                RevocationPoint:       RandPubKey(t),
×
UNCOV
1267
                PaymentPoint:          RandPubKey(t),
×
UNCOV
1268
                DelayedPaymentPoint:   RandPubKey(t),
×
UNCOV
1269
                HtlcPoint:             RandPubKey(t),
×
UNCOV
1270
                FirstCommitmentPoint:  RandPubKey(t),
×
UNCOV
1271
                ChannelFlags:          channelFlags,
×
UNCOV
1272
                UpfrontShutdownScript: RandDeliveryAddress(t),
×
UNCOV
1273
                ChannelType:           channelType,
×
UNCOV
1274
                LeaseExpiry:           leaseExpiry,
×
UNCOV
1275
                LocalNonce:            localNonce,
×
UNCOV
1276
                ExtraData:             RandExtraOpaqueData(t, nil),
×
UNCOV
1277
        }
×
1278
}
1279

1280
// A compile time check to ensure Ping implements the lnwire.TestMessage
1281
// interface.
1282
var _ TestMessage = (*Ping)(nil)
1283

1284
// RandTestMessage populates the message with random data suitable for testing.
1285
// It uses the rapid testing framework to generate random values.
1286
//
1287
// This is part of the TestMessage interface.
UNCOV
1288
func (p *Ping) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1289
        numPongBytes := uint16(rapid.IntRange(0, int(MaxPongBytes)).Draw(
×
UNCOV
1290
                t, "numPongBytes"),
×
UNCOV
1291
        )
×
UNCOV
1292

×
UNCOV
1293
        // Generate padding bytes (but keeping within allowed message size)
×
UNCOV
1294
        // MaxMsgBody - 2 (for NumPongBytes) - 2 (for padding length)
×
UNCOV
1295
        maxPaddingLen := MaxMsgBody - 4
×
UNCOV
1296
        paddingLen := rapid.IntRange(0, maxPaddingLen).Draw(
×
UNCOV
1297
                t, "paddingLen",
×
UNCOV
1298
        )
×
UNCOV
1299
        padding := make(PingPayload, paddingLen)
×
UNCOV
1300

×
UNCOV
1301
        // Fill padding with random bytes
×
UNCOV
1302
        for i := 0; i < paddingLen; i++ {
×
UNCOV
1303
                padding[i] = byte(rapid.IntRange(0, 255).Draw(
×
UNCOV
1304
                        t, fmt.Sprintf("paddingByte%d", i)),
×
UNCOV
1305
                )
×
UNCOV
1306
        }
×
1307

UNCOV
1308
        return &Ping{
×
UNCOV
1309
                NumPongBytes: numPongBytes,
×
UNCOV
1310
                PaddingBytes: padding,
×
UNCOV
1311
        }
×
1312
}
1313

1314
// A compile time check to ensure Pong implements the lnwire.TestMessage
1315
// interface.
1316
var _ TestMessage = (*Pong)(nil)
1317

1318
// RandTestMessage populates the message with random data suitable for testing.
1319
// It uses the rapid testing framework to generate random values.
1320
//
1321
// This is part of the TestMessage interface.
UNCOV
1322
func (p *Pong) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1323
        payloadLen := rapid.IntRange(0, 1000).Draw(t, "pongPayloadLength")
×
UNCOV
1324
        payload := rapid.SliceOfN(rapid.Byte(), payloadLen, payloadLen).Draw(
×
UNCOV
1325
                t, "pongPayload",
×
UNCOV
1326
        )
×
UNCOV
1327

×
UNCOV
1328
        return &Pong{
×
UNCOV
1329
                PongBytes: payload,
×
UNCOV
1330
        }
×
UNCOV
1331
}
×
1332

1333
// A compile time check to ensure QueryChannelRange implements the
1334
// lnwire.TestMessage interface.
1335
var _ TestMessage = (*QueryChannelRange)(nil)
1336

1337
// RandTestMessage populates the message with random data suitable for testing.
1338
// It uses the rapid testing framework to generate random values.
1339
//
1340
// This is part of the TestMessage interface.
UNCOV
1341
func (q *QueryChannelRange) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1342
        msg := &QueryChannelRange{
×
UNCOV
1343
                FirstBlockHeight: uint32(rapid.IntRange(0, 1000000).Draw(
×
UNCOV
1344
                        t, "firstBlockHeight"),
×
UNCOV
1345
                ),
×
UNCOV
1346
                NumBlocks: uint32(rapid.IntRange(1, 10000).Draw(
×
UNCOV
1347
                        t, "numBlocks"),
×
UNCOV
1348
                ),
×
UNCOV
1349
                ExtraData: RandExtraOpaqueData(t, nil),
×
UNCOV
1350
        }
×
UNCOV
1351

×
UNCOV
1352
        // Generate chain hash
×
UNCOV
1353
        chainHash := RandChainHash(t)
×
UNCOV
1354
        var chainHashObj chainhash.Hash
×
UNCOV
1355
        copy(chainHashObj[:], chainHash[:])
×
UNCOV
1356
        msg.ChainHash = chainHashObj
×
UNCOV
1357

×
UNCOV
1358
        // Randomly include QueryOptions
×
UNCOV
1359
        if rapid.Bool().Draw(t, "includeQueryOptions") {
×
UNCOV
1360
                queryOptions := &QueryOptions{}
×
UNCOV
1361
                *queryOptions = QueryOptions(*RandFeatureVector(t))
×
UNCOV
1362
                msg.QueryOptions = queryOptions
×
UNCOV
1363
        }
×
1364

UNCOV
1365
        return msg
×
1366
}
1367

1368
// A compile time check to ensure QueryShortChanIDs implements the
1369
// lnwire.TestMessage interface.
1370
var _ TestMessage = (*QueryShortChanIDs)(nil)
1371

1372
// RandTestMessage populates the message with random data suitable for testing.
1373
// It uses the rapid testing framework to generate random values.
1374
//
1375
// This is part of the TestMessage interface.
UNCOV
1376
func (q *QueryShortChanIDs) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1377
        var chainHash chainhash.Hash
×
UNCOV
1378
        hashBytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(t, "chainHash")
×
UNCOV
1379
        copy(chainHash[:], hashBytes)
×
UNCOV
1380

×
UNCOV
1381
        encodingType := EncodingSortedPlain
×
UNCOV
1382
        if rapid.Bool().Draw(t, "useZlibEncoding") {
×
UNCOV
1383
                encodingType = EncodingSortedZlib
×
UNCOV
1384
        }
×
1385

UNCOV
1386
        msg := &QueryShortChanIDs{
×
UNCOV
1387
                ChainHash:    chainHash,
×
UNCOV
1388
                EncodingType: encodingType,
×
UNCOV
1389
                ExtraData:    RandExtraOpaqueData(t, nil),
×
UNCOV
1390
                noSort:       false,
×
UNCOV
1391
        }
×
UNCOV
1392

×
UNCOV
1393
        numIDs := rapid.IntRange(2, 20).Draw(t, "numShortChanIDs")
×
UNCOV
1394

×
UNCOV
1395
        // Generate sorted short channel IDs.
×
UNCOV
1396
        shortChanIDs := make([]ShortChannelID, numIDs)
×
UNCOV
1397
        for i := 0; i < numIDs; i++ {
×
UNCOV
1398
                shortChanIDs[i] = RandShortChannelID(t)
×
UNCOV
1399

×
UNCOV
1400
                // Ensure they're properly sorted.
×
UNCOV
1401
                if i > 0 && shortChanIDs[i].ToUint64() <=
×
UNCOV
1402
                        shortChanIDs[i-1].ToUint64() {
×
UNCOV
1403

×
UNCOV
1404
                        // Ensure this ID is larger than the previous one.
×
UNCOV
1405
                        shortChanIDs[i] = NewShortChanIDFromInt(
×
UNCOV
1406
                                shortChanIDs[i-1].ToUint64() + 1,
×
UNCOV
1407
                        )
×
UNCOV
1408
                }
×
1409
        }
1410

UNCOV
1411
        msg.ShortChanIDs = shortChanIDs
×
UNCOV
1412

×
UNCOV
1413
        return msg
×
1414
}
1415

1416
// A compile time check to ensure ReplyChannelRange implements the
1417
// lnwire.TestMessage interface.
1418
var _ TestMessage = (*ReplyChannelRange)(nil)
1419

1420
// RandTestMessage populates the message with random data suitable for testing.
1421
// It uses the rapid testing framework to generate random values.
1422
//
1423
// This is part of the TestMessage interface.
UNCOV
1424
func (c *ReplyChannelRange) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1425
        msg := &ReplyChannelRange{
×
UNCOV
1426
                FirstBlockHeight: uint32(rapid.IntRange(0, 1000000).Draw(
×
UNCOV
1427
                        t, "firstBlockHeight"),
×
UNCOV
1428
                ),
×
UNCOV
1429
                NumBlocks: uint32(rapid.IntRange(1, 10000).Draw(
×
UNCOV
1430
                        t, "numBlocks"),
×
UNCOV
1431
                ),
×
UNCOV
1432
                Complete: uint8(rapid.IntRange(0, 1).Draw(t, "complete")),
×
UNCOV
1433
                EncodingType: QueryEncoding(
×
UNCOV
1434
                        rapid.IntRange(0, 1).Draw(t, "encodingType"),
×
UNCOV
1435
                ),
×
UNCOV
1436
                ExtraData: RandExtraOpaqueData(t, nil),
×
UNCOV
1437
        }
×
UNCOV
1438

×
UNCOV
1439
        msg.ChainHash = RandChainHash(t)
×
UNCOV
1440

×
UNCOV
1441
        numShortChanIDs := rapid.IntRange(0, 20).Draw(t, "numShortChanIDs")
×
UNCOV
1442
        if numShortChanIDs == 0 {
×
UNCOV
1443
                return msg
×
UNCOV
1444
        }
×
1445

UNCOV
1446
        scidSet := fn.NewSet[ShortChannelID]()
×
UNCOV
1447
        scids := make([]ShortChannelID, numShortChanIDs)
×
UNCOV
1448
        for i := 0; i < numShortChanIDs; i++ {
×
UNCOV
1449
                scid := RandShortChannelID(t)
×
UNCOV
1450
                for scidSet.Contains(scid) {
×
UNCOV
1451
                        scid = RandShortChannelID(t)
×
UNCOV
1452
                }
×
1453

UNCOV
1454
                scids[i] = scid
×
UNCOV
1455

×
UNCOV
1456
                scidSet.Add(scid)
×
1457
        }
1458

1459
        // Make sure there're no duplicates.
UNCOV
1460
        msg.ShortChanIDs = scids
×
UNCOV
1461

×
UNCOV
1462
        if rapid.Bool().Draw(t, "includeTimestamps") && numShortChanIDs > 0 {
×
UNCOV
1463
                msg.Timestamps = make(Timestamps, numShortChanIDs)
×
UNCOV
1464
                for i := 0; i < numShortChanIDs; i++ {
×
UNCOV
1465
                        msg.Timestamps[i] = ChanUpdateTimestamps{
×
UNCOV
1466
                                Timestamp1: uint32(rapid.IntRange(0, math.MaxInt32).Draw(t, fmt.Sprintf("timestamp-1-%d", i))), //nolint:ll
×
UNCOV
1467
                                Timestamp2: uint32(rapid.IntRange(0, math.MaxInt32).Draw(t, fmt.Sprintf("timestamp-2-%d", i))), //nolint:ll
×
UNCOV
1468
                        }
×
UNCOV
1469
                }
×
1470
        }
1471

UNCOV
1472
        return msg
×
1473
}
1474

1475
// A compile time check to ensure ReplyShortChanIDsEnd implements the
1476
// lnwire.TestMessage interface.
1477
var _ TestMessage = (*ReplyShortChanIDsEnd)(nil)
1478

1479
// RandTestMessage populates the message with random data suitable for testing.
1480
// It uses the rapid testing framework to generate random values.
1481
//
1482
// This is part of the TestMessage interface.
UNCOV
1483
func (c *ReplyShortChanIDsEnd) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1484
        var chainHash chainhash.Hash
×
UNCOV
1485
        hashBytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(t, "chainHash")
×
UNCOV
1486
        copy(chainHash[:], hashBytes)
×
UNCOV
1487

×
UNCOV
1488
        complete := uint8(rapid.IntRange(0, 1).Draw(t, "complete"))
×
UNCOV
1489

×
UNCOV
1490
        return &ReplyShortChanIDsEnd{
×
UNCOV
1491
                ChainHash: chainHash,
×
UNCOV
1492
                Complete:  complete,
×
UNCOV
1493
                ExtraData: RandExtraOpaqueData(t, nil),
×
UNCOV
1494
        }
×
UNCOV
1495
}
×
1496

1497
// RandTestMessage returns a RevokeAndAck message populated with random data.
1498
//
1499
// This is part of the TestMessage interface.
UNCOV
1500
func (c *RevokeAndAck) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1501
        msg := NewRevokeAndAck()
×
UNCOV
1502

×
UNCOV
1503
        var chanID ChannelID
×
UNCOV
1504
        bytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(t, "channelID")
×
UNCOV
1505
        copy(chanID[:], bytes)
×
UNCOV
1506
        msg.ChanID = chanID
×
UNCOV
1507

×
UNCOV
1508
        revBytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(t, "revocation")
×
UNCOV
1509
        copy(msg.Revocation[:], revBytes)
×
UNCOV
1510

×
UNCOV
1511
        msg.NextRevocationKey = RandPubKey(t)
×
UNCOV
1512

×
UNCOV
1513
        if rapid.Bool().Draw(t, "includeLocalNonce") {
×
UNCOV
1514
                var nonce Musig2Nonce
×
UNCOV
1515
                nonceBytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(
×
UNCOV
1516
                        t, "nonce",
×
UNCOV
1517
                )
×
UNCOV
1518
                copy(nonce[:], nonceBytes)
×
UNCOV
1519

×
UNCOV
1520
                msg.LocalNonce = tlv.SomeRecordT(
×
UNCOV
1521
                        tlv.NewRecordT[NonceRecordTypeT, Musig2Nonce](nonce),
×
UNCOV
1522
                )
×
UNCOV
1523
        }
×
1524

UNCOV
1525
        return msg
×
1526
}
1527

1528
// A compile-time check to ensure Shutdown implements the lnwire.TestMessage
1529
// interface.
1530
var _ TestMessage = (*Shutdown)(nil)
1531

1532
// RandTestMessage populates the message with random data suitable for testing.
1533
// It uses the rapid testing framework to generate random values.
1534
//
1535
// This is part of the TestMessage interface.
UNCOV
1536
func (s *Shutdown) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1537
        // Generate random delivery address
×
UNCOV
1538
        // First decide the address type (P2PKH, P2SH, P2WPKH, P2WSH, P2TR)
×
UNCOV
1539
        addrType := rapid.IntRange(0, 4).Draw(t, "addrType")
×
UNCOV
1540

×
UNCOV
1541
        // Generate random address length based on type
×
UNCOV
1542
        var addrLen int
×
UNCOV
1543
        switch addrType {
×
1544
        // P2PKH
UNCOV
1545
        case 0:
×
UNCOV
1546
                addrLen = 25
×
1547
        // P2SH
UNCOV
1548
        case 1:
×
UNCOV
1549
                addrLen = 23
×
1550
        // P2WPKH
UNCOV
1551
        case 2:
×
UNCOV
1552
                addrLen = 22
×
1553
        // P2WSH
UNCOV
1554
        case 3:
×
UNCOV
1555
                addrLen = 34
×
1556
        // P2TR
UNCOV
1557
        case 4:
×
UNCOV
1558
                addrLen = 34
×
1559
        }
1560

UNCOV
1561
        addr := rapid.SliceOfN(rapid.Byte(), addrLen, addrLen).Draw(
×
UNCOV
1562
                t, "address",
×
UNCOV
1563
        )
×
UNCOV
1564

×
UNCOV
1565
        // Randomly decide whether to include a shutdown nonce
×
UNCOV
1566
        includeNonce := rapid.Bool().Draw(t, "includeNonce")
×
UNCOV
1567
        var shutdownNonce ShutdownNonceTLV
×
UNCOV
1568

×
UNCOV
1569
        if includeNonce {
×
UNCOV
1570
                shutdownNonce = SomeShutdownNonce(RandMusig2Nonce(t))
×
UNCOV
1571
        }
×
1572

UNCOV
1573
        cr, _ := RandCustomRecords(t, nil, true)
×
UNCOV
1574

×
UNCOV
1575
        return &Shutdown{
×
UNCOV
1576
                ChannelID:     RandChannelID(t),
×
UNCOV
1577
                Address:       addr,
×
UNCOV
1578
                ShutdownNonce: shutdownNonce,
×
UNCOV
1579
                CustomRecords: cr,
×
UNCOV
1580
        }
×
1581
}
1582

1583
// A compile time check to ensure Stfu implements the lnwire.TestMessage
1584
// interface.
1585
var _ TestMessage = (*Stfu)(nil)
1586

1587
// RandTestMessage populates the message with random data suitable for testing.
1588
// It uses the rapid testing framework to generate random values.
1589
//
1590
// This is part of the TestMessage interface.
UNCOV
1591
func (s *Stfu) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1592
        m := &Stfu{
×
UNCOV
1593
                ChanID:    RandChannelID(t),
×
UNCOV
1594
                Initiator: rapid.Bool().Draw(t, "initiator"),
×
UNCOV
1595
        }
×
UNCOV
1596

×
UNCOV
1597
        extraData := RandExtraOpaqueData(t, nil)
×
UNCOV
1598
        if len(extraData) > 0 {
×
UNCOV
1599
                m.ExtraData = extraData
×
UNCOV
1600
        }
×
1601

UNCOV
1602
        return m
×
1603
}
1604

1605
// A compile time check to ensure UpdateAddHTLC implements the
1606
// lnwire.TestMessage interface.
1607
var _ TestMessage = (*UpdateAddHTLC)(nil)
1608

1609
// RandTestMessage returns an UpdateAddHTLC message populated with random data.
1610
//
1611
// This is part of the TestMessage interface.
UNCOV
1612
func (c *UpdateAddHTLC) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1613
        msg := &UpdateAddHTLC{
×
UNCOV
1614
                ChanID: RandChannelID(t),
×
UNCOV
1615
                ID:     rapid.Uint64().Draw(t, "id"),
×
UNCOV
1616
                Amount: MilliSatoshi(rapid.Uint64().Draw(t, "amount")),
×
UNCOV
1617
                Expiry: rapid.Uint32().Draw(t, "expiry"),
×
UNCOV
1618
        }
×
UNCOV
1619

×
UNCOV
1620
        hashBytes := rapid.SliceOfN(rapid.Byte(), 32, 32).Draw(t, "paymentHash")
×
UNCOV
1621
        copy(msg.PaymentHash[:], hashBytes)
×
UNCOV
1622

×
UNCOV
1623
        onionBytes := rapid.SliceOfN(
×
UNCOV
1624
                rapid.Byte(), OnionPacketSize, OnionPacketSize,
×
UNCOV
1625
        ).Draw(t, "onionBlob")
×
UNCOV
1626
        copy(msg.OnionBlob[:], onionBytes)
×
UNCOV
1627

×
UNCOV
1628
        numRecords := rapid.IntRange(0, 5).Draw(t, "numRecords")
×
UNCOV
1629
        if numRecords > 0 {
×
UNCOV
1630
                msg.CustomRecords, _ = RandCustomRecords(t, nil, true)
×
UNCOV
1631
        }
×
1632

1633
        // 50/50 chance to add a blinding point
UNCOV
1634
        if rapid.Bool().Draw(t, "includeBlindingPoint") {
×
UNCOV
1635
                pubKey := RandPubKey(t)
×
UNCOV
1636

×
UNCOV
1637
                msg.BlindingPoint = tlv.SomeRecordT(
×
UNCOV
1638
                        tlv.NewPrimitiveRecord[BlindingPointTlvType](pubKey),
×
UNCOV
1639
                )
×
UNCOV
1640
        }
×
1641

UNCOV
1642
        return msg
×
1643
}
1644

1645
// A compile time check to ensure UpdateFailHTLC implements the TestMessage
1646
// interface.
1647
var _ TestMessage = (*UpdateFailHTLC)(nil)
1648

1649
// RandTestMessage populates the message with random data suitable for testing.
1650
// It uses the rapid testing framework to generate random values.
1651
//
1652
// This is part of the TestMessage interface.
UNCOV
1653
func (c *UpdateFailHTLC) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1654
        return &UpdateFailHTLC{
×
UNCOV
1655
                ChanID:    RandChannelID(t),
×
UNCOV
1656
                ID:        rapid.Uint64().Draw(t, "id"),
×
UNCOV
1657
                Reason:    RandOpaqueReason(t),
×
UNCOV
1658
                ExtraData: RandExtraOpaqueData(t, nil),
×
UNCOV
1659
        }
×
UNCOV
1660
}
×
1661

1662
// A compile time check to ensure UpdateFailMalformedHTLC implements the
1663
// TestMessage interface.
1664
var _ TestMessage = (*UpdateFailMalformedHTLC)(nil)
1665

1666
// RandTestMessage populates the message with random data suitable for testing.
1667
// It uses the rapid testing framework to generate random values.
1668
//
1669
// This is part of the TestMessage interface.
UNCOV
1670
func (c *UpdateFailMalformedHTLC) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1671
        return &UpdateFailMalformedHTLC{
×
UNCOV
1672
                ChanID:       RandChannelID(t),
×
UNCOV
1673
                ID:           rapid.Uint64().Draw(t, "id"),
×
UNCOV
1674
                ShaOnionBlob: RandSHA256Hash(t),
×
UNCOV
1675
                FailureCode:  RandFailCode(t),
×
UNCOV
1676
                ExtraData:    RandExtraOpaqueData(t, nil),
×
UNCOV
1677
        }
×
UNCOV
1678
}
×
1679

1680
// A compile time check to ensure UpdateFee implements the TestMessage
1681
// interface.
1682
var _ TestMessage = (*UpdateFee)(nil)
1683

1684
// RandTestMessage populates the message with random data suitable for testing.
1685
// It uses the rapid testing framework to generate random values.
1686
//
1687
// This is part of the TestMessage interface.
UNCOV
1688
func (c *UpdateFee) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1689
        return &UpdateFee{
×
UNCOV
1690
                ChanID:    RandChannelID(t),
×
UNCOV
1691
                FeePerKw:  uint32(rapid.IntRange(1, 10000).Draw(t, "feePerKw")),
×
UNCOV
1692
                ExtraData: RandExtraOpaqueData(t, nil),
×
UNCOV
1693
        }
×
UNCOV
1694
}
×
1695

1696
// A compile time check to ensure UpdateFulfillHTLC implements the TestMessage
1697
// interface.
1698
var _ TestMessage = (*UpdateFulfillHTLC)(nil)
1699

1700
// RandTestMessage populates the message with random data suitable for testing.
1701
// It uses the rapid testing framework to generate random values.
1702
//
1703
// This is part of the TestMessage interface.
UNCOV
1704
func (c *UpdateFulfillHTLC) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1705
        msg := &UpdateFulfillHTLC{
×
UNCOV
1706
                ChanID:          RandChannelID(t),
×
UNCOV
1707
                ID:              rapid.Uint64().Draw(t, "id"),
×
UNCOV
1708
                PaymentPreimage: RandPaymentPreimage(t),
×
UNCOV
1709
        }
×
UNCOV
1710

×
UNCOV
1711
        cr, ignoreRecords := RandCustomRecords(t, nil, true)
×
UNCOV
1712
        msg.CustomRecords = cr
×
UNCOV
1713

×
UNCOV
1714
        randData := RandExtraOpaqueData(t, ignoreRecords)
×
UNCOV
1715
        if len(randData) > 0 {
×
UNCOV
1716
                msg.ExtraData = randData
×
UNCOV
1717
        }
×
1718

UNCOV
1719
        return msg
×
1720
}
1721

1722
// A compile time check to ensure Warning implements the lnwire.TestMessage
1723
// interface.
1724
var _ TestMessage = (*Warning)(nil)
1725

1726
// RandTestMessage populates the message with random data suitable for testing.
1727
// It uses the rapid testing framework to generate random values.
1728
//
1729
// This is part of the TestMessage interface.
UNCOV
1730
func (c *Warning) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1731
        msg := &Warning{
×
UNCOV
1732
                ChanID: RandChannelID(t),
×
UNCOV
1733
        }
×
UNCOV
1734

×
UNCOV
1735
        useASCII := rapid.Bool().Draw(t, "useASCII")
×
UNCOV
1736
        if useASCII {
×
UNCOV
1737
                length := rapid.IntRange(1, 100).Draw(t, "warningDataLength")
×
UNCOV
1738
                data := make([]byte, length)
×
UNCOV
1739
                for i := 0; i < length; i++ {
×
UNCOV
1740
                        data[i] = byte(
×
UNCOV
1741
                                rapid.IntRange(32, 126).Draw(
×
UNCOV
1742
                                        t, fmt.Sprintf("warningDataByte-%d", i),
×
UNCOV
1743
                                ),
×
UNCOV
1744
                        )
×
UNCOV
1745
                }
×
UNCOV
1746
                msg.Data = data
×
UNCOV
1747
        } else {
×
UNCOV
1748
                length := rapid.IntRange(1, 100).Draw(t, "warningDataLength")
×
UNCOV
1749
                msg.Data = rapid.SliceOfN(rapid.Byte(), length, length).Draw(
×
UNCOV
1750
                        t, "warningData",
×
UNCOV
1751
                )
×
UNCOV
1752
        }
×
1753

UNCOV
1754
        return msg
×
1755
}
1756

1757
// A compile time check to ensure Error implements the lnwire.TestMessage
1758
// interface.
1759
var _ TestMessage = (*Error)(nil)
1760

1761
// RandTestMessage populates the message with random data suitable for testing.
1762
// It uses the rapid testing framework to generate random values.
1763
//
1764
// This is part of the TestMessage interface.
UNCOV
1765
func (c *Error) RandTestMessage(t *rapid.T) Message {
×
UNCOV
1766
        msg := &Error{
×
UNCOV
1767
                ChanID: RandChannelID(t),
×
UNCOV
1768
        }
×
UNCOV
1769

×
UNCOV
1770
        useASCII := rapid.Bool().Draw(t, "useASCII")
×
UNCOV
1771
        if useASCII {
×
UNCOV
1772
                length := rapid.IntRange(1, 100).Draw(t, "errorDataLength")
×
UNCOV
1773
                data := make([]byte, length)
×
UNCOV
1774
                for i := 0; i < length; i++ {
×
UNCOV
1775
                        data[i] = byte(
×
UNCOV
1776
                                rapid.IntRange(32, 126).Draw(
×
UNCOV
1777
                                        t, fmt.Sprintf("errorDataByte-%d", i),
×
UNCOV
1778
                                ),
×
UNCOV
1779
                        )
×
UNCOV
1780
                }
×
UNCOV
1781
                msg.Data = data
×
UNCOV
1782
        } else {
×
UNCOV
1783
                // Generate random binary data
×
UNCOV
1784
                length := rapid.IntRange(1, 100).Draw(t, "errorDataLength")
×
UNCOV
1785
                msg.Data = rapid.SliceOfN(
×
UNCOV
1786
                        rapid.Byte(), length, length,
×
UNCOV
1787
                ).Draw(t, "errorData")
×
UNCOV
1788
        }
×
1789

UNCOV
1790
        return msg
×
1791
}
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