Initialize media history model and admit the purge test peer
This commit is contained in:
1 parent
316bacd8c8
commit
df39999624
3 files changed
+17
-8
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Tests Makefile.am for utun - all tests with new ll_queue library
|
||||
|
||||
EXTRA_DIST = fixtures/reality_openssl_hello.hex data/silero_speech.pcm data/silero_speech.txt test_net.h nat_fixture.h \
|
||||
EXTRA_DIST = fixtures/reality_openssl_hello.hex data/silero_speech.pcm data/silero_speech.txt test_net.h nat_fixture.h db_sync_fixture.h \
|
||||
run_tests.py test_run_tests.py test_service_ids.py test_build_script.py local_transport_ipv6.sh stream_netns/topology.py stream_netns/network.py \
|
||||
stream_netns/probe.py stream_netns/run.py stream_netns/scenario.py stream_netns/README.md stream_netns/TESTED.md \
|
||||
stream_netns/test_isolation.py stream_netns/nat_scenario.py stream_netns/stun_server.py stream_netns/stun_scenario.py
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "../lib/debug_config.h"
|
||||
#include "../lib/mem.h"
|
||||
#include "test_net.h"
|
||||
#include "db_sync_fixture.h"
|
||||
|
||||
#include <sqlite3.h>
|
||||
#define OPENSSL_API_COMPAT 0x10100000L
|
||||
@@ -496,7 +497,9 @@ static void setup_db_sync(void) {
|
||||
for (int i = 0; i < N_NODES; i++) {
|
||||
g_si[i] = db_sync_instance_add(g_inst[i], "msg_" CH_ID, g_group_id);
|
||||
if (!g_si[i]) { ok = 0; DEBUG_ERROR(DEBUG_CATEGORY_GENERAL, "[mdc] db_sync_instance_add failed node=%d", i); }
|
||||
else db_sync_instance_set_gated(g_si[i], 0);
|
||||
else if (setup_history_model(g_inst[i]) < 0) {
|
||||
ok = 0; DEBUG_ERROR(DEBUG_CATEGORY_GENERAL, "[mdc] history model registration failed node=%d", i);
|
||||
} else db_sync_instance_set_gated(g_si[i], 0);
|
||||
}
|
||||
if (ok) OK(); else FAIL();
|
||||
}
|
||||
@@ -713,7 +716,11 @@ int main(void) {
|
||||
|
||||
done:
|
||||
g_result = 1;
|
||||
for (int i = 0; i < N_NODES; i++) { if (g_inst[i]) { g_inst[i]->running = 0; utun_instance_destroy(g_inst[i]); g_inst[i] = NULL; } }
|
||||
for (int i = 0; i < N_NODES; i++) if (g_inst[i]) {
|
||||
g_inst[i]->running = 0;
|
||||
if (!g_inst[i]->chat_sync) merkle_sync_destroy(g_inst[i]);
|
||||
utun_instance_destroy(g_inst[i]); g_inst[i] = NULL;
|
||||
}
|
||||
if (g_ua) { uasync_destroy(g_ua, 0); g_ua = NULL; }
|
||||
debug_disable_file_output();
|
||||
if (!G_FAILED) t_rmdir(g_tdir);
|
||||
|
||||
@@ -270,20 +270,22 @@ static void purge_done(uint64_t peer, const char* channel, int result, void* arg
|
||||
|
||||
static void test_purge_start(struct UASYNC* ua) {
|
||||
struct purge_fixture f; purge_setup(&f, ua, 0); purge_bad(&f, 123);
|
||||
uint64_t peer = f.member.node_id;
|
||||
f.inst.connections = queue_new(ua, 16, 0, 8, "purge test connections"); assert(f.inst.connections);
|
||||
f.conn.instance = &f.inst; f.conn.peer_node_id = 2; f.conn.initialized = 1; f.conn.links_up = 1;
|
||||
f.conn.instance = &f.inst; f.conn.peer_node_id = peer; f.conn.initialized = 1; f.conn.links_up = 1;
|
||||
memcpy(f.conn.crypto_ctx.peer_public_key, f.x, 32);
|
||||
f.conn.send_input_q = queue_new(ua, 0, 0, 0, "purge test send"); assert(f.conn.send_input_q);
|
||||
queue_set_waiter_defer(f.conn.send_input_q, 1);
|
||||
struct ll_entry* e = queue_entry_new(sizeof(struct conn_queue_entry)); assert(e);
|
||||
struct conn_queue_entry* entry = (struct conn_queue_entry*)e->data; entry->peer_node_id = 2; entry->conn = &f.conn;
|
||||
struct conn_queue_entry* entry = (struct conn_queue_entry*)e->data; entry->peer_node_id = peer; entry->conn = &f.conn;
|
||||
assert(queue_data_put_with_index(f.inst.connections, e) == 0);
|
||||
int callbacks = 0;
|
||||
exec_fault = "COMMIT";
|
||||
assert(member_sync_start(&f.inst, 2, "1001", purge_done, &callbacks) < 0);
|
||||
assert(member_sync_start(&f.inst, peer, "1001", purge_done, &callbacks) < 0);
|
||||
reset_faults();
|
||||
assert(!f.conn.ref_count && !callbacks && member_sync_count(&f.inst, "1001") == 2);
|
||||
assert(member_sync_start(&f.inst, 2, "1001", purge_done, &callbacks) == 0 && f.conn.ref_count == 1);
|
||||
merkle_sync_cancel_peer(&f.inst, 2);
|
||||
assert(member_sync_start(&f.inst, peer, "1001", purge_done, &callbacks) == 0 && f.conn.ref_count == 1);
|
||||
merkle_sync_cancel_peer(&f.inst, peer);
|
||||
assert(!f.conn.ref_count && !callbacks && !f.conn.send_input_q->waiter_head);
|
||||
e = queue_data_get(f.inst.connections); assert(e); queue_entry_free(e);
|
||||
queue_free(f.inst.connections); f.inst.connections = NULL;
|
||||
|
||||
Reference in new issue
Block a user