mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 14:40:51 +02:00
channeldb: remove graph db from channeldb
Now that the channel.DB no longer uses the ChannelGraph pointer, we can completely remove it as a member of channeldb.DB.
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"net"
|
||||
"sort"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
@@ -4775,3 +4776,31 @@ func deserializeChanEdgePolicyRaw(r io.Reader) (*models.ChannelEdgePolicy,
|
||||
|
||||
return edge, nil
|
||||
}
|
||||
|
||||
// MakeTestGraph creates a new instance of the ChannelGraph for testing purposes.
|
||||
func MakeTestGraph(t testing.TB, modifiers ...OptionModifier) (*ChannelGraph, error) {
|
||||
opts := DefaultOptions()
|
||||
for _, modifier := range modifiers {
|
||||
modifier(opts)
|
||||
}
|
||||
|
||||
// Next, create channelgraph for the first time.
|
||||
backend, backendCleanup, err := kvdb.GetTestBackend(t.TempDir(), "cgr")
|
||||
if err != nil {
|
||||
backendCleanup()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
graph, err := NewChannelGraph(backend)
|
||||
if err != nil {
|
||||
backendCleanup()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
t.Cleanup(func() {
|
||||
_ = backend.Close()
|
||||
backendCleanup()
|
||||
})
|
||||
|
||||
return graph, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user