From 238052438e4da1071a63caf7baceeba362848e9b Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Fri, 15 Aug 2025 10:57:53 +0200 Subject: [PATCH] graph/db: let the rapid migration test also tests idempotency --- graph/db/sql_migration_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/graph/db/sql_migration_test.go b/graph/db/sql_migration_test.go index 977e5b772..1c3170488 100644 --- a/graph/db/sql_migration_test.go +++ b/graph/db/sql_migration_test.go @@ -1372,6 +1372,8 @@ func TestMigrateGraphToSQLRapid(t *testing.T) { // SQL store, generates random nodes and channels, populates the KV store, // runs the migration, and asserts that the SQL store contains the expected // state. +// +// The migration is run twice in order to test idempotency and retry-safety. func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T, dbFixture *sqldb.TestPgFixture, maxNumNodes, maxNumChannels int) { @@ -1522,6 +1524,15 @@ func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T, nodes: nodesSlice, chans: chanSetForState, }) + + // The migration is expected to be idempotent and retry-safe. So running + // it again should yield the same result. + err = MigrateGraphToSQL(ctx, sql.cfg, kvDB.db, sql.db) + require.NoError(t, err) + assertResultState(t, sql, dbState{ + nodes: nodesSlice, + chans: chanSetForState, + }) } // genRandomChannel is a rapid generator for creating random channel edge infos.