mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-13 11:09:23 +01:00
discovery: fix incorrect test, masked by loop scoping bug
When we first go to boot up the syncer, when we're in the active phase, after we do the historical sync, we'll send a timestamp message that we want everything, then transition to the passive mode. The test didn't account for this extra message before, as the last test was being re-used here (ran in parallel). We fix this by asserting that the first expected message is sent, then also the follow up messages as well.
This commit is contained in:
parent
b1eaeb6ac6
commit
206ad69b75
2 changed files with 24 additions and 5 deletions
|
@ -163,6 +163,8 @@ func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash,
|
|||
return nil, err
|
||||
}
|
||||
for _, nodeAnn := range nodeAnnsInHorizon {
|
||||
nodeAnn := nodeAnn
|
||||
|
||||
// Ensure we only forward nodes that are publicly advertised to
|
||||
// prevent leaking information about nodes.
|
||||
isNodePublic, err := c.graph.IsPublicNode(nodeAnn.PubKeyBytes)
|
||||
|
|
|
@ -2134,18 +2134,33 @@ func TestGossipSyncerSyncTransitions(t *testing.T) {
|
|||
name: "active to passive",
|
||||
entrySyncType: ActiveSync,
|
||||
finalSyncType: PassiveSync,
|
||||
assert: func(t *testing.T, msgChan chan []lnwire.Message,
|
||||
assert: func(t *testing.T, mChan chan []lnwire.Message,
|
||||
g *GossipSyncer) {
|
||||
|
||||
// When we first boot up, we expect that we
|
||||
// send out a message that indicates we want
|
||||
// all the updates from here on.
|
||||
firstTimestamp := uint32(time.Now().Unix())
|
||||
assertMsgSent(
|
||||
t, mChan, &lnwire.GossipTimestampRange{
|
||||
FirstTimestamp: firstTimestamp,
|
||||
TimestampRange: math.MaxUint32,
|
||||
},
|
||||
)
|
||||
|
||||
// When transitioning from active to passive, we
|
||||
// should expect to see a new local update
|
||||
// horizon sent to the remote peer indicating
|
||||
// that it would not like to receive any future
|
||||
// updates.
|
||||
assertMsgSent(t, msgChan, &lnwire.GossipTimestampRange{
|
||||
FirstTimestamp: uint32(zeroTimestamp.Unix()),
|
||||
TimestampRange: 0,
|
||||
})
|
||||
assertMsgSent(
|
||||
t, mChan, &lnwire.GossipTimestampRange{
|
||||
FirstTimestamp: uint32(
|
||||
zeroTimestamp.Unix(),
|
||||
),
|
||||
TimestampRange: 0,
|
||||
},
|
||||
)
|
||||
|
||||
syncState := g.syncState()
|
||||
if syncState != chansSynced {
|
||||
|
@ -2182,6 +2197,8 @@ func TestGossipSyncerSyncTransitions(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue