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

lightningnetwork / lnd / 15736109134

18 Jun 2025 02:46PM UTC coverage: 58.197% (-10.1%) from 68.248%
15736109134

Pull #9752

github

web-flow
Merge d2634a68c into 31c74f20f
Pull Request #9752: routerrpc: reject payment to invoice that don't have payment secret or blinded paths

6 of 13 new or added lines in 2 files covered. (46.15%)

28331 existing lines in 455 files now uncovered.

97860 of 168153 relevant lines covered (58.2%)

1.81 hits per line

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

62.24
/graph/db/graph.go
1
package graphdb
2

3
import (
4
        "context"
5
        "errors"
6
        "fmt"
7
        "sync"
8
        "sync/atomic"
9
        "testing"
10
        "time"
11

12
        "github.com/btcsuite/btcd/chaincfg/chainhash"
13
        "github.com/btcsuite/btcd/wire"
14
        "github.com/lightningnetwork/lnd/batch"
15
        "github.com/lightningnetwork/lnd/graph/db/models"
16
        "github.com/lightningnetwork/lnd/lnwire"
17
        "github.com/lightningnetwork/lnd/routing/route"
18
        "github.com/stretchr/testify/require"
19
)
20

21
// ErrChanGraphShuttingDown indicates that the ChannelGraph has shutdown or is
22
// busy shutting down.
23
var ErrChanGraphShuttingDown = fmt.Errorf("ChannelGraph shutting down")
24

25
// ChannelGraph is a layer above the graph's CRUD layer.
26
//
27
// NOTE: currently, this is purely a pass-through layer directly to the backing
28
// KVStore. Upcoming commits will move the graph cache out of the KVStore and
29
// into this layer so that the KVStore is only responsible for CRUD operations.
30
type ChannelGraph struct {
31
        started atomic.Bool
32
        stopped atomic.Bool
33

34
        graphCache *GraphCache
35

36
        V1Store
37
        *topologyManager
38

39
        quit chan struct{}
40
        wg   sync.WaitGroup
41
}
42

43
// NewChannelGraph creates a new ChannelGraph instance with the given backend.
44
func NewChannelGraph(v1Store V1Store,
45
        options ...ChanGraphOption) (*ChannelGraph, error) {
3✔
46

3✔
47
        opts := defaultChanGraphOptions()
3✔
48
        for _, o := range options {
6✔
49
                o(opts)
3✔
50
        }
3✔
51

52
        g := &ChannelGraph{
3✔
53
                V1Store:         v1Store,
3✔
54
                topologyManager: newTopologyManager(),
3✔
55
                quit:            make(chan struct{}),
3✔
56
        }
3✔
57

3✔
58
        // The graph cache can be turned off (e.g. for mobile users) for a
3✔
59
        // speed/memory usage tradeoff.
3✔
60
        if opts.useGraphCache {
6✔
61
                g.graphCache = NewGraphCache(opts.preAllocCacheNumNodes)
3✔
62
        }
3✔
63

64
        return g, nil
3✔
65
}
66

67
// Start kicks off any goroutines required for the ChannelGraph to function.
68
// If the graph cache is enabled, then it will be populated with the contents of
69
// the database.
70
func (c *ChannelGraph) Start() error {
3✔
71
        if !c.started.CompareAndSwap(false, true) {
3✔
UNCOV
72
                return nil
×
UNCOV
73
        }
×
74
        log.Debugf("ChannelGraph starting")
3✔
75
        defer log.Debug("ChannelGraph started")
3✔
76

3✔
77
        if c.graphCache != nil {
6✔
78
                if err := c.populateCache(); err != nil {
3✔
79
                        return fmt.Errorf("could not populate the graph "+
×
80
                                "cache: %w", err)
×
81
                }
×
82
        }
83

84
        c.wg.Add(1)
3✔
85
        go c.handleTopologySubscriptions()
3✔
86

3✔
87
        return nil
3✔
88
}
89

90
// Stop signals any active goroutines for a graceful closure.
91
func (c *ChannelGraph) Stop() error {
3✔
92
        if !c.stopped.CompareAndSwap(false, true) {
3✔
UNCOV
93
                return nil
×
UNCOV
94
        }
×
95

96
        log.Debugf("ChannelGraph shutting down...")
3✔
97
        defer log.Debug("ChannelGraph shutdown complete")
3✔
98

3✔
99
        close(c.quit)
3✔
100
        c.wg.Wait()
3✔
101

3✔
102
        return nil
3✔
103
}
104

