From 624ec6da27094ee81280d13a72d09618eb53ab55 Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Tue, 5 Mar 2019 00:39:21 +0100 Subject: [PATCH] tests: always call db_migrate() with non-NULL ld. This will be useful when we add hooks. For the moment, ld's contents is undefined, but this can easily be changed. --- wallet/test/run-db.c | 15 +++++++++------ wallet/test/run-wallet.c | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/wallet/test/run-db.c b/wallet/test/run-db.c index cb93ca8af..859f2ed58 100644 --- a/wallet/test/run-db.c +++ b/wallet/test/run-db.c @@ -51,14 +51,14 @@ static struct db *create_test_db(void) return db; } -static bool test_empty_db_migrate(void) +static bool test_empty_db_migrate(struct lightningd *ld) { struct db *db = create_test_db(); CHECK(db); db_begin_transaction(db); CHECK(db_get_version(db) == -1); db_commit_transaction(db); - db_migrate(NULL, db, NULL); + db_migrate(ld, db, NULL); db_begin_transaction(db); CHECK(db_get_version(db) == ARRAY_SIZE(dbmigrations) - 1); db_commit_transaction(db); @@ -91,12 +91,12 @@ static bool test_primitives(void) return true; } -static bool test_vars(void) +static bool test_vars(struct lightningd *ld) { struct db *db = create_test_db(); char *varname = "testvar"; CHECK(db); - db_migrate(NULL, db, NULL); + db_migrate(ld, db, NULL); db_begin_transaction(db); /* Check default behavior */ @@ -120,10 +120,13 @@ int main(void) setup_locale(); bool ok = true; + /* Dummy for migration hooks */ + struct lightningd *ld = tal(NULL, struct lightningd); - ok &= test_empty_db_migrate(); - ok &= test_vars(); + ok &= test_empty_db_migrate(ld); + ok &= test_vars(ld); ok &= test_primitives(); + tal_free(ld); return !ok; } diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 8fc3cafea..4fa50df36 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -671,7 +671,7 @@ static struct wallet *create_test_wallet(struct lightningd *ld, const tal_t *ctx w->bip32_base) == WALLY_OK); CHECK_MSG(w->db, "Failed opening the db"); - db_migrate(NULL, w->db, w->log); + db_migrate(ld, w->db, w->log); CHECK_MSG(!wallet_err, "DB migration failed"); w->max_channel_dbid = 0;