graph/db: let the rapid migration test also tests idempotency

This commit is contained in:
Elle Mouton
2025-08-15 10:57:53 +02:00
parent b6d48dd23c
commit 238052438e

View File

@@ -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.