105
// handleTopologySubscriptions ensures that topology client subscriptions,
106
// subscription cancellations and topology notifications are handled
107
// synchronously.
108
//
109
// NOTE: this MUST be run in a goroutine.
110
func (c *ChannelGraph) handleTopologySubscriptions() {
3✔
111
        defer c.wg.Done()
3✔
112

3✔
113
        for {
6✔
114
                select {
3✔
115
                // A new fully validated topology update has just arrived.
116
                // We'll notify any registered clients.
117
                case update := <-c.topologyUpdate:
3✔
118
                        // TODO(elle): change topology handling to be handled
3✔
119
                        // synchronously so that we can guarantee the order of
3✔
120
                        // notification delivery.
3✔
121
                        c.wg.Add(1)
3✔
122
                        go c.handleTopologyUpdate(update)
3✔
123

124
                        // TODO(roasbeef): remove all unconnected vertexes
125
                        // after N blocks pass with no corresponding
126
                        // announcements.
127

128
                // A new notification client update has arrived. We're either
129
                // gaining a new client, or cancelling notifications for an
130
                // existing client.
131
                case ntfnUpdate := <-c.ntfnClientUpdates:
3✔
132
                        clientID := ntfnUpdate.clientID
3✔
133

3✔
134
                        if ntfnUpdate.cancel {
6✔
135
                                client, ok := c.topologyClients.LoadAndDelete(
3✔
136
                                        clientID,
3✔
137
                                )
3✔
138
                                if ok {
6✔
139
                                        close(client.exit)
3✔
140
                                        client.wg.Wait()
3✔
141

3✔
142
                                        close(client.ntfnChan)
3✔
143
                                }
3✔
144

145
                                continue
3✔
146
                        }
147

148
                        c.topologyClients.Store(clientID, &topologyClient{
3✔
149
                                ntfnChan: ntfnUpdate.ntfnChan,
3✔
150
                                exit:     make(chan struct{}),
3✔
151
                        })
3✔
152

153
                case <-c.quit:
3✔
154
                        return
3✔
155
                }
156
        }
157
}
158

159
// populateCache loads the entire channel graph into the in-memory graph cache.
160
//
161
// NOTE: This should only be called if the graphCache has been constructed.
162
func (c *ChannelGraph) populateCache() error {
3✔
163
        startTime := time.Now()
3✔
164
        log.Info("Populating in-memory channel graph, this might take a " +
3✔
165
                "while...")
3✔
166

3✔
167
        err := c.V1Store.ForEachNodeCacheable(func(node route.Vertex,
3✔
168
                features *lnwire.FeatureVector) error {
6✔
169

3✔
170
                c.graphCache.AddNodeFeatures(node, features)
3✔
171

3✔
172
                return nil
3✔
173
        })
3✔
174
        if err != nil {
3✔
175
                return err
×
176
        }
×
177

178
        err = c.V1Store.ForEachChannelCacheable(
3✔
179
                func(info *models.CachedEdgeInfo,
3✔
180
                        policy1, policy2 *models.CachedEdgePolicy) error {
6✔
181

3✔
182
                        c.graphCache.AddChannel(info, policy1, policy2)
3✔
183

3✔
184
                        return nil
3✔
185
                })
3✔
186
        if err != nil {
3✔
187
                return err
×
188
        }
×
189

190
        log.Infof("Finished populating in-memory channel graph (took %v, %s)",
3✔
191
                time.Since(startTime), c.graphCache.Stats())
3✔
192

3✔
193
        return nil
3✔
194
}
195

196
// ForEachNodeDirectedChannel iterates through all channels of a given node,
197
// executing the passed callback on the directed edge representing the channel
198
// and its incoming policy. If the callback returns an error, then the iteration
199
// is halted with the error propagated back up to the caller. If the graphCache
200
// is available, then it will be used to retrieve the node's channels instead
201
// of the database.
202
//
203
// Unknown policies are passed into the callback as nil values.
204
//
205
// NOTE: this is part of the graphdb.NodeTraverser interface.
206
func (c *ChannelGraph) ForEachNodeDirectedChannel(node route.Vertex,
207
        cb func(channel *DirectedChannel) error) error {
3✔
208

3✔
209
        if c.graphCache != nil {
6✔
210
                return c.graphCache.ForEachChannel(node, cb)
3✔
211
        }
3✔
212

213
        return c.V1Store.ForEachNodeDirectedChannel(node, cb)
3✔
214
}
215

