lnd_test+lntest: keep btcd debug logs from test run

Useful for debugging 🤷
This commit is contained in:
Johan T. Halseth 2018-10-10 13:04:13 +02:00
parent 3a2fd51f2f
commit 4d05e6bbd8
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -12516,7 +12516,13 @@ func TestLightningNetworkDaemon(t *testing.T) {
// setting of accepting non-standard transactions on simnet to reject them. // setting of accepting non-standard transactions on simnet to reject them.
// Transactions on the lightning network should always be standard to get // Transactions on the lightning network should always be standard to get
// better guarantees of getting included in to blocks. // 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{ handlers := &rpcclient.NotificationHandlers{
OnTxAccepted: func(hash *chainhash.Hash, amt btcutil.Amount) { OnTxAccepted: func(hash *chainhash.Hash, amt btcutil.Amount) {
lndHarness.OnTxAccepted(hash) lndHarness.OnTxAccepted(hash)
@ -12526,7 +12532,21 @@ func TestLightningNetworkDaemon(t *testing.T) {
if err != nil { if err != nil {
ht.Fatalf("unable to create mining node: %v", err) 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 // First create the network harness to gain access to its
// 'OnTxAccepted' call back. // 'OnTxAccepted' call back.