Merge pull request #2117 from halseth/integration-tests-backend-logs
Save integration tests backend logs
This commit is contained in:
commit
8c5d6842c2
2
.gitignore
vendored
2
.gitignore
vendored
@ -29,7 +29,9 @@ lnd-debug
|
|||||||
lncli
|
lncli
|
||||||
lncli-debug
|
lncli-debug
|
||||||
|
|
||||||
|
# Integration test log files
|
||||||
output*.log
|
output*.log
|
||||||
|
/.backendlogs
|
||||||
|
|
||||||
cmd/cmd
|
cmd/cmd
|
||||||
*.key
|
*.key
|
||||||
|
52
lnd_test.go
52
lnd_test.go
@ -5545,26 +5545,6 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyFile(dest, src string) error {
|
|
||||||
s, err := os.Open(src)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer s.Close()
|
|
||||||
|
|
||||||
d, err := os.Create(dest)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := io.Copy(d, s); err != nil {
|
|
||||||
d.Close()
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return d.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
// waitForTxInMempool polls until finding one transaction in the provided
|
// waitForTxInMempool polls until finding one transaction in the provided
|
||||||
// miner's mempool. An error is returned if *one* transaction isn't found within
|
// miner's mempool. An error is returned if *one* transaction isn't found within
|
||||||
// the given timeout.
|
// the given timeout.
|
||||||
@ -6173,7 +6153,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// With the temporary file created, copy Bob's current state into the
|
// With the temporary file created, copy Bob's current state into the
|
||||||
// temporary file we created above. Later after more updates, we'll
|
// temporary file we created above. Later after more updates, we'll
|
||||||
// restore this state.
|
// restore this state.
|
||||||
if err := copyFile(bobTempDbFile, net.Bob.DBPath()); err != nil {
|
if err := lntest.CopyFile(bobTempDbFile, net.Bob.DBPath()); err != nil {
|
||||||
t.Fatalf("unable to copy database files: %v", err)
|
t.Fatalf("unable to copy database files: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6412,7 +6392,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
|
|||||||
// With the temporary file created, copy Carol's current state into the
|
// With the temporary file created, copy Carol's current state into the
|
||||||
// temporary file we created above. Later after more updates, we'll
|
// temporary file we created above. Later after more updates, we'll
|
||||||
// restore this state.
|
// restore this state.
|
||||||
if err := copyFile(carolTempDbFile, carol.DBPath()); err != nil {
|
if err := lntest.CopyFile(carolTempDbFile, carol.DBPath()); err != nil {
|
||||||
t.Fatalf("unable to copy database files: %v", err)
|
t.Fatalf("unable to copy database files: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6727,7 +6707,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
|
|||||||
// With the temporary file created, copy Carol's current state into the
|
// With the temporary file created, copy Carol's current state into the
|
||||||
// temporary file we created above. Later after more updates, we'll
|
// temporary file we created above. Later after more updates, we'll
|
||||||
// restore this state.
|
// restore this state.
|
||||||
if err := copyFile(carolTempDbFile, carol.DBPath()); err != nil {
|
if err := lntest.CopyFile(carolTempDbFile, carol.DBPath()); err != nil {
|
||||||
t.Fatalf("unable to copy database files: %v", err)
|
t.Fatalf("unable to copy database files: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7125,7 +7105,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// With the temporary file created, copy the current state into
|
// With the temporary file created, copy the current state into
|
||||||
// the temporary file we created above. Later after more
|
// the temporary file we created above. Later after more
|
||||||
// updates, we'll restore this state.
|
// updates, we'll restore this state.
|
||||||
if err := copyFile(tempDbFile, node.DBPath()); err != nil {
|
if err := lntest.CopyFile(tempDbFile, node.DBPath()); err != nil {
|
||||||
t.Fatalf("unable to copy database files: %v", err)
|
t.Fatalf("unable to copy database files: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12519,7 +12499,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)
|
||||||
@ -12529,7 +12515,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.
|
||||||
|
@ -3,7 +3,9 @@ package lntest
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -1289,3 +1291,24 @@ func (n *NetworkHarness) sendCoins(ctx context.Context, amt btcutil.Amount,
|
|||||||
expectedBalance := initialBalance.ConfirmedBalance + int64(amt)
|
expectedBalance := initialBalance.ConfirmedBalance + int64(amt)
|
||||||
return target.WaitForBalance(expectedBalance, true)
|
return target.WaitForBalance(expectedBalance, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CopyFile copies the file src to dest.
|
||||||
|
func CopyFile(dest, src string) error {
|
||||||
|
s, err := os.Open(src)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer s.Close()
|
||||||
|
|
||||||
|
d, err := os.Create(dest)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.Copy(d, s); err != nil {
|
||||||
|
d.Close()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return d.Close()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user