Expose transport queue control in media regression fixtures
This commit is contained in:
1 parent
5215163a37
commit
090e7db598
1 file changed
+8
-5
@@ -31,12 +31,13 @@
|
||||
|
||||
struct packet { uint64_t from, to, group; size_t len; uint8_t data[MAX_WIRE]; };
|
||||
static struct packet packets[128];
|
||||
static int packet_count, query_count, request_count, done_count, done_err, fail_send, fail_rng;
|
||||
static int packet_count, query_count, request_count, done_count, done_err, fail_send, fail_rng, capture_blocks;
|
||||
static struct UASYNC* ua;
|
||||
static char directory[256];
|
||||
static void* injected;
|
||||
static uint8_t* poison_tail;
|
||||
static uint8_t author_key[32] = {1};
|
||||
static void (*sent_hook)(struct UTUN_INSTANCE*, uint64_t, uint64_t, int);
|
||||
|
||||
int __real_RAND_bytes(unsigned char* out, int count);
|
||||
int __wrap_RAND_bytes(unsigned char* out, int count) {
|
||||
@@ -50,12 +51,13 @@ int __wrap_etcp_route_send(struct UTUN_INSTANCE* inst, uint64_t group, uint64_t
|
||||
int cmd = entry->dgram[1], rc = cmd == fail_send ? -1 : 0;
|
||||
if (cmd == MEDIA_SUBCMD_BLOCK_REQ) request_count++;
|
||||
if (cmd == MEDIA_SUBCMD_QUERY) query_count++;
|
||||
if (!rc && (cmd == MEDIA_SUBCMD_QUERY || cmd == MEDIA_SUBCMD_QUERY_RESP)) {
|
||||
if (!rc && (cmd == MEDIA_SUBCMD_QUERY || cmd == MEDIA_SUBCMD_QUERY_RESP || capture_blocks)) {
|
||||
REQUIRE(packet_count < 128 && entry->len - 1 <= MAX_WIRE);
|
||||
struct packet* p = &packets[packet_count++];
|
||||
p->from = inst->node_id; p->to = dst; p->group = group; p->len = entry->len - 1;
|
||||
memcpy(p->data, entry->dgram + 1, p->len);
|
||||
}
|
||||
if (!rc && sent_hook) sent_hook(inst, group, dst, cmd);
|
||||
queue_dgram_free(entry); queue_entry_free(entry); return rc;
|
||||
}
|
||||
|
||||
@@ -97,7 +99,7 @@ static struct UTUN_INSTANCE* instance(uint64_t node) {
|
||||
inst->ua = ua; inst->node_id = node;
|
||||
inst->chat_core = u_calloc(1, sizeof(struct chat_core_ctx)); REQUIRE(inst->chat_core);
|
||||
REQUIRE(sqlite3_open(":memory:", &inst->topo_sqlite_db) == SQLITE_OK);
|
||||
REQUIRE(!media_index_init(inst->topo_sqlite_db) && !media_delivery_init(inst));
|
||||
REQUIRE(!etcp_router_init(inst) && !media_index_init(inst->topo_sqlite_db) && !media_delivery_init(inst));
|
||||
uint8_t pubkey[32]; size_t length = sizeof(pubkey);
|
||||
EVP_PKEY* key = EVP_PKEY_new_raw_private_key(EVP_PKEY_ED25519, NULL, author_key, 32); REQUIRE(key);
|
||||
REQUIRE(EVP_PKEY_get_raw_public_key(key, pubkey, &length) == 1 && length == 32); EVP_PKEY_free(key);
|
||||
@@ -111,7 +113,7 @@ static struct UTUN_INSTANCE* instance(uint64_t node) {
|
||||
}
|
||||
|
||||
static void destroy(struct UTUN_INSTANCE* inst) {
|
||||
media_delivery_destroy(inst); sqlite3_close(inst->topo_sqlite_db);
|
||||
media_delivery_destroy(inst); etcp_router_destroy(inst); sqlite3_close(inst->topo_sqlite_db);
|
||||
u_free(inst->chat_core); u_free(inst); uasync_poll(ua, 0);
|
||||
}
|
||||
|
||||
@@ -154,7 +156,8 @@ static void seed(struct UTUN_INSTANCE* inst, const struct media_index_result* r,
|
||||
}
|
||||
|
||||
static void reset(void) {
|
||||
packet_count = query_count = request_count = done_count = done_err = fail_send = fail_rng = 0;
|
||||
packet_count = query_count = request_count = done_count = done_err = fail_send = fail_rng = capture_blocks = 0;
|
||||
sent_hook = NULL;
|
||||
}
|
||||
|
||||
static struct packet answer(struct UTUN_INSTANCE* server) {
|
||||
|
||||
Reference in new issue
Block a user