From c1633da2522a37b27b3dc2e5cd4824898fe187dd Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Fri, 31 Aug 2018 14:59:36 -0700 Subject: [PATCH] channeldb/graph_test: extend prune edge update index test to update edges In this commit, we extend TestChannelEdgePruningUpdateIndexDeletion test to include one more update for each edge. By doing this, we can correctly determine whether old entries were properly pruned from the index once a new update has arrived. --- channeldb/graph_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/channeldb/graph_test.go b/channeldb/graph_test.go index ef274b09..4e1d10f7 100644 --- a/channeldb/graph_test.go +++ b/channeldb/graph_test.go @@ -2178,6 +2178,26 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) { uint64(edge2.LastUpdate.Unix()), ) + // Now, we'll update the edge policies to ensure the old timestamps are + // removed from the update index. + edge1.Flags = 2 + edge1.LastUpdate = time.Now() + if err := graph.UpdateEdgePolicy(edge1); err != nil { + t.Fatalf("unable to update edge: %v", err) + } + edge2.Flags = 3 + edge2.LastUpdate = edge1.LastUpdate.Add(time.Hour) + if err := graph.UpdateEdgePolicy(edge2); err != nil { + t.Fatalf("unable to update edge: %v", err) + } + + // With the policies updated, we should now be able to find their + // updated entries within the update index. + checkIndexTimestamps( + uint64(edge1.LastUpdate.Unix()), + uint64(edge2.LastUpdate.Unix()), + ) + // Now we'll prune the graph, removing the edges, and also the update // index entries from the database all together. var blockHash chainhash.Hash