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