From 921eea9f571ef57dec925fd1d67ab4686e8517f6 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 8 Apr 2019 17:50:23 -0700 Subject: [PATCH] discovery: update mockGraphSource to implement ForAllOutgoingChannels --- discovery/gossiper_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index 265b0898..73ed6b53 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -202,6 +202,30 @@ func (r *mockGraphSource) ForEachNode(func(node *channeldb.LightningNode) error) func (r *mockGraphSource) ForAllOutgoingChannels(cb func(i *channeldb.ChannelEdgeInfo, c *channeldb.ChannelEdgePolicy) error) error { + + r.mu.Lock() + defer r.mu.Unlock() + + chans := make(map[uint64]channeldb.ChannelEdge) + for _, info := range r.infos { + info := info + + edgeInfo := chans[info.ChannelID] + edgeInfo.Info = &info + chans[info.ChannelID] = edgeInfo + } + for _, edges := range r.edges { + edges := edges + + edge := chans[edges[0].ChannelID] + edge.Policy1 = &edges[0] + chans[edges[0].ChannelID] = edge + } + + for _, channel := range chans { + cb(channel.Info, channel.Policy1) + } + return nil }