mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-24 10:40:10 +02:00
channeldb/test: refactor TestGraphCacheForEachNodeChannel
This commit is contained in:
parent
9d4251c18d
commit
d97e7d30fb
@ -3934,19 +3934,24 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
|
|||||||
// Add the channel, but only insert a single edge into the graph.
|
// Add the channel, but only insert a single edge into the graph.
|
||||||
require.NoError(t, graph.AddChannelEdge(edgeInfo))
|
require.NoError(t, graph.AddChannelEdge(edgeInfo))
|
||||||
|
|
||||||
// We should be able to accumulate the single channel added, even
|
getSingleChannel := func() *DirectedChannel {
|
||||||
// though we have a nil edge policy here.
|
var ch *DirectedChannel
|
||||||
var numChans int
|
|
||||||
err = graph.ForEachNodeDirectedChannel(nil, node1.PubKeyBytes,
|
err = graph.ForEachNodeDirectedChannel(nil, node1.PubKeyBytes,
|
||||||
func(_ *DirectedChannel) error {
|
func(c *DirectedChannel) error {
|
||||||
numChans++
|
require.Nil(t, ch)
|
||||||
|
ch = c
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, numChans, 1)
|
return ch
|
||||||
|
}
|
||||||
|
|
||||||
|
// We should be able to accumulate the single channel added, even
|
||||||
|
// though we have a nil edge policy here.
|
||||||
|
require.NotNil(t, getSingleChannel())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestGraphLoading asserts that the cache is properly reconstructed after a
|
// TestGraphLoading asserts that the cache is properly reconstructed after a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user