lnd_test: reverse the order of teardown for lnd and btcd harnesses
This commit prevents the case where btcd stops before lnd is fully started, thus making lnd_test hang on trying to stop lnd using `StopDaemon`. The underlying issue is that while lnd is trying to start the server and subscribe to block notifications from btcd, btcd stops, and lnd continues to attempt to reconnect before it ever starts the interrupt handler. This reversal avoids that issue by making sure lnd is stopped before btcd.
This commit is contained in:
parent
65dede2584
commit
a7218e84ea
17
lnd_test.go
17
lnd_test.go
@ -3128,7 +3128,19 @@ func TestLightningNetworkDaemon(t *testing.T) {
|
||||
if err != nil {
|
||||
ht.Fatalf("unable to create lightning network harness: %v", err)
|
||||
}
|
||||
defer lndHarness.TearDownAll()
|
||||
|
||||
// Set up teardowns. While it's easier to set up the lnd harness before
|
||||
// the btcd harness, they should be torn down in reverse order to
|
||||
// prevent certain types of hangs.
|
||||
var btcdHarness *rpctest.Harness
|
||||
defer func() {
|
||||
if lndHarness != nil {
|
||||
lndHarness.TearDownAll()
|
||||
}
|
||||
if btcdHarness != nil {
|
||||
btcdHarness.TearDown()
|
||||
}
|
||||
}()
|
||||
|
||||
handlers := &btcrpcclient.NotificationHandlers{
|
||||
OnTxAccepted: lndHarness.OnTxAccepted,
|
||||
@ -3157,11 +3169,10 @@ func TestLightningNetworkDaemon(t *testing.T) {
|
||||
// Transactions on the lightning network should always be standard to get
|
||||
// better guarantees of getting included in to blocks.
|
||||
args := []string{"--rejectnonstd"}
|
||||
btcdHarness, err := rpctest.New(harnessNetParams, handlers, args)
|
||||
btcdHarness, err = rpctest.New(harnessNetParams, handlers, args)
|
||||
if err != nil {
|
||||
ht.Fatalf("unable to create mining node: %v", err)
|
||||
}
|
||||
defer btcdHarness.TearDown()
|
||||
|
||||
// Turn off the btcd rpc logging, otherwise it will lead to panic.
|
||||
// TODO(andrew.shvv|roasbeef) Remove the hack after re-work the way the log
|
||||
|
Loading…
Reference in New Issue
Block a user