Put an assertion inside db.c, and run every command we do (in testing) through
a `check` variant.
I inserted a deliberate bug (made addpsbtoutput call wallet_get_newindex()
before returning when running `check`, and indeed, backtrace as expected.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This avoids the mess where we override db_fatal for teqsts, and keeps it
generic.
Also allows us to get rid of one #if DEVELOPER, and an ugly global for
bookkeeper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
I couldn't figure out why my new SQL query was returning 0 rows,
and it was because we were ignoring errors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Avoids the following when postgres returns no query result:
==63458== Conditional jump or move depends on uninitialised value(s)
==63458== at 0x226A1F: db_postgres_step (db_postgres.c:156)
==63458== by 0x22535B: db_step (utils.c:155)
==63458== by 0x1E089A: db_data_version_get (exec.c:49)
==63458== by 0x194F6F: db_setup (db.c:1029)
==63458== by 0x199A2F: wallet_new (wallet.c:101)
==63458== by 0x154B70: main (lightningd.c:1035)
Changelog-None