graph/db: let the rapid migration test also tests idempotency
What changed, and why it matters
This commit only adds a second run of an existing database migration inside a test, to verify the migration can be safely repeated without changing results. It is a test-only change and does not alter production code.
No security action needed; treat as routine test improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies graph/db/sql_migration_test.go to invoke MigrateGraphToSQL twice within testMigrateGraphToSQLRapidOnce and assert the same state after each run. No production logic, migration implementation, or error-handling behavior is changed. The commit message frames this as testing idempotency/retry-safety of the graph-to-SQL migration.
Changed components
graph/db/sql_migration_test.goInspect captured patch +11 / −0
diff --git a/graph/db/sql_migration_test.go b/graph/db/sql_migration_test.go
index 3833b8c..e68c443 100644
--- a/graph/db/sql_migration_test.go
+++ b/graph/db/sql_migration_test.go
@@ -1273,6 +1273,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) {
@@ -1423,6 +1425,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.
Why this scored 12/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.