216
// FetchNodeFeatures returns the features of the given node. If no features are
217
// known for the node, an empty feature vector is returned.
218
// If the graphCache is available, then it will be used to retrieve the node's
219
// features instead of the database.
220
//
221
// NOTE: this is part of the graphdb.NodeTraverser interface.
222
func (c *ChannelGraph) FetchNodeFeatures(node route.Vertex) (
223
        *lnwire.FeatureVector, error) {
3✔
224

3✔
225
        if c.graphCache != nil {
6✔
226
                return c.graphCache.GetFeatures(node), nil
3✔
227
        }
3✔
228

229
        return c.V1Store.FetchNodeFeatures(node)
3✔
230
}
231

232
// GraphSession will provide the call-back with access to a NodeTraverser
233
// instance which can be used to perform queries against the channel graph. If
234
// the graph cache is not enabled, then the call-back will be provided with
235
// access to the graph via a consistent read-only transaction.
236
func (c *ChannelGraph) GraphSession(cb func(graph NodeTraverser) error) error {
3✔
237
        if c.graphCache != nil {
6✔
238
                return cb(c)
3✔
239
        }
3✔
240

UNCOV
241
        return c.V1Store.GraphSession(cb)
×
242
}
243

244
// ForEachNodeCached iterates through all the stored vertices/nodes in the
245
// graph, executing the passed callback with each node encountered.
246
//
247
// NOTE: The callback contents MUST not be modified.
248
func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex,
UNCOV
249
        chans map[uint64]*DirectedChannel) error) error {
×
UNCOV
250

×
UNCOV
251
        if c.graphCache != nil {
×
252
                return c.graphCache.ForEachNode(cb)
×
253
        }
×
254

UNCOV
255
        return c.V1Store.ForEachNodeCached(cb)
×
256
}
257

258
// AddLightningNode adds a vertex/node to the graph database. If the node is not
259
// in the database from before, this will add a new, unconnected one to the
260
// graph. If it is present from before, this will update that node's
261
// information. Note that this method is expected to only be called to update an
262
// already present node from a node announcement, or to insert a node found in a
263
// channel update.
264
func (c *ChannelGraph) AddLightningNode(ctx context.Context,
265
        node *models.LightningNode, op ...batch.SchedulerOption) error {
3✔
266

3✔
267
        err := c.V1Store.AddLightningNode(ctx, node, op...)
3✔
268
        if err != nil {
3✔
269
                return err
×
270
        }
×
271

272
        if c.graphCache != nil {
6✔
273
                c.graphCache.AddNodeFeatures(
3✔
274
                        node.PubKeyBytes, node.Features,
3✔
275
                )
3✔
276
        }
3✔
277

278
        select {
3✔
279
        case c.topologyUpdate <- node:
3✔
280
        case <-c.quit:
×
281
                return ErrChanGraphShuttingDown
×
282
        }
283

284
        return nil
3✔
285
}
286

287
// DeleteLightningNode starts a new database transaction to remove a vertex/node
288
// from the database according to the node's public key.
289
func (c *ChannelGraph) DeleteLightningNode(ctx context.Context,
UNCOV
290
        nodePub route.Vertex) error {
×
UNCOV
291

×
UNCOV
292
        err := c.V1Store.DeleteLightningNode(ctx, nodePub)
×
UNCOV
293
        if err != nil {
×
UNCOV
294
                return err
×
UNCOV
295
        }
×
296

UNCOV
297
        if c.graphCache != nil {
×
UNCOV
298
                c.graphCache.RemoveNode(nodePub)
×
UNCOV
299
        }
×
300

UNCOV
301
        return nil
×
302
}
303

304
// AddChannelEdge adds a new (undirected, blank) edge to the graph database. An
305
// undirected edge from the two target nodes are created. The information stored
306
// denotes the static attributes of the channel, such as the channelID, the keys
307
// involved in creation of the channel, and the set of features that the channel
308
// supports. The chanPoint and chanID are used to uniquely identify the edge
309
// globally within the database.
310
func (c *ChannelGraph) AddChannelEdge(edge *models.ChannelEdgeInfo,
311
        op ...batch.SchedulerOption) error {
3✔
312

3✔
313
        err := c.V1Store.AddChannelEdge(edge, op...)
3✔
314
        if err != nil {
3✔
UNCOV
315
                return err
×
UNCOV
316
        }
×
317

318
        if c.graphCache != nil {
6✔
319
                c.graphCache.AddChannel(models.NewCachedEdge(edge), nil, nil)
3✔
320
        }
3✔
321

322
        select {
3✔
323
        case c.topologyUpdate <- edge:
3✔
324
        case <-c.quit:
×
325
                return ErrChanGraphShuttingDown
×
326
        }
327

328
        return nil
3✔
329
}
330

