From 2edc3cf98f2caae5440a1e5cbd1ac710ec8b2127 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 3 Dec 2020 11:30:22 +0100 Subject: [PATCH] multi: update to latest btcd version With this commit we update btcd to the latest version which allows us to specify the btcd binary we want to use when spinning up a new node. --- chainntnfs/interface_test.go | 12 +++++++++--- chainntnfs/test_utils.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- lntest/btcd.go | 2 +- lntest/itest/lnd_test.go | 8 ++++---- lntest/node.go | 21 ++++++++++++++++++--- lnwallet/interface_test.go | 6 ++++-- routing/chainview/interface_test.go | 4 ++-- 9 files changed, 42 insertions(+), 19 deletions(-) diff --git a/chainntnfs/interface_test.go b/chainntnfs/interface_test.go index 504f19dc..70c4432e 100644 --- a/chainntnfs/interface_test.go +++ b/chainntnfs/interface_test.go @@ -1067,7 +1067,9 @@ func testReorgConf(miner *rpctest.Harness, notifier chainntnfs.TestChainNotifier, scriptDispatch bool, t *testing.T) { // Set up a new miner that we can use to cause a reorg. - miner2, err := rpctest.New(chainntnfs.NetParams, nil, []string{"--txindex"}) + miner2, err := rpctest.New( + chainntnfs.NetParams, nil, []string{"--txindex"}, "", + ) if err != nil { t.Fatalf("unable to create mining node: %v", err) } @@ -1247,7 +1249,9 @@ func testReorgSpend(miner *rpctest.Harness, } // Set up a new miner that we can use to cause a reorg. - miner2, err := rpctest.New(chainntnfs.NetParams, nil, []string{"--txindex"}) + miner2, err := rpctest.New( + chainntnfs.NetParams, nil, []string{"--txindex"}, "", + ) if err != nil { t.Fatalf("unable to create mining node: %v", err) } @@ -1592,7 +1596,9 @@ func testCatchUpOnMissedBlocksWithReorg(miner1 *rpctest.Harness, var wg sync.WaitGroup // Set up a new miner that we can use to cause a reorg. - miner2, err := rpctest.New(chainntnfs.NetParams, nil, []string{"--txindex"}) + miner2, err := rpctest.New( + chainntnfs.NetParams, nil, []string{"--txindex"}, "", + ) if err != nil { t.Fatalf("unable to create mining node: %v", err) } diff --git a/chainntnfs/test_utils.go b/chainntnfs/test_utils.go index a9d95eaa..c4350ec5 100644 --- a/chainntnfs/test_utils.go +++ b/chainntnfs/test_utils.go @@ -177,7 +177,7 @@ func NewMiner(t *testing.T, extraArgs []string, createChain bool, trickle := fmt.Sprintf("--trickleinterval=%v", TrickleInterval) extraArgs = append(extraArgs, trickle) - node, err := rpctest.New(NetParams, nil, extraArgs) + node, err := rpctest.New(NetParams, nil, extraArgs, "") if err != nil { t.Fatalf("unable to create backend node: %v", err) } diff --git a/go.mod b/go.mod index 998b54bf..f244d135 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/NebulousLabs/fastrand v0.0.0-20181203155948-6fb6489aac4e // indirect github.com/NebulousLabs/go-upnp v0.0.0-20180202185039-29b680b06c82 github.com/Yawning/aez v0.0.0-20180114000226-4dad034d9db2 - github.com/btcsuite/btcd v0.20.1-beta.0.20200903105316-61634447e719 + github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401 github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f github.com/btcsuite/btcutil v1.0.2 github.com/btcsuite/btcutil/psbt v1.0.3-0.20200826194809-5f93e33af2b0 diff --git a/go.sum b/go.sum index dd9d4d06..1b0312ca 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,8 @@ github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3/go.mod h1:3J08xEfcug github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.20.1-beta.0.20200513120220-b470eee47728/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.20.1-beta.0.20200903105316-61634447e719 h1:EVCN2/T2EhbccMSuV3iM6cVcVVYSzmsx4EP3fWgdFGQ= -github.com/btcsuite/btcd v0.20.1-beta.0.20200903105316-61634447e719/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= +github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401 h1:0tjUthKCaF8zwF9Qg7lfnep0xdo4n8WiFUfQPaMHX6g= +github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng= diff --git a/lntest/btcd.go b/lntest/btcd.go index e8b8cac4..d50c3803 100644 --- a/lntest/btcd.go +++ b/lntest/btcd.go @@ -88,7 +88,7 @@ func NewBackend(miner string, netParams *chaincfg.Params) ( // make sure they stay connected if it happens. "--nobanning", } - chainBackend, err := rpctest.New(netParams, nil, args) + chainBackend, err := rpctest.New(netParams, nil, args, GetBtcdBinary()) if err != nil { return nil, nil, fmt.Errorf("unable to create btcd node: %v", err) } diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index 33767c92..fc1ea24e 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -2471,8 +2471,8 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) { tempLogDir := fmt.Sprintf("%s/.tempminerlogs", lntest.GetLogDir()) logFilename := "output-open_channel_reorg-temp_miner.log" tempMiner, tempMinerCleanUp, err := lntest.NewMiner( - tempLogDir, logFilename, - harnessNetParams, &rpcclient.NotificationHandlers{}, + tempLogDir, logFilename, harnessNetParams, + &rpcclient.NotificationHandlers{}, lntest.GetBtcdBinary(), ) require.NoError(t.t, err, "failed to create temp miner") defer func() { @@ -14258,8 +14258,8 @@ func TestLightningNetworkDaemon(t *testing.T) { // We will also connect it to our chain backend. minerLogDir := fmt.Sprintf("%s/.minerlogs", logDir) miner, minerCleanUp, err := lntest.NewMiner( - minerLogDir, "output_btcd_miner.log", - harnessNetParams, &rpcclient.NotificationHandlers{}, + minerLogDir, "output_btcd_miner.log", harnessNetParams, + &rpcclient.NotificationHandlers{}, lntest.GetBtcdBinary(), ) require.NoError(t, err, "failed to create new miner") defer func() { diff --git a/lntest/node.go b/lntest/node.go index 2ea8e13a..b0eb63ce 100644 --- a/lntest/node.go +++ b/lntest/node.go @@ -78,6 +78,11 @@ var ( // goroutines of test nodes on failure. goroutineDump = flag.Bool("goroutinedump", false, "write goroutine dump from node n to file pprof-n.log") + + // btcdExecutable is the full path to the btcd binary. + btcdExecutable = flag.String( + "btcdexec", "", "full path to btcd binary", + ) ) // nextAvailablePort returns the first port that is available for listening by @@ -123,6 +128,16 @@ func GetLogDir() string { return "." } +// GetBtcdBinary returns the full path to the binary of the custom built btcd +// executable or an empty string if none is set. +func GetBtcdBinary() string { + if btcdExecutable != nil { + return *btcdExecutable + } + + return "" +} + // generateListeningPorts returns four ints representing ports to listen on // designated for the current lightning network test. This returns the next // available ports for the p2p, rpc, rest and profiling services. @@ -394,8 +409,8 @@ func newNode(cfg NodeConfig) (*HarnessNode, error) { // miner node's log dir. When tests finished, during clean up, its logs are // copied to a file specified as logFilename. func NewMiner(logDir, logFilename string, netParams *chaincfg.Params, - handler *rpcclient.NotificationHandlers) (*rpctest.Harness, - func() error, error) { + handler *rpcclient.NotificationHandlers, + btcdBinary string) (*rpctest.Harness, func() error, error) { args := []string{ "--rejectnonstd", @@ -407,7 +422,7 @@ func NewMiner(logDir, logFilename string, netParams *chaincfg.Params, "--trickleinterval=100ms", } - miner, err := rpctest.New(netParams, handler, args) + miner, err := rpctest.New(netParams, handler, args, btcdBinary) if err != nil { return nil, nil, fmt.Errorf( "unable to create mining node: %v", err, diff --git a/lnwallet/interface_test.go b/lnwallet/interface_test.go index c81abad5..09cd9c30 100644 --- a/lnwallet/interface_test.go +++ b/lnwallet/interface_test.go @@ -2187,7 +2187,7 @@ func testReorgWalletBalance(r *rpctest.Harness, w *lnwallet.LightningWallet, // Now we cause a reorganization as follows. // Step 1: create a new miner and start it. - r2, err := rpctest.New(r.ActiveNet, nil, []string{"--txindex"}) + r2, err := rpctest.New(r.ActiveNet, nil, []string{"--txindex"}, "") if err != nil { t.Fatalf("unable to create mining node: %v", err) } @@ -3093,7 +3093,9 @@ func TestLightningWallet(t *testing.T) { // dedicated miner to generate blocks, cause re-orgs, etc. We'll set // up this node with a chain length of 125, so we have plenty of BTC // to play around with. - miningNode, err := rpctest.New(netParams, nil, []string{"--txindex"}) + miningNode, err := rpctest.New( + netParams, nil, []string{"--txindex"}, "", + ) if err != nil { t.Fatalf("unable to create mining node: %v", err) } diff --git a/routing/chainview/interface_test.go b/routing/chainview/interface_test.go index 14f9461d..e790cdaa 100644 --- a/routing/chainview/interface_test.go +++ b/routing/chainview/interface_test.go @@ -540,7 +540,7 @@ func testFilterBlockDisconnected(node *rpctest.Harness, // Create a node that has a shorter chain than the main chain, so we // can trigger a reorg. - reorgNode, err := rpctest.New(netParams, nil, []string{"--txindex"}) + reorgNode, err := rpctest.New(netParams, nil, []string{"--txindex"}, "") if err != nil { t.Fatalf("unable to create mining node: %v", err) } @@ -902,7 +902,7 @@ func TestFilteredChainView(t *testing.T) { // dedicated miner to generate blocks, cause re-orgs, etc. We'll set up // this node with a chain length of 125, so we have plenty of BTC to // play around with. - miner, err := rpctest.New(netParams, nil, []string{"--txindex"}) + miner, err := rpctest.New(netParams, nil, []string{"--txindex"}, "") if err != nil { t.Fatalf("unable to create mining node: %v", err) }