Merge pull request #8052 from bhandras/sql-invoices

sqldb: `InvoiceDB` implementation
This commit is contained in:
Olaoluwa Osuntokun
2024-03-06 21:15:14 -06:00
committed by GitHub
39 changed files with 3129 additions and 1124 deletions

View File

@@ -103,14 +103,14 @@ type HarnessTest struct {
// NewHarnessTest creates a new instance of a harnessTest from a regular
// testing.T instance.
func NewHarnessTest(t *testing.T, lndBinary string, feeService WebFeeService,
dbBackend node.DatabaseBackend) *HarnessTest {
dbBackend node.DatabaseBackend, nativeSQL bool) *HarnessTest {
t.Helper()
// Create the run context.
ctxt, cancel := context.WithCancel(context.Background())
manager := newNodeManager(lndBinary, dbBackend)
manager := newNodeManager(lndBinary, dbBackend, nativeSQL)
return &HarnessTest{
T: t,

View File

@@ -31,6 +31,10 @@ type nodeManager struct {
// dbBackend sets the database backend to use.
dbBackend node.DatabaseBackend
// nativeSQL sets the database backend to use native SQL when
// applicable.
nativeSQL bool
// activeNodes is a map of all running nodes, format:
// {pubkey: *HarnessNode}.
activeNodes map[uint32]*node.HarnessNode
@@ -48,12 +52,13 @@ type nodeManager struct {
}
// newNodeManager creates a new node manager instance.
func newNodeManager(lndBinary string,
dbBackend node.DatabaseBackend) *nodeManager {
func newNodeManager(lndBinary string, dbBackend node.DatabaseBackend,
nativeSQL bool) *nodeManager {
return &nodeManager{
lndBinary: lndBinary,
dbBackend: dbBackend,
nativeSQL: nativeSQL,
activeNodes: make(map[uint32]*node.HarnessNode),
standbyNodes: make(map[uint32]*node.HarnessNode),
}
@@ -80,6 +85,7 @@ func (nm *nodeManager) newNode(t *testing.T, name string, extraArgs []string,
ExtraArgs: extraArgs,
FeeURL: nm.feeServiceURL,
DBBackend: nm.dbBackend,
NativeSQL: nm.nativeSQL,
NodeID: nm.nextNodeID(),
LndBinary: nm.lndBinary,
NetParams: harnessNetParams,

View File

@@ -18,7 +18,7 @@ import (
// 4. connect the miner and the chain backend.
// 5. start the HarnessTest.
func SetupHarness(t *testing.T, binaryPath, dbBackendName string,
feeService WebFeeService) *HarnessTest {
nativeSQL bool, feeService WebFeeService) *HarnessTest {
t.Log("Setting up HarnessTest...")
@@ -30,7 +30,7 @@ func SetupHarness(t *testing.T, binaryPath, dbBackendName string,
dbBackend := prepareDBBackend(t, dbBackendName)
// Create a new HarnessTest.
ht := NewHarnessTest(t, binaryPath, feeService, dbBackend)
ht := NewHarnessTest(t, binaryPath, feeService, dbBackend, nativeSQL)
// Init the miner.
t.Log("Prepare the miner and mine blocks to activate segwit...")

View File

@@ -119,6 +119,7 @@ type BaseNodeConfig struct {
DBBackend DatabaseBackend
PostgresDsn string
NativeSQL bool
// NodeID is a unique ID used to identify the node.
NodeID uint32
@@ -277,11 +278,17 @@ func (cfg *BaseNodeConfig) GenArgs() []string {
case BackendPostgres:
args = append(args, "--db.backend=postgres")
args = append(args, "--db.postgres.dsn="+cfg.PostgresDsn)
if cfg.NativeSQL {
args = append(args, "--db.use-native-sql")
}
case BackendSqlite:
args = append(args, "--db.backend=sqlite")
args = append(args, fmt.Sprintf("--db.sqlite.busytimeout=%v",
wait.SqliteBusyTimeout))
if cfg.NativeSQL {
args = append(args, "--db.use-native-sql")
}
}
if cfg.FeeURL != "" {