331
// MarkEdgeLive clears an edge from our zombie index, deeming it as live.
332
// If the cache is enabled, the edge will be added back to the graph cache if
333
// we still have a record of this channel in the DB.
UNCOV
334
func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
×
UNCOV
335
        err := c.V1Store.MarkEdgeLive(chanID)
×
UNCOV
336
        if err != nil {
×
UNCOV
337
                return err
×
UNCOV
338
        }
×
339

UNCOV
340
        if c.graphCache != nil {
×
UNCOV
341
                // We need to add the channel back into our graph cache,
×
UNCOV
342
                // otherwise we won't use it for path finding.
×
UNCOV
343
                infos, err := c.V1Store.FetchChanInfos([]uint64{chanID})
×
UNCOV
344
                if err != nil {
×
345
                        return err
×
346
                }
×
347

UNCOV
348
                if len(infos) == 0 {
×
UNCOV
349
                        return nil
×
UNCOV
350
                }
×
351

352
                info := infos[0]
×
353

×
354
                c.graphCache.AddChannel(
×
355
                        models.NewCachedEdge(info.Info),
×
356
                        models.NewCachedPolicy(info.Policy1),
×
357
                        models.NewCachedPolicy(info.Policy2),
×
358
                )
×
359
        }
360

361
        return nil
×
362
}
363

364
// DeleteChannelEdges removes edges with the given channel IDs from the
365
// database and marks them as zombies. This ensures that we're unable to re-add
366
// it to our database once again. If an edge does not exist within the
367
// database, then ErrEdgeNotFound will be returned. If strictZombiePruning is
368
// true, then when we mark these edges as zombies, we'll set up the keys such
369
// that we require the node that failed to send the fresh update to be the one
370
// that resurrects the channel from its zombie state. The markZombie bool
371
// denotes whether to mark the channel as a zombie.
372
func (c *ChannelGraph) DeleteChannelEdges(strictZombiePruning, markZombie bool,
373
        chanIDs ...uint64) error {
3✔
374

3✔
375
        infos, err := c.V1Store.DeleteChannelEdges(
3✔
376
                strictZombiePruning, markZombie, chanIDs...,
3✔
377
        )
3✔
378
        if err != nil {
3✔
UNCOV
379
                return err
×
UNCOV
380
        }
×
381

382
        if c.graphCache != nil {
6✔
383
                for _, info := range infos {
6✔
384
                        c.graphCache.RemoveChannel(
3✔
385
                                info.NodeKey1Bytes, info.NodeKey2Bytes,
3✔
386
                                info.ChannelID,
3✔
387
                        )
3✔
388
                }
3✔
389
        }
390

391
        return err
3✔
392
}
393

394
// DisconnectBlockAtHeight is used to indicate that the block specified
395
// by the passed height has been disconnected from the main chain. This
396
// will "rewind" the graph back to the height below, deleting channels
397
// that are no longer confirmed from the graph. The prune log will be
398
// set to the last prune height valid for the remaining chain.
399
// Channels that were removed from the graph resulting from the
400
// disconnected block are returned.
401
func (c *ChannelGraph) DisconnectBlockAtHeight(height uint32) (
402
        []*models.ChannelEdgeInfo, error) {
2✔
403

2✔
404
        edges, err := c.V1Store.DisconnectBlockAtHeight(height)
2✔
405
        if err != nil {
2✔
406
                return nil, err
×
407
        }
×
408

409
        if c.graphCache != nil {
4✔
410
                for _, edge := range edges {
4✔
411
                        c.graphCache.RemoveChannel(
2✔
412
                                edge.NodeKey1Bytes, edge.NodeKey2Bytes,
2✔
413
                                edge.ChannelID,
2✔
414
                        )
2✔
415
                }
2✔
416
        }
417

418
        return edges, nil
2✔
419
}
420

