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:
Elle Mouton
2024-10-22 14:51:32 +02:00
parent 2c083bc017
commit b86980ec40
9 changed files with 100 additions and 134 deletions

View File

@@ -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
}