Skip to content

Commit 772a9d5

Browse files
committed
discovery: fix mocked peer in unit tests
The mocked peer used here blocks on `sendToPeer`, which is not the behavior of the `SendMessageLazy` of `lnpeer.Peer`. To reflect the reality, we now make sure the `sendToPeer` is non-blocking in the tests.
1 parent 9fecfed commit 772a9d5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

discovery/sync_manager_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func randPeer(t *testing.T, quit chan struct{}) *mockPeer {
2828
func peerWithPubkey(pk *btcec.PublicKey, quit chan struct{}) *mockPeer {
2929
return &mockPeer{
3030
pk: pk,
31-
sentMsgs: make(chan lnwire.Message),
31+
sentMsgs: make(chan lnwire.Message, 1),
3232
quit: quit,
3333
}
3434
}
@@ -483,7 +483,9 @@ func TestSyncManagerWaitUntilInitialHistoricalSync(t *testing.T) {
483483
// transition it to chansSynced to ensure the remaining syncers
484484
// aren't started as active.
485485
if i == 0 {
486-
assertSyncerStatus(t, s, syncingChans, PassiveSync)
486+
assertSyncerStatus(
487+
t, s, waitingQueryRangeReply, PassiveSync,
488+
)
487489
continue
488490
}
489491

discovery/syncer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ func (g *GossipSyncer) handleSyncingChans() {
495495
g.Lock()
496496
defer g.Unlock()
497497

498+
// Send the msg to the remote peer, which is non-blocking as
499+
// `sendToPeer` only queues the msg in Brontide.
498500
err = g.cfg.sendToPeer(queryRangeMsg)
499501
if err != nil {
500502
log.Errorf("Unable to send chan range query: %v", err)

0 commit comments

Comments
 (0)