diff --git a/lntest/itest/dcrlnd_maxio_test.go b/lntest/itest/dcrlnd_maxio_test.go index 96abaa2080..98b683cbde 100644 --- a/lntest/itest/dcrlnd_maxio_test.go +++ b/lntest/itest/dcrlnd_maxio_test.go @@ -11,6 +11,7 @@ import ( "github.com/decred/dcrd/dcrutil/v4" "github.com/decred/dcrlnd/lnrpc" "github.com/decred/dcrlnd/lntest" + "github.com/stretchr/testify/require" ) // testAddInvoiceMaxInboundAmt tests whether trying to add an invoice fails @@ -118,6 +119,10 @@ func testAddInvoiceMaxInboundAmt(net *lntest.NetworkHarness, t *harnessTest) { } } + peerReq := &lnrpc.PeerEventSubscription{} + carolPeerClient, err := carol.SubscribePeerEvents(ctxb, peerReq) + require.NoError(t.t, err) + // Disconnect the nodes from one another. While their channel remains open, // carol cannot receive payments (since bob is offline from her POV). err = net.DisconnectNodes(ctxb, carol, net.Bob) @@ -125,6 +130,12 @@ func testAddInvoiceMaxInboundAmt(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("unable to disconnect carol and bob: %v", err) } + // Wait to receive the PEER_OFFLINE event before trying to create the + // invoice. + peerEvent, err := carolPeerClient.Recv() + require.NoError(t.t, err) + require.Equal(t.t, lnrpc.PeerEvent_PEER_OFFLINE, peerEvent.GetType()) + // Now trying to add an invoice with an offline peer should fail. err = addInvoice(0, false) if err == nil { @@ -350,6 +361,10 @@ func testSendPaymentMaxOutboundAmt(net *lntest.NetworkHarness, t *harnessTest) { } } + peerReq := &lnrpc.PeerEventSubscription{} + carolPeerClient, err := carol.SubscribePeerEvents(ctxb, peerReq) + require.NoError(t.t, err) + // Disconnect the nodes from one another. While their channel remains // open, carol cannot send payments (since bob is offline from her // POV). @@ -358,6 +373,12 @@ func testSendPaymentMaxOutboundAmt(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("unable to disconnect carol and bob: %v", err) } + // Wait to receive the PEER_OFFLINE event before trying to create the + // invoice. + peerEvent, err := carolPeerClient.Recv() + require.NoError(t.t, err) + require.Equal(t.t, lnrpc.PeerEvent_PEER_OFFLINE, peerEvent.GetType()) + // Now trying to send a payment with an offline peer should fail. err = sendPayment(1) if err == nil {