mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-04 09:58:39 +02:00
itest: update switch delivery tests with more robust reconnect logic
This commit is contained in:
parent
f7681cb51d
commit
a7f5b89cf3
@ -9,6 +9,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lntest"
|
||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// testSwitchCircuitPersistence creates a multihop network to ensure the sender
|
||||
@ -451,13 +452,23 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
t.Fatalf("htlc mismatch: %v", predErr)
|
||||
}
|
||||
|
||||
peerReq := &lnrpc.PeerEventSubscription{}
|
||||
peerClient, err := dave.SubscribePeerEvents(ctxb, peerReq)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
// First, disconnect Dave and Alice so that their link is broken.
|
||||
if err := net.DisconnectNodes(dave, net.Alice); err != nil {
|
||||
t.Fatalf("unable to disconnect alice from dave: %v", err)
|
||||
}
|
||||
|
||||
// Wait to receive the PEER_OFFLINE event before reconnecting them.
|
||||
peerEvent, err := peerClient.Recv()
|
||||
require.NoError(t.t, err)
|
||||
require.Equal(t.t, lnrpc.PeerEvent_PEER_OFFLINE, peerEvent.GetType())
|
||||
|
||||
// Then, reconnect them to ensure Dave doesn't just fail back the htlc.
|
||||
net.ConnectNodes(t.t, dave, net.Alice)
|
||||
// We use EnsureConnected here in case they have already re-connected.
|
||||
net.EnsureConnected(t.t, dave, net.Alice)
|
||||
|
||||
// Wait to ensure that the payment remain are not failed back after
|
||||
// reconnecting. All node should report the number payments initiated
|
||||
@ -476,6 +487,16 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
t.Fatalf("unable to disconnect alice from dave: %v", err)
|
||||
}
|
||||
|
||||
// Wait to receive the PEER_ONLINE and then the PEER_OFFLINE event
|
||||
// before advancing.
|
||||
peerEvent2, err := peerClient.Recv()
|
||||
require.NoError(t.t, err)
|
||||
require.Equal(t.t, lnrpc.PeerEvent_PEER_ONLINE, peerEvent2.GetType())
|
||||
|
||||
peerEvent3, err := peerClient.Recv()
|
||||
require.NoError(t.t, err)
|
||||
require.Equal(t.t, lnrpc.PeerEvent_PEER_OFFLINE, peerEvent3.GetType())
|
||||
|
||||
// Now restart carol without hodl mode, to settle back the outstanding
|
||||
// payments.
|
||||
carol.SetExtraArgs(nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user