MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_primitives

Function test_primitives

wallet/test/run-db.c:112–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112static 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
146static bool test_vars(struct lightningd *ld)
147{

Callers 1

mainFunction · 0.70

Calls 4

db_exec_prepared_v2Function · 0.85
tal_freeFunction · 0.85
create_test_dbFunction · 0.70
db_commit_transactionFunction · 0.50

Tested by

no test coverage detected