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.
This commit is contained in:
Olaoluwa Osuntokun 2021-04-02 15:44:49 -07:00
parent 6c27de7d11
commit a9f1b341be
No known key found for this signature in database
GPG Key ID: 3BBD59E99B280306

@ -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