diff --git a/tests/test_chat_profile.c b/tests/test_chat_profile.c index f69285bbe..8d02ae0cb 100644 --- a/tests/test_chat_profile.c +++ b/tests/test_chat_profile.c @@ -666,6 +666,17 @@ static void member_save_faults(struct UTUN_INSTANCE* inst) { assert(sqlite3_exec(inst->topo_sqlite_db, "BEGIN", NULL, NULL, NULL) == SQLITE_OK); assert(chat_core_save_member(inst, channel, inst->node_id, "foreign", "") < 0 && !sqlite3_get_autocommit(inst->topo_sqlite_db)); assert(sqlite3_exec(inst->topo_sqlite_db, "ROLLBACK", NULL, NULL, NULL) == SQLITE_OK); + for (int owner = 0; owner < 2; owner++) { + uint8_t before[32], after[32]; snapshot(reader, before); int running = inst->running; + target = owner ? "COMMIT /* tags */" : "COMMIT /* nickname */"; + fault = F_EXEC; fail_rollback = 1; inst->running = 1; + assert(chat_core_save_member(inst, channel, inst->node_id, "failed rollback", + owner ? "{\"owner_test\":\"failed rollback\"}" : "") < 0); + assert(fault == F_NONE && !fail_rollback && !inst->running && !sqlite3_get_autocommit(inst->topo_sqlite_db)); + snapshot(reader, after); assert(!memcmp(before, after, sizeof(before))); + target = NULL; assert(sqlite3_exec(inst->topo_sqlite_db, "ROLLBACK", NULL, NULL, NULL) == SQLITE_OK); + inst->running = running; + } printf("PASS member save:%u SQL failures/retries preserve nickname,owner signature and Merkle atomically\n", cases); }