multi: Allow selecting miner backend in itest
What changed, and why it matters
This commit is a testing-only change. It adds a command-line flag so integration tests can choose which Bitcoin mining software (btcd or bitcoind) is used behind the scenes. It also tweaks one test to calculate transaction size locally instead of asking the miner for it. There is no change to production LND code or user funds.
No security action required. Treat as a normal test-framework enhancement during routine review.
Security signals we found
No production code changes
Test infrastructure only
No cryptographic, network, or consensus logic altered
No privilege escalation or input validation changes
Evidence from the diff
The patch introduces a new minerbackend flag for integration tests, wires it through make/testing_flags.mk, and updates itest/lnd_test.go to pass a miner.MinerConfig into the test harness. A single test (itest/lnd_nonstd_sweep_test.go) is adjusted to compute transaction vsize from local weight ((weight+3)/4) rather than relying on GetRawTransactionVerbose from the miner, likely so the same assertion works regardless of whether btcd or bitcoind is the miner backend. No production code paths are modified.
Changed components
itest/lnd_test.goitest/lnd_nonstd_sweep_test.gomake/testing_flags.mkInspect captured patch +25 / −5
diff --git a/itest/lnd_nonstd_sweep_test.go b/itest/lnd_nonstd_sweep_test.go
index 1e20e2b..47725f1 100644
--- a/itest/lnd_nonstd_sweep_test.go
+++ b/itest/lnd_nonstd_sweep_test.go
@@ -123,12 +123,13 @@ func testNonStdSweepInner(ht *lntest.HarnessTest, address string) {
fee = inputVal - outputVal
- // Fetch the vsize of the transaction so we can determine if the
+ // Calculate the vsize of the transaction so we can determine if the
// transaction pays >= 1 sat/vbyte.
- rawTx := ht.Miner().GetRawTransactionVerbose(txid)
+ weight := ht.CalculateTxWeight(msgTx)
+ vbytes := (int64(weight) + 3) / 4
// Require fee >= vbytes.
- require.True(ht, fee >= int(rawTx.Vsize))
+ require.True(ht, int64(fee) >= vbytes)
// Mine a block to keep the mempool clean.
ht.MineBlocksAndAssertNumTxes(1, 1)
diff --git a/itest/lnd_test.go b/itest/lnd_test.go
index 32c0f1c..c073cb5 100644
--- a/itest/lnd_test.go
+++ b/itest/lnd_test.go
@@ -15,6 +15,7 @@ import (
"github.com/btcsuite/btcd/integration/rpctest"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lntest"
+ "github.com/lightningnetwork/lnd/lntest/miner"
"github.com/lightningnetwork/lnd/lntest/node"
"github.com/lightningnetwork/lnd/lntest/port"
"github.com/lightningnetwork/lnd/lntest/wait"
@@ -86,6 +87,12 @@ var (
lndExecutable = flag.String(
"lndexec", itestLndBinary, "full path to lnd binary",
)
+
+ // minerBackendFlag selects which miner backend to use. If not set, the
+ // default miner is btcd.
+ minerBackendFlag = flag.String(
+ "minerbackend", "", "miner backend (btcd, bitcoind)",
+ )
)
// TestLightningNetworkDaemon performs a series of integration tests amongst a
@@ -104,8 +111,15 @@ func TestLightningNetworkDaemon(t *testing.T) {
// Get the binary path and setup the harness test.
binary := getLndBinary(t)
- harnessTest := lntest.SetupHarness(
- t, binary, *dbBackendFlag, *nativeSQLFlag, feeService,
+ var minerCfg *miner.MinerConfig
+ if minerBackendFlag != nil && *minerBackendFlag != "" {
+ minerCfg = &miner.MinerConfig{
+ Backend: *minerBackendFlag,
+ }
+ }
+
+ harnessTest := lntest.SetupHarnessWithMinerConfig(
+ t, binary, *dbBackendFlag, *nativeSQLFlag, feeService, minerCfg,
)
defer harnessTest.Stop()
diff --git a/make/testing_flags.mk b/make/testing_flags.mk
index 95a4939..4f7bd42 100644
--- a/make/testing_flags.mk
+++ b/make/testing_flags.mk
@@ -69,6 +69,11 @@ ifneq ($(dbbackend),)
ITEST_FLAGS += -dbbackend=$(dbbackend)
endif
+# Select miner backend independently from chain backend. Defaults to btcd.
+ifneq ($(minerbackend),)
+ITEST_FLAGS += -minerbackend=$(minerbackend)
+endif
+
ifeq ($(dbbackend),etcd)
DEV_TAGS += kvdb_etcd
endif
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.