Appending a message produces the ID. And bump the version.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4344 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-07-13 00:20:12 +00:00
parent c4a2d790a3
commit 18128303b6
7 changed files with 29 additions and 16 deletions

View File

@ -170,17 +170,19 @@ void tf_ssb_test_ssb(const tf_test_options_t* options)
b = tf_ssb_db_blob_store(ssb0, (const uint8_t*)k_blob, strlen(k_blob), blob_id, sizeof(blob_id), NULL);
assert(b);
char message_id[k_id_base64_len] = { 0 };
JSContext* context0 = tf_ssb_get_context(ssb0);
JSValue obj = JS_NewObject(context0);
JS_SetPropertyStr(context0, obj, "type", JS_NewString(context0, "post"));
JS_SetPropertyStr(context0, obj, "text", JS_NewString(context0, "Hello, world!"));
tf_ssb_append_message_with_keys(ssb0, id0, priv0, obj);
tf_ssb_append_message_with_keys(ssb0, id0, priv0, obj, message_id, sizeof(message_id));
JS_FreeValue(context0, obj);
printf("appended %s\n", message_id);
obj = JS_NewObject(context0);
JS_SetPropertyStr(context0, obj, "type", JS_NewString(context0, "post"));
JS_SetPropertyStr(context0, obj, "text", JS_NewString(context0, "First post."));
tf_ssb_append_message_with_keys(ssb0, id0, priv0, obj);
tf_ssb_append_message_with_keys(ssb0, id0, priv0, obj, NULL, 0);
JS_FreeValue(context0, obj);
obj = JS_NewObject(context0);
@ -191,7 +193,7 @@ void tf_ssb_test_ssb(const tf_test_options_t* options)
JS_SetPropertyStr(context0, mention, "link", JS_NewString(context0, blob_id));
JS_SetPropertyUint32(context0, mentions, 0, mention);
JS_SetPropertyStr(context0, obj, "mentions", mentions);
tf_ssb_append_message_with_keys(ssb0, id0, priv0, obj);
tf_ssb_append_message_with_keys(ssb0, id0, priv0, obj, NULL, 0);
JS_FreeValue(context0, obj);
uint8_t* b0;
@ -247,7 +249,7 @@ void tf_ssb_test_ssb(const tf_test_options_t* options)
obj = JS_NewObject(context0);
JS_SetPropertyStr(context0, obj, "type", JS_NewString(context0, "post"));
JS_SetPropertyStr(context0, obj, "text", JS_NewString(context0, "Message to self."));
tf_ssb_append_message_with_keys(ssb0, id0, priv0, obj);
tf_ssb_append_message_with_keys(ssb0, id0, priv0, obj, NULL, 0);
JS_FreeValue(context0, obj);
while (count0 == 0)
@ -497,7 +499,7 @@ void tf_ssb_test_following(const tf_test_options_t* options)
JS_SetPropertyStr(context, message, "type", JS_NewString(context, "contact")); \
JS_SetPropertyStr(context, message, "contact", JS_NewString(context, id)); \
JS_SetPropertyStr(context, message, "following", follow ? JS_TRUE : JS_FALSE); \
tf_ssb_append_message_with_keys(ssb, id, priv, message); \
tf_ssb_append_message_with_keys(ssb, id, priv, message, NULL, 0); \
JS_FreeValue(context, message); \
context = NULL
@ -573,7 +575,7 @@ void tf_ssb_test_bench(const tf_test_options_t* options)
JS_SetPropertyStr(tf_ssb_get_context(ssb0), obj, "text", JS_NewString(tf_ssb_get_context(ssb0), "Hello, world!"));
for (int i = 0; i < k_messages; i++)
{
tf_ssb_append_message_with_keys(ssb0, id0, priv0, obj);
tf_ssb_append_message_with_keys(ssb0, id0, priv0, obj, NULL, 0);
}
JS_FreeValue(tf_ssb_get_context(ssb0), obj);
clock_gettime(CLOCK_REALTIME, &end_time);