421
// PruneGraph prunes newly closed channels from the channel graph in response
422
// to a new block being solved on the network. Any transactions which spend the
423
// funding output of any known channels within he graph will be deleted.
424
// Additionally, the "prune tip", or the last block which has been used to
425
// prune the graph is stored so callers can ensure the graph is fully in sync
426
// with the current UTXO state. A slice of channels that have been closed by
427
// the target block are returned if the function succeeds without error.
428
func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
429
        blockHash *chainhash.Hash, blockHeight uint32) (
430
        []*models.ChannelEdgeInfo, error) {
3✔
431

3✔
432
        edges, nodes, err := c.V1Store.PruneGraph(
3✔
433
                spentOutputs, blockHash, blockHeight,
3✔
434
        )
3✔
435
        if err != nil {
3✔
436
                return nil, err
×
437
        }
×
438

439
        if c.graphCache != nil {
6✔
440
                for _, edge := range edges {
6✔
441
                        c.graphCache.RemoveChannel(
3✔
442
                                edge.NodeKey1Bytes, edge.NodeKey2Bytes,
3✔
443
                                edge.ChannelID,
3✔
444
                        )
3✔
445
                }
3✔
446

447
                for _, node := range nodes {
6✔
448
                        c.graphCache.RemoveNode(node)
3✔
449
                }
3✔
450

451
                log.Debugf("Pruned graph, cache now has %s",
3✔
452
                        c.graphCache.Stats())
3✔
453
        }
454

455
        if len(edges) != 0 {
6✔
456
                // Notify all currently registered clients of the newly closed
3✔
457
                // channels.
3✔
458
                closeSummaries := createCloseSummaries(
3✔
459
                        blockHeight, edges...,
3✔
460
                )
3✔
461

3✔
462
                select {
3✔
463
                case c.topologyUpdate <- closeSummaries:
3✔
464
                case <-c.quit:
×
465
                        return nil, ErrChanGraphShuttingDown
×
466
                }
467
        }
468

469
        return edges, nil
3✔
470
}
471

472
// PruneGraphNodes is a garbage collection method which attempts to prune out
473
// any nodes from the channel graph that are currently unconnected. This ensure
474
// that we only maintain a graph of reachable nodes. In the event that a pruned
475
// node gains more channels, it will be re-added back to the graph.
476
func (c *ChannelGraph) PruneGraphNodes() error {
3✔
477
        nodes, err := c.V1Store.PruneGraphNodes()
3✔
478
        if err != nil {
3✔
479
                return err
×
480
        }
×
481

482
        if c.graphCache != nil {
6✔
483
                for _, node := range nodes {
3✔
UNCOV
484
                        c.graphCache.RemoveNode(node)
×
UNCOV
485
                }
×
486
        }
487

488
        return nil
3✔
489
}
490

491
// FilterKnownChanIDs takes a set of channel IDs and return the subset of chan
492
// ID's that we don't know and are not known zombies of the passed set. In other
493
// words, we perform a set difference of our set of chan ID's and the ones
494
// passed in. This method can be used by callers to determine the set of
495
// channels another peer knows of that we don't.
496
func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo,
497
        isZombieChan func(time.Time, time.Time) bool) ([]uint64, error) {
3✔
498

3✔
499
        unknown, knownZombies, err := c.V1Store.FilterKnownChanIDs(chansInfo)
3✔
500
        if err != nil {
3✔
501
                return nil, err
×
502
        }
×
503

504
        for _, info := range knownZombies {
3✔
UNCOV
505
                // TODO(ziggie): Make sure that for the strict pruning case we
×
UNCOV
506
                // compare the pubkeys and whether the right timestamp is not
×
UNCOV
507
                // older than the `ChannelPruneExpiry`.
×
UNCOV
508
                //
×
UNCOV
509
                // NOTE: The timestamp data has no verification attached to it
×
UNCOV
510
                // in the `ReplyChannelRange` msg so we are trusting this data
×
UNCOV
511
                // at this point. However it is not critical because we are just
×
UNCOV
512
                // removing the channel from the db when the timestamps are more
×
UNCOV
513
                // recent. During the querying of the gossip msg verification
×
UNCOV
514
                // happens as usual. However we should start punishing peers
×
UNCOV
515
                // when they don't provide us honest data ?
×
UNCOV
516
                isStillZombie := isZombieChan(
×
UNCOV
517
                        info.Node1UpdateTimestamp, info.Node2UpdateTimestamp,
×
UNCOV
518
                )
×
UNCOV
519

×
UNCOV
520
                if isStillZombie {
×
UNCOV
521
                        continue
×
522
                }
523

524
                // If we have marked it as a zombie but the latest update
525
                // timestamps could bring it back from the dead, then we mark it
526
                // alive, and we let it be added to the set of IDs to query our
527
                // peer for.
UNCOV
528
                err := c.V1Store.MarkEdgeLive(
×
UNCOV
529
                        info.ShortChannelID.ToUint64(),
×
UNCOV
530
                )
×
UNCOV
531
                // Since there is a chance that the edge could have been marked
×
UNCOV
532
                // as "live" between the FilterKnownChanIDs call and the
×
UNCOV
533
                // MarkEdgeLive call, we ignore the error if the edge is already
×
UNCOV
534
                // marked as live.
×
UNCOV
535
                if err != nil && !errors.Is(err, ErrZombieEdgeNotFound) {
×
536
                        return nil, err
×
537
                }
×
538
        }
539

540
        return unknown, nil
3✔
541
}
542

