Commit Graph

22 Commits

Author SHA1 Message Date
Elle Mouton
2c8ac0c92c graph/db: thread through reset call-backs
In preparation for handling retries on the source DB side, we thread
through the `reset` call-backs properly so that we can reset appropriate
variables.
2025-09-01 07:56:09 +02:00
Elle Mouton
aefc9118a4 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.
2025-09-01 07:56:09 +02:00
Elle Mouton
68e4970fbb graph/db: let migration test test retry safety
Currently, the graph SQL migration is not retry safe. Meaning that if
the source DB exeutes a retry under the hood, this could result in the
migration failing. In preparation for fixing this, we adust the
migration test accordingly.
2025-09-01 07:56:09 +02:00
Elle Mouton
9019bcaddf graph/db: let test policy have some extra opaque data
This will help us test idempotency later on, but it also ensures that
TestMigrateGraphToSQL is properly testing writes to the
graph_channel_policy_extra_types table.
2025-09-01 07:56:08 +02:00
Elle Mouton
b1deddec44 multi: remove DefaultQueryConfig
And always make use of either the new DefaultSQLiteConfig or
DefaultPostgresConfig.
2025-08-13 14:43:31 +02:00
Elle Mouton
8aa8c7cc42 multi: remove the NodeRTx interface type 2025-08-06 09:56:21 +02:00
Elle Mouton
1a60edbd33 make+graph/db: add -short helper and skip tests in short mode
In this commit, we add a makefile helper that can be used to add the
"-short" flag to the "go test" command when running unit tests via "make
unit ...".

Tests can then be expanded with a `testing.Short()` check to potentially
skip the test in short mode. This is useful for if a dev wants to
quickly run most of the tests in a package but would like to opt out of
running the longer form tests such as stress tests or rapid generation
tests.

This commit adds this check to two graph/db tests.
2025-08-05 06:34:38 +02:00
Elle Mouton
d7b8259a36 graph/db: add graph SQL migration rapid unit test 2025-07-15 18:17:23 +02:00
Elle Mouton
955f4c9182 graph/db: refactor to make postgres fixtures re-usable
In preparation for tests where we will want to spin up SQL DBs many
times, we do some refactoring so that it is easy to re-use postgres
fixtures since those are expensive to spin up.
2025-07-15 18:06:05 +02:00
Elle Mouton
21ac7ef6f4 multi: add reset to ForEachNode 2025-07-15 11:25:09 +02:00
Elle Mouton
88261834e5 graph/db: expose reset in ForEachChannel
Add a `reset` call-back param to the V1Store ForEachChannel method.
2025-07-15 11:23:26 +02:00
Elle Mouton
8b82a5c8fe graph/db: migrate zombie index to SQL
This commit expands `MigrateGraphToSQL` to include migration of the
zombie index.

NOTE: we take this opportunity to clean up the zombie index a bit by
first checking for each channel in the zombie index if it has been
marked as closed in the closed-scid index. If it has, then there is no
need to include it in the zombie index. A special case test for this
is added too.
2025-07-11 09:36:17 +02:00
Elle Mouton
0cb17bbbe5 graph/db: migrate closed SCID index
This commit expands `MigrateGraphToSQL` to include the migration of the
closed-scid index.
2025-07-11 09:36:14 +02:00
Elle Mouton
03ede9ccef graph/db: migrate prune log
This commit expands the `MigrateGraphToSQL` to include migration of the
prune log.
2025-07-11 09:15:47 +02:00
Elle Mouton
b7d4f80e3e graph/db: pass in ctx to test method
Fix compilation error.
2025-07-10 14:53:10 +02:00
Oliver Gugger
8ee661f18f Merge pull request #10043 from ellemouton/ctx3
multi: add context.Context param to more graphdb.V1Store methods
2025-07-10 13:40:51 +02:00
Elle Mouton
b58089049a graph/db: migrate channels and polices to SQL
In this commit, the `MigrateGraphToSQL` function is expanded to migrate
the channel and channe policy data. Both of these have the special case
where the kvdb store records may contain invalid TLV. If we encounter a
channel with invalid TLV, we skip it and its policies. If we encounter a
policy with invalid TLV, we skip it.

The `TestMigrateGraphToSQL` and `TestMigrationWithChannelDB` tests are
updated accordingly.
2025-07-09 10:18:57 +02:00
Elle Mouton
1e804a3d5f graph/db: let ForEachNode take a context 2025-07-08 15:11:02 +02:00
Elle Mouton
9657707175 graph/db: migrate source node to SQL store 2025-07-08 11:37:41 +02:00
Elle Mouton
8b2f4821d4 graph/db: migrate nodes to SQL store
This commit expands MigrateGraphToSQL so that it migrates all the graph
nodes from kvdb to SQL.

The TestMigrateGraphToSQL test is updated to cover the basic
LightningNode cases. A new test, `TestSQLMigrationEdgeCases`, is also
added and a case is added to tests the edge case where a node exists in
our kvdb store that has invalid TLV bytes.
2025-07-08 11:37:39 +02:00
Elle Mouton
5c09652e1a graph/db: add dev migration test helper
This commit was inspired by the invoices package
TestMigrationWithChannelDB test helper.

This test is purely for running locally to test the graph SQL migration.
It allows a dev to run the migration against a local `channel.sqlite` or
even `channel.db` file.
2025-07-07 13:35:30 +02:00
Elle Mouton
e3572e77c5 graph/db: add SQL migration function and test framework
In this commit, the basic framework for the graph SQL migration is
added. This sets us up for the commits to follow which will add
migration logic for each table in the graph commit by commit.
2025-07-07 13:34:19 +02:00