mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-08 05:08:13 +02:00
channeldb+lnd: set invoice bucket tombstone after migration
This commit introduces the functionality to set a tombstone key in the invoice bucket after the migration to the native SQL database. The tombstone prevents the user from switching back to the KV invoice database, ensuring data consistency and avoiding potential issues like lingering invoices or partial state in KV tables. The tombstone is checked on startup to block any manual overrides that attempt to revert the migration.
This commit is contained in:
@@ -103,3 +103,28 @@ func TestEncodeDecodeAmpInvoiceState(t *testing.T) {
|
||||
// The two states should match.
|
||||
require.Equal(t, ampState, ampState2)
|
||||
}
|
||||
|
||||
// TestInvoiceBucketTombstone tests the behavior of setting and checking the
|
||||
// invoice bucket tombstone. It verifies that the tombstone can be set correctly
|
||||
// and detected when present in the database.
|
||||
func TestInvoiceBucketTombstone(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Initialize a test database.
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err, "unable to initialize db")
|
||||
|
||||
// Ensure the tombstone doesn't exist initially.
|
||||
tombstoneExists, err := db.GetInvoiceBucketTombstone()
|
||||
require.NoError(t, err)
|
||||
require.False(t, tombstoneExists)
|
||||
|
||||
// Set the tombstone.
|
||||
err = db.SetInvoiceBucketTombstone()
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify that the tombstone exists after setting it.
|
||||
tombstoneExists, err = db.GetInvoiceBucketTombstone()
|
||||
require.NoError(t, err)
|
||||
require.True(t, tombstoneExists)
|
||||
}
|
||||
|
Reference in New Issue
Block a user