102 files changed
+461
-488
No files matched your search
+13
-14
@@ -2,7 +2,6 @@ package graph
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
@@ -44,7 +43,7 @@ const (
|
||||
// info was added to the database.
|
||||
func TestAddProof(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
ctx := createTestCtxSingleNode(t, 0)
|
||||
|
||||
@@ -109,7 +108,7 @@ func TestIgnoreNodeAnnouncement(t *testing.T) {
|
||||
}
|
||||
copy(node.PubKeyBytes[:], pub.SerializeCompressed())
|
||||
|
||||
err := ctx.builder.AddNode(context.Background(), node)
|
||||
err := ctx.builder.AddNode(t.Context(), node)
|
||||
if !IsError(err, ErrIgnored) {
|
||||
t.Fatalf("expected to get ErrIgnore, instead got: %v", err)
|
||||
}
|
||||
@@ -119,7 +118,7 @@ func TestIgnoreNodeAnnouncement(t *testing.T) {
|
||||
// ignore a channel policy for a channel not in the graph.
|
||||
func TestIgnoreChannelEdgePolicyForUnknownChannel(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
const startingBlockHeight = 101
|
||||
|
||||
@@ -194,7 +193,7 @@ func TestIgnoreChannelEdgePolicyForUnknownChannel(t *testing.T) {
|
||||
// confirmed on the stale chain, and resync to the main chain.
|
||||
func TestWakeUpOnStaleBranch(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
const startingBlockHeight = 101
|
||||
ctx := createTestCtxSingleNode(t, startingBlockHeight)
|
||||
@@ -354,7 +353,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
|
||||
// Give time to process new blocks.
|
||||
time.Sleep(time.Millisecond * 500)
|
||||
|
||||
selfNode, err := ctx.graph.SourceNode(context.Background())
|
||||
selfNode, err := ctx.graph.SourceNode(t.Context())
|
||||
require.NoError(t, err)
|
||||
|
||||
// Create new router with same graph database.
|
||||
@@ -408,7 +407,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
|
||||
// it is active.
|
||||
func TestDisconnectedBlocks(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
const startingBlockHeight = 101
|
||||
ctx := createTestCtxSingleNode(t, startingBlockHeight)
|
||||
@@ -609,7 +608,7 @@ func TestDisconnectedBlocks(t *testing.T) {
|
||||
// ChannelRouter, then the channels are properly pruned.
|
||||
func TestChansClosedOfflinePruneGraph(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
const startingBlockHeight = 101
|
||||
ctx := createTestCtxSingleNode(t, startingBlockHeight)
|
||||
@@ -1037,7 +1036,7 @@ func testPruneChannelGraphDoubleDisabled(t *testing.T, assumeValid bool) {
|
||||
// node announcements.
|
||||
func TestIsStaleNode(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
const startingBlockHeight = 101
|
||||
ctx := createTestCtxSingleNode(t, startingBlockHeight)
|
||||
@@ -1095,7 +1094,7 @@ func TestIsStaleNode(t *testing.T) {
|
||||
Features: testFeatures,
|
||||
}
|
||||
copy(n1.PubKeyBytes[:], priv1.PubKey().SerializeCompressed())
|
||||
if err := ctx.builder.AddNode(context.Background(), n1); err != nil {
|
||||
if err := ctx.builder.AddNode(t.Context(), n1); err != nil {
|
||||
t.Fatalf("could not add node: %v", err)
|
||||
}
|
||||
|
||||
@@ -1117,7 +1116,7 @@ func TestIsStaleNode(t *testing.T) {
|
||||
// channel announcements.
|
||||
func TestIsKnownEdge(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
const startingBlockHeight = 101
|
||||
ctx := createTestCtxSingleNode(t, startingBlockHeight)
|
||||
@@ -1167,7 +1166,7 @@ func TestIsKnownEdge(t *testing.T) {
|
||||
// stale channel edge update announcements.
|
||||
func TestIsStaleEdgePolicy(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
const startingBlockHeight = 101
|
||||
ctx := createTestCtxFromFile(t, startingBlockHeight, basicGraphFilePath)
|
||||
@@ -1359,7 +1358,7 @@ func createTestCtxFromFile(t *testing.T,
|
||||
func parseTestGraph(t *testing.T, useCache bool, path string) (
|
||||
*testGraphInstance, error) {
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graphJSON, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
@@ -1751,7 +1750,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
testChannels []*testChannel, source string) (*testGraphInstance,
|
||||
error) {
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// We'll use this fake address for the IP address of all the nodes in
|
||||
// our tests. This value isn't needed for path finding so it doesn't
|
||||
|
||||
@@ -189,7 +189,7 @@ func sqlSQLite(t testing.TB, dbPath, file string) BatchedSQLQueries {
|
||||
// database for testing purposes.
|
||||
func kvdbPostgres(t testing.TB, dsn string) kvdb.Backend {
|
||||
kvStore, err := kvdb.Open(
|
||||
kvdb.PostgresBackendName, context.Background(),
|
||||
kvdb.PostgresBackendName, t.Context(),
|
||||
&postgres.Config{
|
||||
Dsn: dsn,
|
||||
MaxConnections: testMaxPostgresConnections,
|
||||
@@ -217,7 +217,7 @@ func connectKVDBPostgres(t testing.TB, dsn string) V1Store {
|
||||
func kvdbSqlite(t testing.TB, dbPath, fileName string) kvdb.Backend {
|
||||
sqlbase.Init(testMaxSQLiteConnections)
|
||||
kvStore, err := kvdb.Open(
|
||||
kvdb.SqliteBackendName, context.Background(),
|
||||
kvdb.SqliteBackendName, t.Context(),
|
||||
&sqlite.Config{
|
||||
BusyTimeout: testSQLBusyTimeout,
|
||||
MaxConnections: testMaxSQLiteConnections,
|
||||
@@ -273,7 +273,7 @@ func newKVStore(t testing.TB, backend kvdb.Backend) V1Store {
|
||||
// provided sqldb.DB instance.
|
||||
func newSQLExecutor(t testing.TB, db sqldb.DB) BatchedSQLQueries {
|
||||
err := db.ApplyAllMigrations(
|
||||
context.Background(), sqldb.GetMigrations(),
|
||||
t.Context(), sqldb.GetMigrations(),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -317,7 +317,7 @@ func newSQLStore(t testing.TB, cfg *sqldb.QueryConfig,
|
||||
// very long to sync the graph.
|
||||
func TestPopulateDBs(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// NOTE: uncomment the line below to run this test locally, then provide
|
||||
// the desired source database (and make sure the destination Postgres
|
||||
@@ -539,7 +539,7 @@ func TestPopulateViaMigration(t *testing.T) {
|
||||
|
||||
// Use the graph migration to populate the SQL graph from the
|
||||
// kvdb graph.
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
err := dstSQL.ExecTx(
|
||||
ctx, sqldb.WriteTxOpt(), func(queries SQLQueries) error {
|
||||
return MigrateGraphToSQL(
|
||||
@@ -556,7 +556,7 @@ func TestPopulateViaMigration(t *testing.T) {
|
||||
// syncGraph synchronizes the source graph with the destination graph by
|
||||
// copying all nodes and channels from the source to the destination.
|
||||
func syncGraph(t *testing.T, src, dest *ChannelGraph) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
var (
|
||||
s = rate.Sometimes{
|
||||
@@ -683,7 +683,7 @@ func syncGraph(t *testing.T, src, dest *ChannelGraph) {
|
||||
// NOTE: the TestPopulateDBs test helper can be used to populate a set of test
|
||||
// DBs from a single source db.
|
||||
func BenchmarkCacheLoading(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
ctx := b.Context()
|
||||
|
||||
tests := []dbConnection{
|
||||
kvdbBBoltConn,
|
||||
@@ -723,7 +723,7 @@ func BenchmarkCacheLoading(b *testing.B) {
|
||||
// NOTE: the TestPopulateDBs test helper can be used to populate a set of test
|
||||
// DBs from a single source db.
|
||||
func BenchmarkGraphReadMethods(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
ctx := b.Context()
|
||||
|
||||
backends := []dbConnection{
|
||||
kvdbBBoltConn,
|
||||
@@ -900,7 +900,7 @@ func BenchmarkFindOptimalSQLQueryConfig(b *testing.B) {
|
||||
for _, size := range testSizes {
|
||||
b.Run(fmt.Sprintf("%s-%s-%d", configOption, dbName, size),
|
||||
func(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
ctx := b.Context()
|
||||
|
||||
cfg := sqldb.DefaultSQLiteConfig()
|
||||
if testPostgres {
|
||||
|
||||
+37
-37
@@ -100,7 +100,7 @@ func createTestVertex(t testing.TB) *models.LightningNode {
|
||||
// TestNodeInsertionAndDeletion tests the CRUD operations for a LightningNode.
|
||||
func TestNodeInsertionAndDeletion(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -276,7 +276,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
||||
// only the pubkey is known to the database.
|
||||
func TestPartialNode(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -344,7 +344,7 @@ func TestPartialNode(t *testing.T) {
|
||||
// TestAliasLookup tests the alias lookup functionality of the graph store.
|
||||
func TestAliasLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -375,7 +375,7 @@ func TestAliasLookup(t *testing.T) {
|
||||
// TestSourceNode tests the source node functionality of the graph store.
|
||||
func TestSourceNode(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -402,7 +402,7 @@ func TestSourceNode(t *testing.T) {
|
||||
// TestEdgeInsertionDeletion tests the basic CRUD operations for channel edges.
|
||||
func TestEdgeInsertionDeletion(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -527,7 +527,7 @@ func createEdge(height, txIndex uint32, txPosition uint16, outPointIndex uint32,
|
||||
// database is what we expect after calling DisconnectBlockAtHeight.
|
||||
func TestDisconnectBlockAtHeight(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -818,7 +818,7 @@ func createChannelEdge(node1, node2 *models.LightningNode,
|
||||
|
||||
func TestEdgeInfoUpdates(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -914,7 +914,7 @@ func TestEdgeInfoUpdates(t *testing.T) {
|
||||
// TestEdgePolicyCRUD tests basic CRUD operations for edge policies.
|
||||
func TestEdgePolicyCRUD(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -1208,7 +1208,7 @@ func newEdgePolicy(chanID uint64, updateTime int64) *models.ChannelEdgePolicy {
|
||||
// TestAddEdgeProof tests the ability to add an edge proof to an existing edge.
|
||||
func TestAddEdgeProof(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -1267,7 +1267,7 @@ func TestAddEdgeProof(t *testing.T) {
|
||||
// correctly iterates through the channels of the set source node.
|
||||
func TestForEachSourceNodeChannel(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -1356,7 +1356,7 @@ func TestForEachSourceNodeChannel(t *testing.T) {
|
||||
|
||||
func TestGraphTraversal(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -1455,7 +1455,7 @@ func TestGraphTraversal(t *testing.T) {
|
||||
// working correctly.
|
||||
func TestGraphTraversalCacheable(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -1582,7 +1582,7 @@ func TestGraphCacheTraversal(t *testing.T) {
|
||||
func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
|
||||
numChannels int) (map[uint64]struct{}, []*models.LightningNode) {
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
nodes := make([]*models.LightningNode, numNodes)
|
||||
nodeIndex := map[string]struct{}{}
|
||||
@@ -1694,7 +1694,7 @@ func assertPruneTip(t *testing.T, graph *ChannelGraph,
|
||||
func assertNumChans(t *testing.T, graph *ChannelGraph, n int) {
|
||||
numChans := 0
|
||||
err := graph.ForEachChannel(
|
||||
context.Background(), func(*models.ChannelEdgeInfo,
|
||||
t.Context(), func(*models.ChannelEdgeInfo,
|
||||
*models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy) error {
|
||||
|
||||
@@ -1710,7 +1710,7 @@ func assertNumChans(t *testing.T, graph *ChannelGraph, n int) {
|
||||
|
||||
func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) {
|
||||
numNodes := 0
|
||||
err := graph.ForEachNode(context.Background(),
|
||||
err := graph.ForEachNode(t.Context(),
|
||||
func(_ *models.LightningNode) error {
|
||||
numNodes++
|
||||
|
||||
@@ -1772,7 +1772,7 @@ func assertChanViewEqualChanPoints(t *testing.T, a []EdgePoint,
|
||||
|
||||
func TestGraphPruning(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -1963,7 +1963,7 @@ func TestGraphPruning(t *testing.T) {
|
||||
// known channel ID in the database.
|
||||
func TestHighestChanID(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -2023,7 +2023,7 @@ func TestHighestChanID(t *testing.T) {
|
||||
// insertion of a new edge, the edge update index is updated properly.
|
||||
func TestChanUpdatesInHorizon(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -2181,7 +2181,7 @@ func TestChanUpdatesInHorizon(t *testing.T) {
|
||||
// the most recent node updates within a particular time horizon.
|
||||
func TestNodeUpdatesInHorizon(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -2352,7 +2352,7 @@ func TestFilterKnownChanIDsZombieRevival(t *testing.T) {
|
||||
// know of on disk.
|
||||
func TestFilterKnownChanIDs(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -2535,7 +2535,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
|
||||
t.Skipf("Skipping test in short mode")
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -2824,7 +2824,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
|
||||
// set of short channel ID's for a given block range.
|
||||
func TestFilterChannelRange(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -3043,7 +3043,7 @@ func TestFilterChannelRange(t *testing.T) {
|
||||
// of ChannelEdge structs for a given set of short channel ID's.
|
||||
func TestFetchChanInfos(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -3146,7 +3146,7 @@ func TestFetchChanInfos(t *testing.T) {
|
||||
// both sides.
|
||||
func TestIncompleteChannelPolicies(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -3239,7 +3239,7 @@ func TestIncompleteChannelPolicies(t *testing.T) {
|
||||
// up.
|
||||
func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -3387,7 +3387,7 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) {
|
||||
// PruneSyncState method.
|
||||
func TestPruneGraphNodes(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -3453,7 +3453,7 @@ func TestPruneGraphNodes(t *testing.T) {
|
||||
// database, then shell edges are created for each node if needed.
|
||||
func TestAddChannelEdgeShellNodes(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -3492,7 +3492,7 @@ func TestAddChannelEdgeShellNodes(t *testing.T) {
|
||||
// well.
|
||||
func TestNodePruningUpdateIndexDeletion(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -3553,7 +3553,7 @@ func nextUpdateTime() time.Time {
|
||||
// public within the network graph.
|
||||
func TestNodeIsPublic(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// We'll start off the test by creating a small network of 3
|
||||
// participants with the following graph:
|
||||
@@ -3688,7 +3688,7 @@ func TestNodeIsPublic(t *testing.T) {
|
||||
// DisabledChannelIDs is correct.
|
||||
func TestDisabledChannelIDs(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -3773,7 +3773,7 @@ func TestDisabledChannelIDs(t *testing.T) {
|
||||
// receive the proper update.
|
||||
func TestEdgePolicyMissingMaxHTLC(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -3916,7 +3916,7 @@ func assertNumZombies(t *testing.T, graph *ChannelGraph, expZombies uint64) {
|
||||
// TestGraphZombieIndex ensures that we can mark edges correctly as zombie/live.
|
||||
func TestGraphZombieIndex(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// We'll start by creating our test graph along with a test edge.
|
||||
graph := MakeTestGraph(t)
|
||||
@@ -4103,7 +4103,7 @@ func TestComputeFee(t *testing.T) {
|
||||
// executes multiple AddChannelEdge requests in a single txn.
|
||||
func TestBatchedAddChannelEdge(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -4180,7 +4180,7 @@ func TestBatchedAddChannelEdge(t *testing.T) {
|
||||
// executes multiple UpdateEdgePolicy requests in a single txn.
|
||||
func TestBatchedUpdateEdgePolicy(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -4233,7 +4233,7 @@ func TestBatchedUpdateEdgePolicy(t *testing.T) {
|
||||
// allocations and the total memory consumed by the full graph traversal.
|
||||
func BenchmarkForEachChannel(b *testing.B) {
|
||||
graph := MakeTestGraph(b)
|
||||
ctx := context.Background()
|
||||
ctx := b.Context()
|
||||
|
||||
const numNodes = 100
|
||||
const numChannels = 4
|
||||
@@ -4286,7 +4286,7 @@ func BenchmarkForEachChannel(b *testing.B) {
|
||||
// method works as expected, and is able to handle nil self edges.
|
||||
func TestGraphCacheForEachNodeChannel(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -4448,7 +4448,7 @@ var testNodeAnn = "01012674c2e7ef68c73a086b7de2603f4ef1567358df84bb4edaa06c" +
|
||||
// that the two messages are equal.
|
||||
func TestLightningNodePersistence(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Create a new test graph instance.
|
||||
graph := MakeTestGraph(t)
|
||||
|
||||
@@ -5,7 +5,6 @@ package graphdb
|
||||
import (
|
||||
"bytes"
|
||||
"cmp"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -65,7 +64,7 @@ var (
|
||||
// ensure that the migration can handle this.
|
||||
func TestMigrateGraphToSQL(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
dbFixture := NewTestDBFixture(t)
|
||||
|
||||
@@ -459,7 +458,7 @@ func assertInSync(t *testing.T, kvDB *KVStore, sqlDB *SQLStore,
|
||||
func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode {
|
||||
nodes := make([]*models.LightningNode, 0)
|
||||
|
||||
err := store.ForEachNode(context.Background(),
|
||||
err := store.ForEachNode(t.Context(),
|
||||
func(node *models.LightningNode) error {
|
||||
|
||||
// Call PubKey to ensure the objects cached pubkey is set so that
|
||||
@@ -489,7 +488,7 @@ func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode {
|
||||
|
||||
// fetchSourceNode retrieves the source node from the given store.
|
||||
func fetchSourceNode(t *testing.T, store V1Store) *models.LightningNode {
|
||||
node, err := store.SourceNode(context.Background())
|
||||
node, err := store.SourceNode(t.Context())
|
||||
if errors.Is(err, ErrSourceNodeNotSet) {
|
||||
return nil
|
||||
} else {
|
||||
@@ -527,7 +526,7 @@ func (c chanSet) CountPolicies() int {
|
||||
// fetchAllChannelsAndPolicies retrieves all channels and their policies
|
||||
// from the given store and returns them sorted by their channel ID.
|
||||
func fetchAllChannelsAndPolicies(t *testing.T, store V1Store) chanSet {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
channels := make(chanSet, 0)
|
||||
err := store.ForEachChannel(ctx, func(info *models.ChannelEdgeInfo,
|
||||
p1 *models.ChannelEdgePolicy,
|
||||
@@ -572,7 +571,7 @@ func checkKVPruneLogEntries(t *testing.T, kv *KVStore, sql *SQLStore,
|
||||
err := forEachPruneLogEntry(
|
||||
kv.db, func(height uint32, hash *chainhash.Hash) error {
|
||||
sqlHash, err := sql.db.GetPruneHashByHeight(
|
||||
context.Background(), int64(height),
|
||||
t.Context(), int64(height),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, hash[:], sqlHash)
|
||||
@@ -804,7 +803,7 @@ func makeTestPolicy(chanID uint64, toNode route.Vertex, isNode1 bool,
|
||||
// and set the "fileName" variable to the name of the channel database file you
|
||||
// want to use for the migration test.
|
||||
func TestMigrationWithChannelDB(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// NOTE: comment this line out to run the test.
|
||||
t.Skipf("skipping test meant for local debugging only")
|
||||
@@ -923,7 +922,7 @@ func TestMigrationWithChannelDB(t *testing.T) {
|
||||
// will differ slightly.
|
||||
func TestSQLMigrationEdgeCases(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
var invalidTLVData = []byte{0x01, 0x02, 0x03}
|
||||
|
||||
@@ -1183,7 +1182,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
||||
func runTestMigration(t *testing.T, populateKV func(t *testing.T, db *KVStore),
|
||||
expState dbState) {
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Set up our source kvdb DB.
|
||||
kvDB := setUpKVStore(t)
|
||||
@@ -1278,7 +1277,7 @@ func TestMigrateGraphToSQLRapid(t *testing.T) {
|
||||
func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T,
|
||||
dbFixture *sqldb.TestPgFixture, maxNumNodes, maxNumChannels int) {
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Set up our source kvdb DB.
|
||||
kvDB := setUpKVStore(t)
|
||||
|
||||
@@ -2,7 +2,6 @@ package graph
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"image/color"
|
||||
@@ -422,7 +421,7 @@ func (m *mockChainView) FilterBlock(blockHash *chainhash.Hash) (*chainview.Filte
|
||||
// a proper notification is sent of to all registered clients.
|
||||
func TestEdgeUpdateNotification(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
ctx := createTestCtxSingleNode(t, 0)
|
||||
|
||||
@@ -611,7 +610,7 @@ func TestEdgeUpdateNotification(t *testing.T) {
|
||||
// attributes with new data.
|
||||
func TestNodeUpdateNotification(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
const startingBlockHeight = 101
|
||||
ctx := createTestCtxSingleNode(t, startingBlockHeight)
|
||||
@@ -795,7 +794,7 @@ func TestNodeUpdateNotification(t *testing.T) {
|
||||
// when the client wishes to exit.
|
||||
func TestNotificationCancellation(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
const startingBlockHeight = 101
|
||||
ctx := createTestCtxSingleNode(t, startingBlockHeight)
|
||||
@@ -879,7 +878,7 @@ func TestNotificationCancellation(t *testing.T) {
|
||||
// properly dispatched to all registered clients.
|
||||
func TestChannelCloseNotification(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctxb := context.Background()
|
||||
ctxb := t.Context()
|
||||
|
||||
const startingBlockHeight = 101
|
||||
ctx := createTestCtxSingleNode(t, startingBlockHeight)
|
||||
@@ -1067,7 +1066,7 @@ func createTestCtxSingleNode(t *testing.T,
|
||||
sourceNode := createTestNode(t)
|
||||
|
||||
require.NoError(t,
|
||||
graph.SetSourceNode(context.Background(), sourceNode),
|
||||
graph.SetSourceNode(t.Context(), sourceNode),
|
||||
"failed to set source node",
|
||||
)
|
||||
|
||||
@@ -1083,7 +1082,7 @@ func createTestCtxSingleNode(t *testing.T,
|
||||
func (c *testCtx) RestartBuilder(t *testing.T) {
|
||||
c.chainView.Reset()
|
||||
|
||||
selfNode, err := c.graph.SourceNode(context.Background())
|
||||
selfNode, err := c.graph.SourceNode(t.Context())
|
||||
require.NoError(t, err)
|
||||
|
||||
// With the chainView reset, we'll now re-create the builder itself, and
|
||||
@@ -1156,7 +1155,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
|
||||
ConfChan: make(chan *chainntnfs.TxConfirmation),
|
||||
}
|
||||
|
||||
selfnode, err := graphInstance.graph.SourceNode(context.Background())
|
||||
selfnode, err := graphInstance.graph.SourceNode(t.Context())
|
||||
require.NoError(t, err)
|
||||
|
||||
graphBuilder, err := NewBuilder(&Config{
|
||||
|
||||
Reference in new issue
Block a user