Merge pull request #8568 from bhandras/native-sql-ensure-empty-invoicedb

lnd: ensure that LND won't start in native SQL mode if it has any KV invoices
This commit is contained in:
Oliver Gugger authored and GitHub committed 2024-03-20 05:34:08 -06:00
commit 23f5f3cde5
6 files changed
+89 -3

No files matched your search

+4
View File
@@ -578,4 +578,8 @@ var allTestCases = []*lntest.TestCase{
Name: "open channel locked balance",
TestFunc: testOpenChannelLockedBalance,
},
{
Name: "nativesql no migration",
TestFunc: testNativeSQLNoMigration,
},
}
+39
View File
@@ -1,6 +1,7 @@
package itest
import (
"context"
"encoding/hex"
"fmt"
"io/ioutil"
@@ -1242,3 +1243,41 @@ func testSignVerifyMessageWithAddr(ht *lntest.HarnessTest) {
require.False(ht, respValid.Valid, "external signature did validate")
}
// testNativeSQLNoMigration tests that nodes that have invoices would not start
// up with native SQL enabled, as we don't currently support migration of KV
// invoices to the new SQL schema.
func testNativeSQLNoMigration(ht *lntest.HarnessTest) {
alice := ht.Alice
// Make sure we run the test with SQLite or Postgres.
if alice.Cfg.DBBackend != node.BackendSqlite &&
alice.Cfg.DBBackend != node.BackendPostgres {
ht.Skip("node not running with SQLite or Postgres")
}
// Skip the test if the node is already running with native SQL.
if alice.Cfg.NativeSQL {
ht.Skip("node already running with native SQL")
}
alice.RPC.AddInvoice(&lnrpc.Invoice{
Value: 10_000,
})
alice.SetExtraArgs([]string{"--db.use-native-sql"})
// Restart the node manually as we're really only interested in the
// startup error.
require.NoError(ht, alice.Stop())
require.NoError(ht, alice.StartLndCmd(context.Background()))
// We expect the node to fail to start up with native SQL enabled, as we
// have an invoice in the KV store.
require.Error(ht, alice.WaitForProcessExit())
// Reset the extra args and restart alice.
alice.SetExtraArgs(nil)
require.NoError(ht, alice.Start(ht.Context()))
}