forked from cory/tildefriends
Delete some code that doesn't need to exist.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4319 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -151,6 +151,11 @@ void tf_ssb_test_ssb(const tf_test_options_t* options)
|
||||
tf_ssb_generate_keys(ssb0);
|
||||
tf_ssb_generate_keys(ssb1);
|
||||
|
||||
uint8_t priv0[512] = { 0 };
|
||||
uint8_t priv1[512] = { 0 };
|
||||
tf_ssb_get_private_key(ssb0, priv0, sizeof(priv0));
|
||||
tf_ssb_get_private_key(ssb1, priv1, sizeof(priv1));
|
||||
|
||||
char id0[k_id_base64_len] = { 0 };
|
||||
char id1[k_id_base64_len] = { 0 };
|
||||
bool b = tf_ssb_whoami(ssb0, id0, sizeof(id0));
|
||||
@ -165,20 +170,29 @@ 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);
|
||||
|
||||
tf_ssb_append_post(ssb0, "Hello, world!");
|
||||
tf_ssb_append_post(ssb0, "First post.");
|
||||
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);
|
||||
JS_FreeValue(context0, obj);
|
||||
|
||||
JSContext* context = tf_ssb_get_context(ssb0);
|
||||
JSValue message = JS_NewObject(context);
|
||||
JS_SetPropertyStr(context, message, "type", JS_NewString(context, "post"));
|
||||
JS_SetPropertyStr(context, message, "text", JS_NewString(context, "First post."));
|
||||
JSValue mentions = JS_NewArray(context);
|
||||
JSValue mention = JS_NewObject(context);
|
||||
JS_SetPropertyStr(context, mention, "link", JS_NewString(context, blob_id));
|
||||
JS_SetPropertyUint32(context, mentions, 0, mention);
|
||||
JS_SetPropertyStr(context, message, "mentions", mentions);
|
||||
tf_ssb_append_message(ssb0, message);
|
||||
JS_FreeValue(context, message);
|
||||
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);
|
||||
JS_FreeValue(context0, obj);
|
||||
|
||||
obj = JS_NewObject(context0);
|
||||
JS_SetPropertyStr(context0, obj, "type", JS_NewString(context0, "post"));
|
||||
JS_SetPropertyStr(context0, obj, "text", JS_NewString(context0, "First post."));
|
||||
JSValue mentions = JS_NewArray(context0);
|
||||
JSValue mention = JS_NewObject(context0);
|
||||
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);
|
||||
JS_FreeValue(context0, obj);
|
||||
|
||||
uint8_t* b0;
|
||||
size_t s0 = 0;
|
||||
@ -229,7 +243,13 @@ void tf_ssb_test_ssb(const tf_test_options_t* options)
|
||||
int count1 = 0;
|
||||
tf_ssb_add_message_added_callback(ssb0, _message_added, NULL, &count0);
|
||||
tf_ssb_add_message_added_callback(ssb1, _message_added, NULL, &count1);
|
||||
tf_ssb_append_post(ssb0, "Message to self.");
|
||||
|
||||
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);
|
||||
JS_FreeValue(context0, obj);
|
||||
|
||||
while (count0 == 0)
|
||||
{
|
||||
uv_run(&loop, UV_RUN_ONCE);
|
||||
@ -461,16 +481,23 @@ void tf_ssb_test_following(const tf_test_options_t* options)
|
||||
tf_ssb_whoami(ssb1, id1, sizeof(id1));
|
||||
tf_ssb_whoami(ssb2, id2, sizeof(id2));
|
||||
|
||||
uint8_t priv0[512] = { 0 };
|
||||
uint8_t priv1[512] = { 0 };
|
||||
uint8_t priv2[512] = { 0 };
|
||||
tf_ssb_get_private_key(ssb0, priv0, sizeof(priv0));
|
||||
tf_ssb_get_private_key(ssb1, priv1, sizeof(priv1));
|
||||
tf_ssb_get_private_key(ssb2, priv2, sizeof(priv2));
|
||||
|
||||
JSContext* context = NULL;
|
||||
JSValue message;
|
||||
|
||||
#define FOLLOW(ssb, id, follow) \
|
||||
#define FOLLOW(ssb, id, priv, follow) \
|
||||
context = tf_ssb_get_context(ssb); \
|
||||
message = JS_NewObject(context); \
|
||||
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(ssb, message); \
|
||||
tf_ssb_append_message_with_keys(ssb, id, priv, message); \
|
||||
JS_FreeValue(context, message); \
|
||||
context = NULL
|
||||
|
||||
@ -494,18 +521,18 @@ void tf_ssb_test_following(const tf_test_options_t* options)
|
||||
while (0)
|
||||
#endif
|
||||
|
||||
FOLLOW(ssb0, id1, true);
|
||||
FOLLOW(ssb1, id2, true);
|
||||
FOLLOW(ssb2, id0, true);
|
||||
FOLLOW(ssb0, id1, priv1, true);
|
||||
FOLLOW(ssb1, id2, priv2, true);
|
||||
FOLLOW(ssb2, id0, priv0, true);
|
||||
DUMP(id0, 2);
|
||||
DUMP(id1, 2);
|
||||
DUMP(id2, 2);
|
||||
FOLLOW(ssb0, id1, false);
|
||||
//FOLLOW(ssb0, id1, true);
|
||||
//FOLLOW(ssb0, id1, true);
|
||||
FOLLOW(ssb0, id1, priv1, false);
|
||||
//FOLLOW(ssb0, id1, priv1, true);
|
||||
//FOLLOW(ssb0, id1, priv1, true);
|
||||
DUMP(id0, 1);
|
||||
DUMP(id1, 2);
|
||||
//FOLLOW(ssb0, id1, false);
|
||||
//FOLLOW(ssb0, id1, priv1, false);
|
||||
//DUMP(1);
|
||||
//DUMP(1);
|
||||
|
||||
@ -534,14 +561,21 @@ void tf_ssb_test_bench(const tf_test_options_t* options)
|
||||
char id0[k_id_base64_len] = { 0 };
|
||||
tf_ssb_whoami(ssb0, id0, sizeof(id0));
|
||||
|
||||
uint8_t priv0[512];
|
||||
tf_ssb_get_private_key(ssb0, priv0, sizeof(priv0));
|
||||
|
||||
struct timespec start_time = { 0 };
|
||||
struct timespec end_time = { 0 };
|
||||
clock_gettime(CLOCK_REALTIME, &start_time);
|
||||
const int k_messages = 4096;
|
||||
JSValue obj = JS_NewObject(tf_ssb_get_context(ssb0));
|
||||
JS_SetPropertyStr(tf_ssb_get_context(ssb0), obj, "type", JS_NewString(tf_ssb_get_context(ssb0), "post"));
|
||||
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_post(ssb0, "Hello, world!");
|
||||
tf_ssb_append_message_with_keys(ssb0, id0, priv0, obj);
|
||||
}
|
||||
JS_FreeValue(tf_ssb_get_context(ssb0), obj);
|
||||
clock_gettime(CLOCK_REALTIME, &end_time);
|
||||
tf_printf("insert = %f seconds\n", (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec - start_time.tv_nsec) / 1e9);
|
||||
|
||||
|
Reference in New Issue
Block a user