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.
This commit is contained in:
2 files changed
+6
-2
No files matched your search
@@ -28,7 +28,7 @@ func randPeer(t *testing.T, quit chan struct{}) *mockPeer {
|
|||||||
func peerWithPubkey(pk *btcec.PublicKey, quit chan struct{}) *mockPeer {
|
func peerWithPubkey(pk *btcec.PublicKey, quit chan struct{}) *mockPeer {
|
||||||
return &mockPeer{
|
return &mockPeer{
|
||||||
pk: pk,
|
pk: pk,
|
||||||
sentMsgs: make(chan lnwire.Message),
|
sentMsgs: make(chan lnwire.Message, 1),
|
||||||
quit: quit,
|
quit: quit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -483,7 +483,9 @@ func TestSyncManagerWaitUntilInitialHistoricalSync(t *testing.T) {
|
|||||||
// transition it to chansSynced to ensure the remaining syncers
|
// transition it to chansSynced to ensure the remaining syncers
|
||||||
// aren't started as active.
|
// aren't started as active.
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
assertSyncerStatus(t, s, syncingChans, PassiveSync)
|
assertSyncerStatus(
|
||||||
|
t, s, waitingQueryRangeReply, PassiveSync,
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -495,6 +495,8 @@ func (g *GossipSyncer) handleSyncingChans() {
|
|||||||
g.Lock()
|
g.Lock()
|
||||||
defer g.Unlock()
|
defer g.Unlock()
|
||||||
|
|
||||||
|
// Send the msg to the remote peer, which is non-blocking as
|
||||||
|
// `sendToPeer` only queues the msg in Brontide.
|
||||||
err = g.cfg.sendToPeer(queryRangeMsg)
|
err = g.cfg.sendToPeer(queryRangeMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Unable to send chan range query: %v", err)
|
log.Errorf("Unable to send chan range query: %v", err)
|
||||||
|
|||||||
Reference in new issue
Block a user