From 4d05e6bbd8dd2f345ded746feee6aa1cf2ce7123 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Wed, 10 Oct 2018 13:04:13 +0200 Subject: [PATCH] lnd_test+lntest: keep btcd debug logs from test run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Useful for debugging 🤷 --- lnd_test.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lnd_test.go b/lnd_test.go index 681aa5f2..b8588cce 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -12516,7 +12516,13 @@ func TestLightningNetworkDaemon(t *testing.T) { // setting of accepting non-standard transactions on simnet to reject them. // Transactions on the lightning network should always be standard to get // better guarantees of getting included in to blocks. - args := []string{"--rejectnonstd", "--txindex"} + logDir := "./.backendlogs" + args := []string{ + "--rejectnonstd", + "--txindex", + "--debuglevel=debug", + "--logdir=" + logDir, + } handlers := &rpcclient.NotificationHandlers{ OnTxAccepted: func(hash *chainhash.Hash, amt btcutil.Amount) { lndHarness.OnTxAccepted(hash) @@ -12526,7 +12532,21 @@ func TestLightningNetworkDaemon(t *testing.T) { if err != nil { ht.Fatalf("unable to create mining node: %v", err) } - defer btcdHarness.TearDown() + defer func() { + btcdHarness.TearDown() + + // After shutting down the chain backend, we'll make a copy of + // the log file before deleting the temporary log dir. + logFile := logDir + "/" + harnessNetParams.Name + "/btcd.log" + err := lntest.CopyFile("./output_btcd_chainbackend.log", + logFile) + if err != nil { + fmt.Printf("unable to copy file: %v\n", err) + } + if err = os.RemoveAll(logDir); err != nil { + fmt.Printf("Cannot remove dir %s: %v\n", logDir, err) + } + }() // First create the network harness to gain access to its // 'OnTxAccepted' call back.