channeldb/test: refactor TestGraphCacheForEachNodeChannel
This commit is contained in:
1 parent
9d4251c18d
commit
d97e7d30fb
1 file changed
+16
-11
+16
-11
@@ -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))
|
||||||
|
|
||||||
|
getSingleChannel := func() *DirectedChannel {
|
||||||
|
var ch *DirectedChannel
|
||||||
|
err = graph.ForEachNodeDirectedChannel(nil, node1.PubKeyBytes,
|
||||||
|
func(c *DirectedChannel) error {
|
||||||
|
require.Nil(t, ch)
|
||||||
|
ch = c
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
return ch
|
||||||
|
}
|
||||||
|
|
||||||
// We should be able to accumulate the single channel added, even
|
// We should be able to accumulate the single channel added, even
|
||||||
// though we have a nil edge policy here.
|
// though we have a nil edge policy here.
|
||||||
var numChans int
|
require.NotNil(t, getSingleChannel())
|
||||||
err = graph.ForEachNodeDirectedChannel(nil, node1.PubKeyBytes,
|
|
||||||
func(_ *DirectedChannel) error {
|
|
||||||
numChans++
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
require.Equal(t, numChans, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestGraphLoading asserts that the cache is properly reconstructed after a
|
// TestGraphLoading asserts that the cache is properly reconstructed after a
|
||||||
|
|||||||
Reference in new issue
Block a user