@@ -23,6 +23,7 @@ import (
23
23
"github.com/btcsuite/btcd/chaincfg"
24
24
"github.com/btcsuite/btcd/chaincfg/chainhash"
25
25
"github.com/btcsuite/btcd/wire"
26
+ "github.com/lightningnetwork/lnd/fn/v2"
26
27
"github.com/lightningnetwork/lnd/graph/db/models"
27
28
"github.com/lightningnetwork/lnd/kvdb"
28
29
"github.com/lightningnetwork/lnd/lnwire"
@@ -1366,7 +1367,7 @@ func TestGraphTraversal(t *testing.T) {
1366
1367
func TestGraphTraversalCacheable (t * testing.T ) {
1367
1368
t .Parallel ()
1368
1369
1369
- graph := MakeTestGraph (t )
1370
+ graph := MakeTestGraphNew (t )
1370
1371
1371
1372
// We'd like to test some of the graph traversal capabilities within
1372
1373
// the DB, so we'll create a series of fake nodes to insert into the
@@ -1436,7 +1437,7 @@ func TestGraphTraversalCacheable(t *testing.T) {
1436
1437
func TestGraphCacheTraversal (t * testing.T ) {
1437
1438
t .Parallel ()
1438
1439
1439
- graph := MakeTestGraph (t )
1440
+ graph := MakeTestGraphNew (t )
1440
1441
1441
1442
// We'd like to test some of the graph traversal capabilities within
1442
1443
// the DB, so we'll create a series of fake nodes to insert into the
@@ -2069,16 +2070,15 @@ func TestChanUpdatesInHorizon(t *testing.T) {
2069
2070
2070
2071
assertEdgeInfoEqual (t , chanExp .Info , chanRet .Info )
2071
2072
2072
- err : = compareEdgePolicies (
2073
+ err = compareEdgePolicies (
2073
2074
chanExp .Policy1 , chanRet .Policy1 ,
2074
2075
)
2075
- if err != nil {
2076
- t .Fatal (err )
2077
- }
2078
- compareEdgePolicies (chanExp .Policy2 , chanRet .Policy2 )
2079
- if err != nil {
2080
- t .Fatal (err )
2081
- }
2076
+ require .NoError (t , err )
2077
+
2078
+ err = compareEdgePolicies (
2079
+ chanExp .Policy2 , chanRet .Policy2 ,
2080
+ )
2081
+ require .NoError (t , err )
2082
2082
}
2083
2083
}
2084
2084
}
@@ -3041,7 +3041,7 @@ func TestIncompleteChannelPolicies(t *testing.T) {
3041
3041
t .Parallel ()
3042
3042
ctx := context .Background ()
3043
3043
3044
- graph := MakeTestGraph (t )
3044
+ graph := MakeTestGraphNew (t )
3045
3045
3046
3046
// Create two nodes.
3047
3047
node1 := createTestVertex (t )
@@ -4110,7 +4110,7 @@ func TestBatchedUpdateEdgePolicy(t *testing.T) {
4110
4110
// BenchmarkForEachChannel is a benchmark test that measures the number of
4111
4111
// allocations and the total memory consumed by the full graph traversal.
4112
4112
func BenchmarkForEachChannel (b * testing.B ) {
4113
- graph := MakeTestGraph (b )
4113
+ graph := MakeTestGraphNew (b )
4114
4114
4115
4115
const numNodes = 100
4116
4116
const numChannels = 4
@@ -4163,7 +4163,7 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
4163
4163
t .Parallel ()
4164
4164
ctx := context .Background ()
4165
4165
4166
- graph := MakeTestGraph (t )
4166
+ graph := MakeTestGraphNew (t )
4167
4167
4168
4168
// Unset the channel graph cache to simulate the user running with the
4169
4169
// option turned off.
@@ -4213,21 +4213,25 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
4213
4213
edge1 .ExtraOpaqueData = []byte {
4214
4214
253 , 217 , 3 , 8 , 0 , 0 , 0 , 10 , 0 , 0 , 0 , 20 ,
4215
4215
}
4216
+ inboundFee := lnwire.Fee {
4217
+ BaseFee : 10 ,
4218
+ FeeRate : 20 ,
4219
+ }
4220
+ edge1 .InboundFee = fn .Some (inboundFee )
4216
4221
require .NoError (t , graph .UpdateEdgePolicy (edge1 ))
4217
4222
edge1 = copyEdgePolicy (edge1 ) // Avoid read/write race conditions.
4218
4223
4219
4224
directedChan := getSingleChannel ()
4220
4225
require .NotNil (t , directedChan )
4221
- expectedInbound := lnwire.Fee {
4222
- BaseFee : 10 ,
4223
- FeeRate : 20 ,
4224
- }
4225
- require .Equal (t , expectedInbound , directedChan .InboundFee )
4226
+ require .Equal (t , inboundFee , directedChan .InboundFee )
4226
4227
4227
4228
// Set an invalid inbound fee and check that persistence fails.
4228
4229
edge1 .ExtraOpaqueData = []byte {
4229
4230
253 , 217 , 3 , 8 , 0 ,
4230
4231
}
4232
+ // We need to update the timestamp so that we don't hit the DB conflict
4233
+ // error when we try to update the edge policy.
4234
+ edge1 .LastUpdate = edge1 .LastUpdate .Add (time .Second )
4231
4235
require .ErrorIs (
4232
4236
t , graph .UpdateEdgePolicy (edge1 ), ErrParsingExtraTLVBytes ,
4233
4237
)
@@ -4236,7 +4240,7 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
4236
4240
// the previous result when we query the channel again.
4237
4241
directedChan = getSingleChannel ()
4238
4242
require .NotNil (t , directedChan )
4239
- require .Equal (t , expectedInbound , directedChan .InboundFee )
4243
+ require .Equal (t , inboundFee , directedChan .InboundFee )
4240
4244
}
4241
4245
4242
4246
// TestGraphLoading asserts that the cache is properly reconstructed after a
0 commit comments