forked from cory/tildefriends
Test that blobs actually round trip data. I want to rewrite a thing.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4025 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
d3d4b1a13c
commit
98a7753a55
@ -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);
|
const uint8_t* blob = sqlite3_column_blob(statement, 0);
|
||||||
int size = sqlite3_column_bytes(statement, 0);
|
int size = sqlite3_column_bytes(statement, 0);
|
||||||
|
printf("bytes = %d\n", size);
|
||||||
if (out_blob)
|
if (out_blob)
|
||||||
{
|
{
|
||||||
*out_blob = tf_malloc(size + 1);
|
*out_blob = tf_malloc(size + 1);
|
||||||
|
@ -184,8 +184,13 @@ void tf_ssb_test_ssb(const tf_test_options_t* options)
|
|||||||
tf_ssb_append_message(ssb0, message);
|
tf_ssb_append_message(ssb0, message);
|
||||||
JS_FreeValue(context, 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(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);
|
b = !tf_ssb_db_blob_get(ssb1, blob_id, NULL, NULL);
|
||||||
assert(b);
|
assert(b);
|
||||||
tf_ssb_server_open(ssb0, 12347);
|
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);
|
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");
|
printf("Waiting for message to self.\n");
|
||||||
int count0 = 0;
|
int count0 = 0;
|
||||||
int count1 = 0;
|
int count1 = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user