Align media integration inputs with routed block identity
This commit is contained in:
1 parent
b1a3d0c6cd
commit
353752165c
2 files changed
+15
-15
No files matched your search
@@ -32,7 +32,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include "../lib/platform_compat.h"
|
||||
|
||||
static int G_PASSED = 0, G_FAILED = 0, G_TOTAL = 0;
|
||||
#define TEST(n) do { G_TOTAL++; printf(" %-60s", n); fflush(stdout); } while(0)
|
||||
@@ -50,6 +50,9 @@ static uint64_t g_nid[N_NODES];
|
||||
static uint64_t g_group_id = 0;
|
||||
static uint8_t g_test_mid[16], g_test_bid0[16], g_test_bid1[16];
|
||||
static uint8_t g_t2_mid[16], g_t2_bids[3][16];
|
||||
static struct media_index_result g_truncated;
|
||||
static int g_download_done, g_download_error;
|
||||
static void downloaded(void* arg, int error) { (void)arg; g_download_done++; g_download_error = error; }
|
||||
static char g_tdir[256] = "/tmp/utun_mdf_XXXXXX";
|
||||
static char g_cfg[N_NODES][256];
|
||||
static char g_db_dir[N_NODES][320];
|
||||
@@ -108,7 +111,7 @@ static int msend(struct UTUN_INSTANCE* inst, uint64_t dst, const uint8_t* data,
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[msend] 0x%016llx → 0x%016llx svc=0x%02x subcmd=0x%02x len=%zu",
|
||||
(unsigned long long)inst->node_id, (unsigned long long)dst, e->dgram[0], data[0], len);
|
||||
int rc = etcp_route_send(inst, TOPO_GROUP_UTUN, dst, e, 1, 0);
|
||||
if (rc != 0) { DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "[msend] FAILED rc=%d", rc); u_free(e->dgram); queue_entry_free(e); }
|
||||
if (rc != 0) DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "[msend] FAILED rc=%d", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -261,7 +264,7 @@ static int create_test_file(void) {
|
||||
sc_ed25519_sign(g_inst[0]->my_ed25519_privkey, smsg, soff, result.block_sigs + i * 64);
|
||||
}
|
||||
int rc = media_index_commit(g_inst[0]->topo_sqlite_db, &result, g_nid[0],
|
||||
g_inst[0]->my_ed25519_privkey, "test_ch", dst_path, media_base);
|
||||
g_inst[0]->my_ed25519_privkey, "9223372036854775808", dst_path, media_base);
|
||||
if (rc != 0) { media_index_result_free(&result); return -1; }
|
||||
memcpy(g_test_mid, result.media_id, 16);
|
||||
memcpy(g_test_bid0, result.block_ids, 16);
|
||||
@@ -282,7 +285,7 @@ static void phase_a3_admission(void) {
|
||||
|
||||
TEST("1st BLOCK_REQ → stream"); {
|
||||
struct media_pkt_block_req req; memset(&req, 0, sizeof(req));
|
||||
req.subcmd = MEDIA_SUBCMD_BLOCK_REQ; req.group_id = g_group_id;
|
||||
req.subcmd = MEDIA_SUBCMD_BLOCK_REQ; assert(!media_index_generate_uuid(req.transfer_id));
|
||||
memcpy(req.media_id, g_test_mid, 16); memcpy(req.block_id, g_test_bid0, 16);
|
||||
msend(g_inst[1], g_nid[0], (const uint8_t*)&req, sizeof(req));
|
||||
int a = 0; while (a < 500) { uasync_poll(g_ua, POLL_MS); a++; }
|
||||
@@ -292,7 +295,7 @@ static void phase_a3_admission(void) {
|
||||
int before = g_inst[0]->md.streams_started;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
struct media_pkt_block_req req; memset(&req, 0, sizeof(req));
|
||||
req.subcmd = MEDIA_SUBCMD_BLOCK_REQ; req.group_id = g_group_id; req.chunk = (uint32_t)i;
|
||||
req.subcmd = MEDIA_SUBCMD_BLOCK_REQ; assert(!media_index_generate_uuid(req.transfer_id));
|
||||
memcpy(req.media_id, g_test_mid, 16); memcpy(req.block_id, g_test_bid0, 16);
|
||||
msend(g_inst[1], g_nid[0], (const uint8_t*)&req, sizeof(req));
|
||||
}
|
||||
@@ -300,7 +303,6 @@ static void phase_a3_admission(void) {
|
||||
int started = g_inst[0]->md.streams_started - before;
|
||||
if (started == 3) OK(); else FAIL("started=%d (expected 3, total=%d)", started, g_inst[0]->md.streams_started);
|
||||
}
|
||||
g_inst[0]->md.active_streams = 0;
|
||||
}
|
||||
|
||||
/* ══════════════════════════════════════════════════════════
|
||||
@@ -310,9 +312,9 @@ static void phase_a3_admission(void) {
|
||||
static void phase_b1_stream_test(void) {
|
||||
TEST("n2→n1 BLOCK_REQ streams data"); {
|
||||
struct media_pkt_block_req req; memset(&req, 0, sizeof(req));
|
||||
req.subcmd = MEDIA_SUBCMD_BLOCK_REQ; req.group_id = g_group_id;
|
||||
req.subcmd = MEDIA_SUBCMD_BLOCK_REQ; assert(!media_index_generate_uuid(req.transfer_id));
|
||||
memcpy(req.media_id, g_test_mid, 16); memcpy(req.block_id, g_test_bid1, 16);
|
||||
req.chunk = 0;
|
||||
req.chunk = 1;
|
||||
g_inst[0]->md.stream_completed = 0;
|
||||
msend(g_inst[1], g_nid[0], (const uint8_t*)&req, sizeof(req));
|
||||
int a = 0;
|
||||
@@ -357,16 +359,13 @@ static int create_truncated_file(void) {
|
||||
for (int i = 0; i < NB; i++) {
|
||||
assert(media_index_generate_uuid(result.block_ids + i * 16) == 0);
|
||||
int sz = (i == NB - 1) ? FS - i * BS : BS;
|
||||
uint8_t smsg[5200]; size_t soff = 0;
|
||||
memcpy(smsg + soff, file_data + i * BS, sz); soff += (size_t)sz;
|
||||
uint64_t nid = g_nid[0]; memcpy(smsg + soff, &nid, 8); soff += 8;
|
||||
sc_ed25519_sign(g_inst[0]->my_ed25519_privkey, smsg, soff, result.block_sigs + i * 64);
|
||||
assert(sc_ed25519_sign(g_inst[0]->my_ed25519_privkey, file_data + i * BS, (size_t)sz, result.block_sigs + i * 64) == SC_OK);
|
||||
}
|
||||
int rc = media_index_commit(g_inst[0]->topo_sqlite_db, &result, g_nid[0],
|
||||
g_inst[0]->my_ed25519_privkey, "test_ch", dst_path, media_base);
|
||||
g_inst[0]->my_ed25519_privkey, "9223372036854775808", dst_path, media_base);
|
||||
memcpy(g_t2_mid, result.media_id, 16);
|
||||
for (int i = 0; i < NB; i++) memcpy(g_t2_bids[i], result.block_ids + i * 16, 16);
|
||||
media_index_result_free(&result);
|
||||
g_truncated = result;
|
||||
unlink(src_tmp);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -266,7 +266,8 @@ static void pending_deletion(void) {
|
||||
assert(!media_index_delete_channel(db, "0", root));
|
||||
completed = 0;
|
||||
sqlite3_stmt* author = NULL;
|
||||
assert(!sqlite3_prepare_v2(db, "INSERT INTO nodes(node_id,ed25519_pubkey) VALUES(?,?)", -1, &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));
|
||||
|
||||
Reference in new issue
Block a user