543
// MarkEdgeZombie attempts to mark a channel identified by its channel ID as a
544
// zombie. This method is used on an ad-hoc basis, when channels need to be
545
// marked as zombies outside the normal pruning cycle.
546
func (c *ChannelGraph) MarkEdgeZombie(chanID uint64,
UNCOV
547
        pubKey1, pubKey2 [33]byte) error {
×
UNCOV
548

×
UNCOV
549
        err := c.V1Store.MarkEdgeZombie(chanID, pubKey1, pubKey2)
×
UNCOV
550
        if err != nil {
×
551
                return err
×
552
        }
×
553

UNCOV
554
        if c.graphCache != nil {
×
UNCOV
555
                c.graphCache.RemoveChannel(pubKey1, pubKey2, chanID)
×
UNCOV
556
        }
×
557

UNCOV
558
        return nil
×
559
}
560

561
// UpdateEdgePolicy updates the edge routing policy for a single directed edge
562
// within the database for the referenced channel. The `flags` attribute within
563
// the ChannelEdgePolicy determines which of the directed edges are being
564
// updated. If the flag is 1, then the first node's information is being
565
// updated, otherwise it's the second node's information. The node ordering is
566
// determined by the lexicographical ordering of the identity public keys of the
567
// nodes on either side of the channel.
568
func (c *ChannelGraph) UpdateEdgePolicy(edge *models.ChannelEdgePolicy,
569
        op ...batch.SchedulerOption) error {
3✔
570

3✔
571
        from, to, err := c.V1Store.UpdateEdgePolicy(edge, op...)
3✔
572
        if err != nil {
3✔
UNCOV
573
                return err
×
UNCOV
574
        }
×
575

576
        if c.graphCache != nil {
6✔
577
                c.graphCache.UpdatePolicy(
3✔
578
                        models.NewCachedPolicy(edge), from, to,
3✔
579
                )
3✔
580
        }
3✔
581

582
        select {
3✔
583
        case c.topologyUpdate <- edge:
3✔
584
        case <-c.quit:
×
585
                return ErrChanGraphShuttingDown
×
586
        }
587

588
        return nil
3✔
589
}
590

591
// MakeTestGraphNew creates a new instance of the ChannelGraph for testing
592
// purposes. The backing V1Store implementation depends on the version of
593
// NewTestDB included in the current build.
594
//
595
// NOTE: this is currently unused, but is left here for future use to show how
596
// NewTestDB can be used. As the SQL implementation of the V1Store is
597
// implemented, unit tests will be switched to use this function instead of
598
// the existing MakeTestGraph helper. Once only this function is used, the
599
// existing MakeTestGraph function will be removed and this one will be renamed.
600
func MakeTestGraphNew(t testing.TB,
UNCOV
601
        opts ...ChanGraphOption) *ChannelGraph {
×
UNCOV
602

×
UNCOV
603
        t.Helper()
×
UNCOV
604

×
UNCOV
605
        store := NewTestDB(t)
×
UNCOV
606

×
UNCOV
607
        graph, err := NewChannelGraph(store, opts...)
×
UNCOV
608
        require.NoError(t, err)
×
UNCOV
609
        require.NoError(t, graph.Start())
×
UNCOV
610

×
UNCOV
611
        t.Cleanup(func() {
×
UNCOV
612
                require.NoError(t, graph.Stop())
×
UNCOV
613
        })
×
614

UNCOV
615
        return graph
×
616
}
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