diff --git a/tests/test_downgrade.py b/tests/test_downgrade.py index 1d8dcc809..2e0062e48 100644 --- a/tests/test_downgrade.py +++ b/tests/test_downgrade.py @@ -80,7 +80,7 @@ def test_downgrade(node_factory, executor): l1.daemon.executable = current_executable # Another downgrade is a noop. - assert subprocess.check_output(cmd_line).decode("utf8").startswith("Already compatible with ") + assert "Already compatible with " in subprocess.check_output(cmd_line).decode("utf8") # Should be able to upgrade without any trouble l1.daemon.opts['database-upgrade'] = True diff --git a/tools/lightning-downgrade.c b/tools/lightning-downgrade.c index 3bf41c6cb..2c76bf738 100644 --- a/tools/lightning-downgrade.c +++ b/tools/lightning-downgrade.c @@ -239,6 +239,12 @@ int main(int argc, char *argv[]) migrations = get_db_migrations(&num_migrations); prev_version = version_db(PREV_VERSION); + /* Do this even if the db hasn't changed. */ + if (!version_db(PREV_VERSION)->gossip_store_compatible) { + printf("Deleting incompatible gossip_store\n"); + unlink(path_join(tmpctx, net_dir, "gossip_store")); + } + /* Open db, check it's the expected version */ db = db_open(tmpctx, wallet_dsn, false, false, db_error, NULL); if (!db) @@ -290,11 +296,6 @@ int main(int argc, char *argv[]) printf("Downgrade to %s succeeded. Committing.\n", PREV_VERSION); db_commit_transaction(db); tal_free(db); - - if (!version_db(PREV_VERSION)->gossip_store_compatible) { - printf("Deleting incompatible gossip_store\n"); - unlink(path_join(tmpctx, net_dir, "gossip_store")); - } } /*** We don't actually perform migrations, so these are stubs which abort. ***/