From a9f1b341bee288c0a9e4d127851050e5f1bcd3e1 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 2 Apr 2021 15:44:49 -0700 Subject: [PATCH] discovery: update zombie resurrection test w/ new logic In this commit, we update the existing zombie resurrection test to ensure that if we prune an edge and another pubkey is marked as nil, that we only accept a resurrection channel update from the node the we originally pruned if the pruning decision was one sided. --- discovery/gossiper_test.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index a8b3154a..c12b9b53 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -397,7 +397,9 @@ func (r *mockGraphSource) MarkEdgeZombie(chanID lnwire.ShortChannelID, pubKey1, r.mu.Lock() defer r.mu.Unlock() + r.zombies[chanID.ToUint64()] = [][33]byte{pubKey1, pubKey2} + return nil } @@ -2317,15 +2319,34 @@ func TestProcessZombieEdgeNowLive(t *testing.T) { t.Fatalf("unable to sign update with new timestamp: %v", err) } - // We'll also add the edge to our zombie index. + // We'll also add the edge to our zombie index, provide a blank pubkey + // for the first node as we're simulating the sitaution where the first + // ndoe is updating but the second node isn't. In this case we only + // want to allow a new update from the second node to allow the entire + // edge to be resurrected. chanID := batch.chanAnn.ShortChannelID err = ctx.router.MarkEdgeZombie( - chanID, batch.chanAnn.NodeID1, batch.chanAnn.NodeID2, + chanID, [33]byte{}, batch.chanAnn.NodeID2, ) if err != nil { t.Fatalf("unable mark channel %v as zombie: %v", chanID, err) } + // If we send a new update but for the other direction of the channel, + // then it should still be rejected as we want a fresh update from the + // one that was considered stale. + batch.chanUpdAnn1.Timestamp = uint32(time.Now().Unix()) + if err := signUpdate(remoteKeyPriv1, batch.chanUpdAnn1); err != nil { + t.Fatalf("unable to sign update with new timestamp: %v", err) + } + processAnnouncement(batch.chanUpdAnn1, true, true) + + // At this point, the channel should still be consiered a zombie. + _, _, _, err = ctx.router.GetChannelByID(chanID) + if err != channeldb.ErrZombieEdge { + t.Fatalf("channel should still be a zombie") + } + // Attempting to process the current channel update should fail due to // its edge being considered a zombie and its timestamp not being within // the live horizon. We should not expect an error here since it is just