gossiper_test: combine local/remote chan ann

It will be the same announcement, no need to distinguish.
This commit is contained in:
Johan T. Halseth 2021-01-18 10:49:47 +01:00
parent f047c3517f
commit 4268bcc9f9
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -454,8 +454,7 @@ type annBatch struct {
nodeAnn1 *lnwire.NodeAnnouncement
nodeAnn2 *lnwire.NodeAnnouncement
localChanAnn *lnwire.ChannelAnnouncement
remoteChanAnn *lnwire.ChannelAnnouncement
chanAnn *lnwire.ChannelAnnouncement
chanUpdAnn1 *lnwire.ChannelUpdate
chanUpdAnn2 *lnwire.ChannelUpdate
@ -479,7 +478,7 @@ func createAnnouncements(blockHeight uint32) (*annBatch, error) {
return nil, err
}
batch.remoteChanAnn, err = createRemoteChannelAnnouncement(blockHeight)
batch.chanAnn, err = createRemoteChannelAnnouncement(blockHeight)
if err != nil {
return nil, err
}
@ -488,21 +487,16 @@ func createAnnouncements(blockHeight uint32) (*annBatch, error) {
ShortChannelID: lnwire.ShortChannelID{
BlockHeight: blockHeight,
},
NodeSignature: batch.remoteChanAnn.NodeSig2,
BitcoinSignature: batch.remoteChanAnn.BitcoinSig2,
}
batch.localChanAnn, err = createRemoteChannelAnnouncement(blockHeight)
if err != nil {
return nil, err
NodeSignature: batch.chanAnn.NodeSig2,
BitcoinSignature: batch.chanAnn.BitcoinSig2,
}
batch.localProofAnn = &lnwire.AnnounceSignatures{
ShortChannelID: lnwire.ShortChannelID{
BlockHeight: blockHeight,
},
NodeSignature: batch.localChanAnn.NodeSig1,
BitcoinSignature: batch.localChanAnn.BitcoinSig1,
NodeSignature: batch.chanAnn.NodeSig1,
BitcoinSignature: batch.chanAnn.BitcoinSig1,
}
batch.chanUpdAnn1, err = createUpdateAnnouncement(
@ -984,7 +978,7 @@ func TestSignatureAnnouncementLocalFirst(t *testing.T) {
// Recreate lightning network topology. Initialize router with channel
// between two nodes.
select {
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localChanAnn):
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.chanAnn):
case <-time.After(2 * time.Second):
t.Fatal("did not process local announcement")
}
@ -1208,7 +1202,7 @@ func TestOrphanSignatureAnnouncement(t *testing.T) {
// Recreate lightning network topology. Initialize router with channel
// between two nodes.
select {
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localChanAnn):
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.chanAnn):
case <-time.After(2 * time.Second):
t.Fatal("did not process local announcement")
}
@ -1380,7 +1374,7 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
// Recreate lightning network topology. Initialize router with channel
// between two nodes.
select {
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localChanAnn):
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.chanAnn):
case <-time.After(2 * time.Second):
t.Fatal("did not process local announcement")
}
@ -1594,7 +1588,7 @@ func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
// between two nodes.
select {
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
batch.localChanAnn,
batch.chanAnn,
):
case <-time.After(2 * time.Second):
t.Fatal("did not process local announcement")
@ -2161,7 +2155,7 @@ func TestRejectZombieEdge(t *testing.T) {
t.Helper()
errChan := ctx.gossiper.ProcessRemoteAnnouncement(
batch.remoteChanAnn, remotePeer,
batch.chanAnn, remotePeer,
)
select {
case err := <-errChan:
@ -2222,9 +2216,9 @@ func TestRejectZombieEdge(t *testing.T) {
// We'll mark the edge for which we'll process announcements for as a
// zombie within the router. This should reject any announcements for
// this edge while it remains as a zombie.
chanID := batch.remoteChanAnn.ShortChannelID
chanID := batch.chanAnn.ShortChannelID
err = ctx.router.MarkEdgeZombie(
chanID, batch.remoteChanAnn.NodeID1, batch.remoteChanAnn.NodeID2,
chanID, batch.chanAnn.NodeID1, batch.chanAnn.NodeID2,
)
if err != nil {
t.Fatalf("unable to mark channel %v as zombie: %v", chanID, err)
@ -2316,9 +2310,9 @@ func TestProcessZombieEdgeNowLive(t *testing.T) {
}
// We'll also add the edge to our zombie index.
chanID := batch.remoteChanAnn.ShortChannelID
chanID := batch.chanAnn.ShortChannelID
err = ctx.router.MarkEdgeZombie(
chanID, batch.remoteChanAnn.NodeID1, batch.remoteChanAnn.NodeID2,
chanID, batch.chanAnn.NodeID1, batch.chanAnn.NodeID2,
)
if err != nil {
t.Fatalf("unable mark channel %v as zombie: %v", chanID, err)
@ -2366,7 +2360,7 @@ func TestProcessZombieEdgeNowLive(t *testing.T) {
// We'll go ahead and process the channel announcement to ensure the
// channel update is processed thereafter.
processAnnouncement(batch.remoteChanAnn, false, false)
processAnnouncement(batch.chanAnn, false, false)
// After successfully processing the announcement, the channel update
// should have been processed and broadcast successfully as well.
@ -2465,7 +2459,7 @@ func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
// Recreate lightning network topology. Initialize router with channel
// between two nodes.
err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localChanAnn)
err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.chanAnn)
if err != nil {
t.Fatalf("unable to process :%v", err)
}
@ -2800,7 +2794,7 @@ func TestRetransmit(t *testing.T) {
// announcement. No messages should be broadcasted yet, since no proof
// has been exchanged.
assertProcessAnnouncement(
t, ctx.gossiper.ProcessLocalAnnouncement(batch.localChanAnn),
t, ctx.gossiper.ProcessLocalAnnouncement(batch.chanAnn),
)
assertBroadcast(t, ctx, 0)
@ -2931,7 +2925,7 @@ func TestNodeAnnouncementNoChannels(t *testing.T) {
// Now add the node's channel to the graph by processing the channel
// announement and channel update.
select {
case err = <-ctx.gossiper.ProcessRemoteAnnouncement(batch.remoteChanAnn,
case err = <-ctx.gossiper.ProcessRemoteAnnouncement(batch.chanAnn,
remotePeer):
case <-time.After(2 * time.Second):
t.Fatal("did not process remote announcement")
@ -3143,7 +3137,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
// Process the channel announcement for which we'll send a channel
// update for.
select {
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localChanAnn):
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.chanAnn):
case <-time.After(2 * time.Second):
t.Fatal("did not process local channel announcement")
}
@ -3500,7 +3494,7 @@ func TestPropagateChanPolicyUpdate(t *testing.T) {
// the gossiper in order for it to process. However, we'll hold back
// the channel ann proof from the first channel in order to have it be
// marked as private channel.
firstChanID := channelsToAnnounce[0].localChanAnn.ShortChannelID
firstChanID := channelsToAnnounce[0].chanAnn.ShortChannelID
for i, batch := range channelsToAnnounce {
// channelPoint ensures that each channel policy in the map
// returned by PropagateChanPolicyUpdate has a unique key. Since
@ -3508,7 +3502,7 @@ func TestPropagateChanPolicyUpdate(t *testing.T) {
// each channel has a unique channel point.
channelPoint := ChannelPoint(wire.OutPoint{Index: uint32(i)})
sendLocalMsg(t, ctx, batch.localChanAnn, channelPoint)
sendLocalMsg(t, ctx, batch.chanAnn, channelPoint)
sendLocalMsg(t, ctx, batch.chanUpdAnn1)
sendLocalMsg(t, ctx, batch.nodeAnn1)
@ -3517,7 +3511,7 @@ func TestPropagateChanPolicyUpdate(t *testing.T) {
// We'll skip sending the auth proofs from the first channel to
// ensure that it's seen as a private channel.
if batch.localChanAnn.ShortChannelID == firstChanID {
if batch.chanAnn.ShortChannelID == firstChanID {
continue
}
@ -3903,7 +3897,7 @@ func TestRateLimitChannelUpdates(t *testing.T) {
nodePeer1 := &mockPeer{nodeKeyPriv1.PubKey(), nil, nil}
select {
case err := <-ctx.gossiper.ProcessRemoteAnnouncement(
batch.remoteChanAnn, nodePeer1,
batch.chanAnn, nodePeer1,
):
require.NoError(t, err)
case <-time.After(time.Second):
@ -3938,7 +3932,7 @@ func TestRateLimitChannelUpdates(t *testing.T) {
}
}
shortChanID := batch.remoteChanAnn.ShortChannelID.ToUint64()
shortChanID := batch.chanAnn.ShortChannelID.ToUint64()
require.Contains(t, ctx.router.infos, shortChanID)
require.Contains(t, ctx.router.edges, shortChanID)