From 612d424196d68d26c098f2bc8e57e488556e183a Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Fri, 15 Aug 2025 09:59:21 +0200 Subject: [PATCH] graph/db: migration test for channels with no policies In preparation for making the channel & policy migration logic idempotent in a step-by-step manner, we add a test here that only tests the migration of channels _without_ policies so that we can first focus on just making the channel migration idempotent. --- graph/db/sql_migration_test.go | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/graph/db/sql_migration_test.go b/graph/db/sql_migration_test.go index b1be2a661..dc2e7e843 100644 --- a/graph/db/sql_migration_test.go +++ b/graph/db/sql_migration_test.go @@ -176,6 +176,60 @@ func TestMigrateGraphToSQL(t *testing.T) { }, expNotRetrySafety: true, }, + { + name: "channel with no policies", + write: writeUpdate, + objects: []any{ + // A channel with unknown nodes. This will + // result in two shell nodes being created. + // - channel count += 1 + // - node count += 2 + makeTestChannel(t), + + // Insert some nodes. + // - node count += 1 + makeTestNode(t, func(n *models.LightningNode) { + n.PubKeyBytes = node1 + }), + // - node count += 1 + makeTestNode(t, func(n *models.LightningNode) { + n.PubKeyBytes = node2 + }), + + // A channel with known nodes. + // - channel count += 1 + makeTestChannel( + t, func(c *models.ChannelEdgeInfo) { + c.ChannelID = chanID1 + + c.NodeKey1Bytes = node1 + c.NodeKey2Bytes = node2 + }, + ), + + // Insert a channel with no auth proof, no + // extra opaque data, and empty features. + // Use known nodes. + // - channel count += 1 + makeTestChannel( + t, func(c *models.ChannelEdgeInfo) { + c.ChannelID = chanID2 + + c.NodeKey1Bytes = node1 + c.NodeKey2Bytes = node2 + + c.AuthProof = nil + c.ExtraOpaqueData = nil + c.Features = testEmptyFeatures + }, + ), + }, + expGraphStats: graphStats{ + numNodes: 4, + numChannels: 3, + }, + expNotRetrySafety: true, + }, { name: "channels and policies", write: writeUpdate,