diff --git a/src/media_delivery/media_delivery.c b/src/media_delivery/media_delivery.c index a390985a0..d54502c21 100644 --- a/src/media_delivery/media_delivery.c +++ b/src/media_delivery/media_delivery.c @@ -559,11 +559,6 @@ int md_send(struct UTUN_INSTANCE* inst, uint64_t group_id, uint64_t dst_node_id, DEBUG_WARN(DEBUG_CATEGORY_MEDIA, "%s: send denied group=%llx peer=%llx cmd=%u", MD_ID, (unsigned long long)group_id, (unsigned long long)dst_node_id, data[0]); return -1; } - struct TOPO_GROUP* grp = inst->topo_groups ? topo_groups_find(inst->topo_groups, group_id) : NULL; - struct ETCP_CONN* conn = grp ? topo_group_find_conn_for_node(grp, dst_node_id) : NULL; - if (!conn) - DEBUG_WARN(DEBUG_CATEGORY_MEDIA, "%s: no conn to 0x%016llx group=0x%016llx subcmd=0x%02x — packet queued, no route", - MD_ID, (unsigned long long)dst_node_id, (unsigned long long)group_id, (unsigned)data[0]); struct ll_entry* e = queue_entry_new(0); if (!e) { DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "%s: send entry allocation failed", MD_ID); return -1; } e->dgram = u_malloc(len + 1); diff --git a/tests/test_bgp_paths.c b/tests/test_bgp_paths.c index 6a320ee6f..16e6ce493 100644 --- a/tests/test_bgp_paths.c +++ b/tests/test_bgp_paths.c @@ -67,7 +67,7 @@ static int step(void) { const struct SVC_ROUTE_HDR* header = (const struct SVC_ROUTE_HDR*)e->dgram; size_t body = e->len - count * 8 - 1; if ((header->svc_id == ETCP_RT_ID_CALL_AUDIO || header->svc_id == ETCP_RT_ID_CALL_VIDEO) - && body > SVC_ROUTE_HDR_SIZE && a != 0 && a != 3) { + && body > SVC_ROUTE_HDR_SIZE + SC_SIGN_SIZE && a != 0 && a != 3) { assert(header->flags == (ROUTER_FLAG_SIGNED | ROUTER_FLAG_ENCRYPTED)); uint8_t* decoded = NULL, flags = 0; size_t decoded_size = 0; assert(route_crypto_decode(nodes[a], e->dgram, body, &decoded, &decoded_size, &flags) == -1 && !decoded); diff --git a/tests/test_media_index_regressions.c b/tests/test_media_index_regressions.c index 3999116f2..661b0ba86 100644 --- a/tests/test_media_index_regressions.c +++ b/tests/test_media_index_regressions.c @@ -10,6 +10,7 @@ #include "../src/chat/chat_core_priv.h" #include "../src/chat/chat_event.h" #include "test_utils.h" +#include "test_membership.h" #include #include #include @@ -258,26 +259,32 @@ static void pending_deletion(void) { /* Отказ/синхронное завершение/дубликат имеют разные правила владения аргументом. */ uint8_t signatures[128] = {0}; struct media_index_result download = result; download.block_sigs = signatures; int completed = 0; - assert(media_download_start(inst, 0, &download, destinations[0], root, 0, download_done, &completed, NULL, NULL) == -1); + uint64_t group = strtoull(channel, NULL, 10); + assert(test_member_seed(inst, channel, inst->my_keys.public_key, inst->my_ed25519_pubkey, + inst->my_ed25519_privkey, recreate.ed25519_privkey, "{}", NULL, NULL) >= 0); + assert(media_download_start(inst, 0, &download, destinations[0], root, inst->node_id, + download_done, &completed, NULL, NULL) == -1 && !completed); // Несуществующая группа. + assert(media_download_start(inst, group, &download, destinations[0], root, 0, download_done, &completed, NULL, NULL) == -1); assert(!completed); /* Отсутствующий ключ автора — отказ до принятия владения callback. */ - assert(!media_download_start(inst, 0, &download, destinations[0], root, inst->node_id, + assert(!media_download_start(inst, group, &download, destinations[0], root, inst->node_id, download_done, &completed, NULL, NULL)); assert(completed == 1); /* Нет суперузлов: completion уже вызван, dl освобождён. */ - assert(!media_index_delete_channel(db, "0", root)); + assert(!media_index_delete_channel(db, channel, root)); completed = 0; - sqlite3_stmt* author = NULL; - assert(!sqlite3_prepare_v2(db, "INSERT INTO nodes(node_id,ed25519_pubkey,x25519_pubkey) VALUES(?,?,zeroblob(32))", - -1, &author, NULL)); - assert(!sqlite3_bind_int64(author, 1, (sqlite3_int64)(inst->node_id ^ 0x55))); - assert(!sqlite3_bind_blob(author, 2, inst->my_ed25519_pubkey, 32, SQLITE_STATIC)); - assert(sqlite3_step(author) == SQLITE_DONE && !sqlite3_finalize(author)); - assert(!media_download_start(inst, 0, &download, destinations[0], root, inst->node_id ^ 0x55, + struct SC_MYKEYS author_keys; uint8_t author_ed[32], author_private[64]; + assert(sc_generate_keypair(&author_keys) == SC_OK); + assert(sc_derive_ed25519_pubkey(author_keys.private_key, author_ed) == SC_OK); + SHA512(author_keys.private_key, 32, author_private); + uint64_t author = sc_derive_node_id_from_pubkey(author_keys.public_key); + assert(test_member_seed(inst, channel, author_keys.public_key, author_ed, author_private, + recreate.ed25519_privkey, "{}", NULL, NULL) >= 0); + assert(!media_download_start(inst, group, &download, destinations[0], root, author, download_done, &completed, NULL, NULL)); assert(!completed); - assert(media_download_start(inst, 0, &download, destinations[0], root, inst->node_id ^ 0x55, + assert(media_download_start(inst, group, &download, destinations[0], root, author, download_done, &completed, NULL, NULL) == -1); assert(!completed && !media_download_cancel(inst, download.media_id, NULL, 0) && completed == 1); - assert(!media_index_delete_channel(db, "0", root)); + assert(!media_index_delete_channel(db, channel, root)); utun_instance_destroy(inst); uasync_destroy(ua, 0); DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "media regression pending deletion/two completions/recreation PASS"); }