discovery/gossiper: remove source pubkey from ProcessLocalAnnouncement params
This commit is contained in:
parent
69770f15e4
commit
f047c3517f
@ -574,7 +574,7 @@ func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message,
|
|||||||
// entire channel announcement and update messages will be re-constructed and
|
// entire channel announcement and update messages will be re-constructed and
|
||||||
// broadcast to the rest of the network.
|
// broadcast to the rest of the network.
|
||||||
func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message,
|
func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message,
|
||||||
source *btcec.PublicKey, optionalFields ...OptionalMsgField) chan error {
|
optionalFields ...OptionalMsgField) chan error {
|
||||||
|
|
||||||
optionalMsgFields := &optionalMsgFields{}
|
optionalMsgFields := &optionalMsgFields{}
|
||||||
optionalMsgFields.apply(optionalFields...)
|
optionalMsgFields.apply(optionalFields...)
|
||||||
@ -583,7 +583,7 @@ func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message,
|
|||||||
msg: msg,
|
msg: msg,
|
||||||
optionalMsgFields: optionalMsgFields,
|
optionalMsgFields: optionalMsgFields,
|
||||||
isRemote: false,
|
isRemote: false,
|
||||||
source: source,
|
source: d.selfKey,
|
||||||
err: make(chan error, 1),
|
err: make(chan error, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,10 +975,6 @@ func TestSignatureAnnouncementLocalFirst(t *testing.T) {
|
|||||||
t.Fatalf("can't generate announcements: %v", err)
|
t.Fatalf("can't generate announcements: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
localKey, err := btcec.ParsePubKey(batch.nodeAnn1.NodeID[:], btcec.S256())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
|
||||||
}
|
|
||||||
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
t.Fatalf("unable to parse pubkey: %v", err)
|
||||||
@ -988,9 +984,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(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localChanAnn):
|
||||||
batch.localChanAnn, localKey,
|
|
||||||
):
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
@ -1004,9 +998,7 @@ func TestSignatureAnnouncementLocalFirst(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.chanUpdAnn1):
|
||||||
batch.chanUpdAnn1, localKey,
|
|
||||||
):
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
@ -1020,9 +1012,7 @@ func TestSignatureAnnouncementLocalFirst(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.nodeAnn1):
|
||||||
batch.nodeAnn1, localKey,
|
|
||||||
):
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
@ -1080,9 +1070,7 @@ func TestSignatureAnnouncementLocalFirst(t *testing.T) {
|
|||||||
// Pretending that we receive local channel announcement from funding
|
// Pretending that we receive local channel announcement from funding
|
||||||
// manager, thereby kick off the announcement exchange process.
|
// manager, thereby kick off the announcement exchange process.
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localProofAnn):
|
||||||
batch.localProofAnn, localKey,
|
|
||||||
):
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
@ -1180,10 +1168,6 @@ func TestOrphanSignatureAnnouncement(t *testing.T) {
|
|||||||
t.Fatalf("can't generate announcements: %v", err)
|
t.Fatalf("can't generate announcements: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
localKey, err := btcec.ParsePubKey(batch.nodeAnn1.NodeID[:], btcec.S256())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
|
||||||
}
|
|
||||||
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
t.Fatalf("unable to parse pubkey: %v", err)
|
||||||
@ -1224,8 +1208,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.localChanAnn):
|
||||||
localKey):
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
@ -1241,8 +1224,7 @@ func TestOrphanSignatureAnnouncement(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.chanUpdAnn1,
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.chanUpdAnn1):
|
||||||
localKey):
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
@ -1257,9 +1239,7 @@ func TestOrphanSignatureAnnouncement(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.nodeAnn1):
|
||||||
batch.nodeAnn1, localKey,
|
|
||||||
):
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
@ -1316,8 +1296,7 @@ func TestOrphanSignatureAnnouncement(t *testing.T) {
|
|||||||
// After that we process local announcement, and waiting to receive
|
// After that we process local announcement, and waiting to receive
|
||||||
// the channel announcement.
|
// the channel announcement.
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localProofAnn,
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localProofAnn):
|
||||||
localKey):
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
@ -1379,10 +1358,6 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
|
|||||||
t.Fatalf("can't generate announcements: %v", err)
|
t.Fatalf("can't generate announcements: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
localKey, err := btcec.ParsePubKey(batch.nodeAnn1.NodeID[:], btcec.S256())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
|
||||||
}
|
|
||||||
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
t.Fatalf("unable to parse pubkey: %v", err)
|
||||||
@ -1405,9 +1380,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(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localChanAnn):
|
||||||
batch.localChanAnn, localKey,
|
|
||||||
):
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
@ -1424,7 +1397,7 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
|
|||||||
// manager, thereby kick off the announcement exchange process.
|
// manager, thereby kick off the announcement exchange process.
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
||||||
batch.localProofAnn, localKey,
|
batch.localProofAnn,
|
||||||
):
|
):
|
||||||
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")
|
||||||
@ -1599,10 +1572,6 @@ func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
|
|||||||
t.Fatalf("can't generate announcements: %v", err)
|
t.Fatalf("can't generate announcements: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
localKey, err := btcec.ParsePubKey(batch.nodeAnn1.NodeID[:], btcec.S256())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
|
||||||
}
|
|
||||||
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
t.Fatalf("unable to parse pubkey: %v", err)
|
||||||
@ -1625,7 +1594,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, localKey,
|
batch.localChanAnn,
|
||||||
):
|
):
|
||||||
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")
|
||||||
@ -1641,7 +1610,7 @@ func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
||||||
batch.chanUpdAnn1, localKey,
|
batch.chanUpdAnn1,
|
||||||
):
|
):
|
||||||
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")
|
||||||
@ -1664,7 +1633,7 @@ func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
||||||
batch.nodeAnn1, localKey,
|
batch.nodeAnn1,
|
||||||
):
|
):
|
||||||
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")
|
||||||
@ -1714,7 +1683,7 @@ func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
|
|||||||
// manager, thereby kick off the announcement exchange process.
|
// manager, thereby kick off the announcement exchange process.
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
||||||
batch.localProofAnn, localKey,
|
batch.localProofAnn,
|
||||||
):
|
):
|
||||||
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")
|
||||||
@ -2080,7 +2049,7 @@ func TestForwardPrivateNodeAnnouncement(t *testing.T) {
|
|||||||
pubKey := nodeKeyPriv1.PubKey()
|
pubKey := nodeKeyPriv1.PubKey()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case err := <-ctx.gossiper.ProcessLocalAnnouncement(chanAnn, pubKey):
|
case err := <-ctx.gossiper.ProcessLocalAnnouncement(chanAnn):
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to process local announcement: %v", err)
|
t.Fatalf("unable to process local announcement: %v", err)
|
||||||
}
|
}
|
||||||
@ -2102,7 +2071,7 @@ func TestForwardPrivateNodeAnnouncement(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case err := <-ctx.gossiper.ProcessLocalAnnouncement(nodeAnn, pubKey):
|
case err := <-ctx.gossiper.ProcessLocalAnnouncement(nodeAnn):
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to process remote announcement: %v", err)
|
t.Fatalf("unable to process remote announcement: %v", err)
|
||||||
}
|
}
|
||||||
@ -2436,10 +2405,6 @@ func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
|
|||||||
t.Fatalf("can't generate announcements: %v", err)
|
t.Fatalf("can't generate announcements: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
localKey, err := btcec.ParsePubKey(batch.nodeAnn1.NodeID[:], btcec.S256())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
|
||||||
}
|
|
||||||
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
t.Fatalf("unable to parse pubkey: %v", err)
|
||||||
@ -2500,7 +2465,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, localKey)
|
err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localChanAnn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to process :%v", err)
|
t.Fatalf("unable to process :%v", err)
|
||||||
}
|
}
|
||||||
@ -2510,7 +2475,7 @@ func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
|
|||||||
case <-time.After(2 * trickleDelay):
|
case <-time.After(2 * trickleDelay):
|
||||||
}
|
}
|
||||||
|
|
||||||
err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.chanUpdAnn1, localKey)
|
err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.chanUpdAnn1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to process :%v", err)
|
t.Fatalf("unable to process :%v", err)
|
||||||
}
|
}
|
||||||
@ -2520,7 +2485,7 @@ func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
|
|||||||
case <-time.After(2 * trickleDelay):
|
case <-time.After(2 * trickleDelay):
|
||||||
}
|
}
|
||||||
|
|
||||||
err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.nodeAnn1, localKey)
|
err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.nodeAnn1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to process :%v", err)
|
t.Fatalf("unable to process :%v", err)
|
||||||
}
|
}
|
||||||
@ -2570,9 +2535,7 @@ func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
|
|||||||
|
|
||||||
// Pretending that we receive local channel announcement from funding
|
// Pretending that we receive local channel announcement from funding
|
||||||
// manager, thereby kick off the announcement exchange process.
|
// manager, thereby kick off the announcement exchange process.
|
||||||
err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localProofAnn)
|
||||||
batch.localProofAnn, localKey,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to process :%v", err)
|
t.Fatalf("unable to process :%v", err)
|
||||||
}
|
}
|
||||||
@ -2827,10 +2790,6 @@ func TestRetransmit(t *testing.T) {
|
|||||||
t.Fatalf("can't generate announcements: %v", err)
|
t.Fatalf("can't generate announcements: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
localKey, err := btcec.ParsePubKey(batch.nodeAnn1.NodeID[:], btcec.S256())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
|
||||||
}
|
|
||||||
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
t.Fatalf("unable to parse pubkey: %v", err)
|
||||||
@ -2841,23 +2800,17 @@ 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(
|
t, ctx.gossiper.ProcessLocalAnnouncement(batch.localChanAnn),
|
||||||
batch.localChanAnn, localKey,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
assertBroadcast(t, ctx, 0)
|
assertBroadcast(t, ctx, 0)
|
||||||
|
|
||||||
assertProcessAnnouncement(
|
assertProcessAnnouncement(
|
||||||
t, ctx.gossiper.ProcessLocalAnnouncement(
|
t, ctx.gossiper.ProcessLocalAnnouncement(batch.chanUpdAnn1),
|
||||||
batch.chanUpdAnn1, localKey,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
assertBroadcast(t, ctx, 0)
|
assertBroadcast(t, ctx, 0)
|
||||||
|
|
||||||
assertProcessAnnouncement(
|
assertProcessAnnouncement(
|
||||||
t, ctx.gossiper.ProcessLocalAnnouncement(
|
t, ctx.gossiper.ProcessLocalAnnouncement(batch.nodeAnn1),
|
||||||
batch.nodeAnn1, localKey,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
assertBroadcast(t, ctx, 0)
|
assertBroadcast(t, ctx, 0)
|
||||||
|
|
||||||
@ -2873,9 +2826,7 @@ func TestRetransmit(t *testing.T) {
|
|||||||
// Now add the local and remote proof to the gossiper, which should
|
// Now add the local and remote proof to the gossiper, which should
|
||||||
// trigger a broadcast of the announcements.
|
// trigger a broadcast of the announcements.
|
||||||
assertProcessAnnouncement(
|
assertProcessAnnouncement(
|
||||||
t, ctx.gossiper.ProcessLocalAnnouncement(
|
t, ctx.gossiper.ProcessLocalAnnouncement(batch.localProofAnn),
|
||||||
batch.localProofAnn, localKey,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
assertBroadcast(t, ctx, 0)
|
assertBroadcast(t, ctx, 0)
|
||||||
|
|
||||||
@ -3145,10 +3096,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
|
|||||||
|
|
||||||
// We'll also create two keys, one for ourselves and another for the
|
// We'll also create two keys, one for ourselves and another for the
|
||||||
// remote party.
|
// remote party.
|
||||||
localKey, err := btcec.ParsePubKey(batch.nodeAnn1.NodeID[:], btcec.S256())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
|
||||||
}
|
|
||||||
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
remoteKey, err := btcec.ParsePubKey(batch.nodeAnn2.NodeID[:], btcec.S256())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to parse pubkey: %v", err)
|
t.Fatalf("unable to parse pubkey: %v", err)
|
||||||
@ -3195,9 +3143,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(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.localChanAnn):
|
||||||
batch.localChanAnn, localKey,
|
|
||||||
):
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
@ -3214,9 +3160,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
|
|||||||
|
|
||||||
// Now, we'll process the channel update.
|
// Now, we'll process the channel update.
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(batch.chanUpdAnn1):
|
||||||
batch.chanUpdAnn1, localKey,
|
|
||||||
):
|
|
||||||
case <-time.After(2 * time.Second):
|
case <-time.After(2 * time.Second):
|
||||||
t.Fatal("did not process local channel update")
|
t.Fatal("did not process local channel update")
|
||||||
}
|
}
|
||||||
@ -3277,7 +3221,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
|
|||||||
// With the new update created, we'll go ahead and process it.
|
// With the new update created, we'll go ahead and process it.
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
||||||
batch.chanUpdAnn1, localKey,
|
batch.chanUpdAnn1,
|
||||||
):
|
):
|
||||||
case <-time.After(2 * time.Second):
|
case <-time.After(2 * time.Second):
|
||||||
t.Fatal("did not process local channel update")
|
t.Fatal("did not process local channel update")
|
||||||
@ -3318,7 +3262,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
|
|||||||
// the channel.
|
// the channel.
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
||||||
batch.localProofAnn, localKey,
|
batch.localProofAnn,
|
||||||
):
|
):
|
||||||
case <-time.After(2 * time.Second):
|
case <-time.After(2 * time.Second):
|
||||||
t.Fatal("did not process local channel proof")
|
t.Fatal("did not process local channel proof")
|
||||||
@ -3375,7 +3319,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
|
|||||||
// not announced.
|
// not announced.
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
||||||
newChannelUpdate, localKey,
|
newChannelUpdate,
|
||||||
):
|
):
|
||||||
case <-time.After(2 * time.Second):
|
case <-time.After(2 * time.Second):
|
||||||
t.Fatal("did not process local channel update")
|
t.Fatal("did not process local channel update")
|
||||||
@ -3448,14 +3392,14 @@ func TestSendChannelUpdateReliably(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sendLocalMsg(t *testing.T, ctx *testCtx, msg lnwire.Message,
|
func sendLocalMsg(t *testing.T, ctx *testCtx, msg lnwire.Message,
|
||||||
localPub *btcec.PublicKey, optionalMsgFields ...OptionalMsgField) {
|
optionalMsgFields ...OptionalMsgField) {
|
||||||
|
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
select {
|
select {
|
||||||
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
case err = <-ctx.gossiper.ProcessLocalAnnouncement(
|
||||||
msg, localPub, optionalMsgFields...,
|
msg, optionalMsgFields...,
|
||||||
):
|
):
|
||||||
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")
|
||||||
@ -3529,7 +3473,6 @@ func TestPropagateChanPolicyUpdate(t *testing.T) {
|
|||||||
channelsToAnnounce = append(channelsToAnnounce, newChan)
|
channelsToAnnounce = append(channelsToAnnounce, newChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
localKey := nodeKeyPriv1.PubKey()
|
|
||||||
remoteKey := nodeKeyPriv2.PubKey()
|
remoteKey := nodeKeyPriv2.PubKey()
|
||||||
|
|
||||||
sentMsgs := make(chan lnwire.Message, 10)
|
sentMsgs := make(chan lnwire.Message, 10)
|
||||||
@ -3565,9 +3508,9 @@ 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, localKey, channelPoint)
|
sendLocalMsg(t, ctx, batch.localChanAnn, channelPoint)
|
||||||
sendLocalMsg(t, ctx, batch.chanUpdAnn1, localKey)
|
sendLocalMsg(t, ctx, batch.chanUpdAnn1)
|
||||||
sendLocalMsg(t, ctx, batch.nodeAnn1, localKey)
|
sendLocalMsg(t, ctx, batch.nodeAnn1)
|
||||||
|
|
||||||
sendRemoteMsg(t, ctx, batch.chanUpdAnn2, remotePeer)
|
sendRemoteMsg(t, ctx, batch.chanUpdAnn2, remotePeer)
|
||||||
sendRemoteMsg(t, ctx, batch.nodeAnn2, remotePeer)
|
sendRemoteMsg(t, ctx, batch.nodeAnn2, remotePeer)
|
||||||
@ -3578,7 +3521,7 @@ func TestPropagateChanPolicyUpdate(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
sendLocalMsg(t, ctx, batch.localProofAnn, localKey)
|
sendLocalMsg(t, ctx, batch.localProofAnn)
|
||||||
sendRemoteMsg(t, ctx, batch.remoteProofAnn, remotePeer)
|
sendRemoteMsg(t, ctx, batch.remoteProofAnn, remotePeer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3702,7 +3645,6 @@ func TestProcessChannelAnnouncementOptionalMsgFields(t *testing.T) {
|
|||||||
|
|
||||||
chanAnn1 := createAnnouncementWithoutProof(100)
|
chanAnn1 := createAnnouncementWithoutProof(100)
|
||||||
chanAnn2 := createAnnouncementWithoutProof(101)
|
chanAnn2 := createAnnouncementWithoutProof(101)
|
||||||
localKey := nodeKeyPriv1.PubKey()
|
|
||||||
|
|
||||||
// assertOptionalMsgFields is a helper closure that ensures the optional
|
// assertOptionalMsgFields is a helper closure that ensures the optional
|
||||||
// message fields were set as intended.
|
// message fields were set as intended.
|
||||||
@ -3727,7 +3669,7 @@ func TestProcessChannelAnnouncementOptionalMsgFields(t *testing.T) {
|
|||||||
|
|
||||||
// We'll process the first announcement without any optional fields. We
|
// We'll process the first announcement without any optional fields. We
|
||||||
// should see the channel's capacity and outpoint have a zero value.
|
// should see the channel's capacity and outpoint have a zero value.
|
||||||
sendLocalMsg(t, ctx, chanAnn1, localKey)
|
sendLocalMsg(t, ctx, chanAnn1)
|
||||||
assertOptionalMsgFields(chanAnn1.ShortChannelID, 0, wire.OutPoint{})
|
assertOptionalMsgFields(chanAnn1.ShortChannelID, 0, wire.OutPoint{})
|
||||||
|
|
||||||
// Providing the capacity and channel point as optional fields should
|
// Providing the capacity and channel point as optional fields should
|
||||||
@ -3735,7 +3677,7 @@ func TestProcessChannelAnnouncementOptionalMsgFields(t *testing.T) {
|
|||||||
capacity := btcutil.Amount(1000)
|
capacity := btcutil.Amount(1000)
|
||||||
channelPoint := wire.OutPoint{Index: 1}
|
channelPoint := wire.OutPoint{Index: 1}
|
||||||
sendLocalMsg(
|
sendLocalMsg(
|
||||||
t, ctx, chanAnn2, localKey, ChannelCapacity(capacity),
|
t, ctx, chanAnn2, ChannelCapacity(capacity),
|
||||||
ChannelPoint(channelPoint),
|
ChannelPoint(channelPoint),
|
||||||
)
|
)
|
||||||
assertOptionalMsgFields(chanAnn2.ShortChannelID, capacity, channelPoint)
|
assertOptionalMsgFields(chanAnn2.ShortChannelID, capacity, channelPoint)
|
||||||
@ -3880,9 +3822,7 @@ func TestBroadcastAnnsAfterGraphSynced(t *testing.T) {
|
|||||||
msg, nodePeer,
|
msg, nodePeer,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
errChan = ctx.gossiper.ProcessLocalAnnouncement(
|
errChan = ctx.gossiper.ProcessLocalAnnouncement(msg)
|
||||||
msg, nodePeer.pk,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
11
server.go
11
server.go
@ -1026,13 +1026,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement, error) {
|
CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement, error) {
|
||||||
return s.genNodeAnnouncement(true)
|
return s.genNodeAnnouncement(true)
|
||||||
},
|
},
|
||||||
SendAnnouncement: func(msg lnwire.Message,
|
SendAnnouncement: s.authGossiper.ProcessLocalAnnouncement,
|
||||||
optionalFields ...discovery.OptionalMsgField) chan error {
|
|
||||||
|
|
||||||
return s.authGossiper.ProcessLocalAnnouncement(
|
|
||||||
msg, nodeKeyECDH.PubKey(), optionalFields...,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
NotifyWhenOnline: s.NotifyWhenOnline,
|
NotifyWhenOnline: s.NotifyWhenOnline,
|
||||||
TempChanIDSeed: chanIDSeed,
|
TempChanIDSeed: chanIDSeed,
|
||||||
FindChannel: func(chanID lnwire.ChannelID) (
|
FindChannel: func(chanID lnwire.ChannelID) (
|
||||||
@ -3792,8 +3786,7 @@ func (s *server) fetchLastChanUpdate() func(lnwire.ShortChannelID) (
|
|||||||
// applyChannelUpdate applies the channel update to the different sub-systems of
|
// applyChannelUpdate applies the channel update to the different sub-systems of
|
||||||
// the server.
|
// the server.
|
||||||
func (s *server) applyChannelUpdate(update *lnwire.ChannelUpdate) error {
|
func (s *server) applyChannelUpdate(update *lnwire.ChannelUpdate) error {
|
||||||
pubKey := s.identityECDH.PubKey()
|
errChan := s.authGossiper.ProcessLocalAnnouncement(update)
|
||||||
errChan := s.authGossiper.ProcessLocalAnnouncement(update, pubKey)
|
|
||||||
select {
|
select {
|
||||||
case err := <-errChan:
|
case err := <-errChan:
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user