diff --git a/src/ssb.db.c b/src/ssb.db.c index b8961fa4..a483934c 100644 --- a/src/ssb.db.c +++ b/src/ssb.db.c @@ -378,6 +378,7 @@ bool tf_ssb_db_blob_get(tf_ssb_t* ssb, const char* id, uint8_t** out_blob, size_ { const uint8_t* blob = sqlite3_column_blob(statement, 0); int size = sqlite3_column_bytes(statement, 0); + printf("bytes = %d\n", size); if (out_blob) { *out_blob = tf_malloc(size + 1); diff --git a/src/ssb.tests.c b/src/ssb.tests.c index 98cfad6b..62624309 100644 --- a/src/ssb.tests.c +++ b/src/ssb.tests.c @@ -184,8 +184,13 @@ void tf_ssb_test_ssb(const tf_test_options_t* options) tf_ssb_append_message(ssb0, message); JS_FreeValue(context, message); - b = tf_ssb_db_blob_get(ssb0, blob_id, NULL, NULL); + uint8_t* b0; + size_t s0 = 0; + b = tf_ssb_db_blob_get(ssb0, blob_id, &b0, &s0); assert(b); + assert(s0 == strlen(k_blob)); + assert(memcmp(b0, k_blob, strlen(k_blob)) == 0); + tf_free(b0); b = !tf_ssb_db_blob_get(ssb1, blob_id, NULL, NULL); assert(b); tf_ssb_server_open(ssb0, 12347); @@ -214,6 +219,15 @@ void tf_ssb_test_ssb(const tf_test_options_t* options) uv_run(&loop, UV_RUN_ONCE); } + uint8_t* b1; + size_t s1 = 0; + b = tf_ssb_db_blob_get(ssb1, blob_id, &b1, &s1); + assert(b); + printf("s1 = %zd sl = %zd\n", s1, strlen(k_blob)); + assert(s1 == strlen(k_blob)); + assert(memcmp(b1, k_blob, strlen(k_blob)) == 0); + tf_free(b1); + printf("Waiting for message to self.\n"); int count0 = 0; int count1 = 0;