| 110 | } |
| 111 | |
| 112 | static bool test_primitives(void) |
| 113 | { |
| 114 | struct db_stmt *stmt; |
| 115 | struct db *db = create_test_db(); |
| 116 | db_err = NULL; |
| 117 | db_begin_transaction(db); |
| 118 | CHECK(db->in_transaction); |
| 119 | db_commit_transaction(db); |
| 120 | CHECK(!db->in_transaction); |
| 121 | db_begin_transaction(db); |
| 122 | db_commit_transaction(db); |
| 123 | |
| 124 | db_begin_transaction(db); |
| 125 | stmt = db_prepare_v2(db, SQL("SELECT name FROM sqlite_master WHERE type='table';")); |
| 126 | CHECK_MSG(db_exec_prepared_v2(stmt), "db_exec_prepared must succeed"); |
| 127 | CHECK_MSG(!db_err, "Simple correct SQL command"); |
| 128 | tal_free(stmt); |
| 129 | |
| 130 | stmt = db_prepare_v2(db, SQL("not a valid SQL statement")); |
| 131 | CHECK_MSG(!db_exec_prepared_v2(stmt), "db_exec_prepared must fail"); |
| 132 | CHECK_MSG(db_err, "Failing SQL command"); |
| 133 | tal_free(stmt); |
| 134 | db_err = tal_free(db_err); |
| 135 | |
| 136 | /* We didn't migrate the DB, so don't have the vars table. Pretend we |
| 137 | * didn't change anything so we don't bump the data_version. */ |
| 138 | db->dirty = false; |
| 139 | db_commit_transaction(db); |
| 140 | CHECK(!db->in_transaction); |
| 141 | tal_free(db); |
| 142 | |
| 143 | return true; |
| 144 | } |
| 145 | |
| 146 | static bool test_vars(struct lightningd *ld) |
| 147 | { |
no test coverage detected