forked from cory/tildefriends
clang-format the source. Not exactly how I want it, but automated is better than perfect.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4845 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -34,7 +34,8 @@ void tf_ssb_test_id_conversion(const tf_test_options_t* options)
|
||||
assert(b);
|
||||
}
|
||||
|
||||
typedef struct _test_t {
|
||||
typedef struct _test_t
|
||||
{
|
||||
tf_ssb_t* ssb0;
|
||||
tf_ssb_t* ssb1;
|
||||
tf_ssb_t* ssb2;
|
||||
@ -238,8 +239,7 @@ void tf_ssb_test_ssb(const tf_test_options_t* options)
|
||||
tf_ssb_connect(ssb1, "127.0.0.1", 12347, id0bin);
|
||||
|
||||
tf_printf("Waiting for connection.\n");
|
||||
while (test.connection_count0 != 1 ||
|
||||
test.connection_count1 != 1)
|
||||
while (test.connection_count0 != 1 || test.connection_count1 != 1)
|
||||
{
|
||||
uv_run(&loop, UV_RUN_ONCE);
|
||||
}
|
||||
@ -373,8 +373,7 @@ void tf_ssb_test_rooms(const tf_test_options_t* options)
|
||||
uv_idle_init(&loop, &idle2);
|
||||
uv_idle_start(&idle2, _ssb_test_idle);
|
||||
|
||||
test_t test =
|
||||
{
|
||||
test_t test = {
|
||||
.ssb0 = ssb0,
|
||||
.ssb1 = ssb1,
|
||||
.ssb2 = ssb2,
|
||||
@ -412,17 +411,14 @@ void tf_ssb_test_rooms(const tf_test_options_t* options)
|
||||
tf_ssb_connect(ssb2, "127.0.0.1", 12347, id0bin);
|
||||
|
||||
tf_printf("Waiting for connection.\n");
|
||||
while (test.connection_count0 != 2 ||
|
||||
test.connection_count1 != 1 ||
|
||||
test.connection_count2 != 1)
|
||||
while (test.connection_count0 != 2 || test.connection_count1 != 1 || test.connection_count2 != 1)
|
||||
{
|
||||
uv_run(&loop, UV_RUN_ONCE);
|
||||
}
|
||||
tf_ssb_server_close(ssb0);
|
||||
|
||||
tf_printf("Waiting for broadcasts.\n");
|
||||
while (test.broadcast_count1 != 1 ||
|
||||
test.broadcast_count2 != 1)
|
||||
while (test.broadcast_count1 != 1 || test.broadcast_count2 != 1)
|
||||
{
|
||||
uv_run(&loop, UV_RUN_ONCE);
|
||||
}
|
||||
@ -448,14 +444,7 @@ void tf_ssb_test_rooms(const tf_test_options_t* options)
|
||||
JS_SetPropertyStr(context, message, "args", args);
|
||||
JS_SetPropertyStr(context, message, "type", JS_NewString(context, "duplex"));
|
||||
|
||||
tf_ssb_connection_rpc_send_json(
|
||||
connections[0],
|
||||
k_ssb_rpc_flag_stream | k_ssb_rpc_flag_new_request,
|
||||
tunnel_request_number,
|
||||
message,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
tf_ssb_connection_rpc_send_json(connections[0], k_ssb_rpc_flag_stream | k_ssb_rpc_flag_new_request, tunnel_request_number, message, NULL, NULL, NULL);
|
||||
JS_FreeValue(context, message);
|
||||
|
||||
tf_ssb_connection_t* tun0 = tf_ssb_connection_tunnel_create(ssb1, id0, tunnel_request_number, id2);
|
||||
@ -463,9 +452,7 @@ void tf_ssb_test_rooms(const tf_test_options_t* options)
|
||||
|
||||
tf_printf("Done.\n");
|
||||
|
||||
while (test.connection_count0 != 2 ||
|
||||
test.connection_count1 != 2 ||
|
||||
test.connection_count2 != 2)
|
||||
while (test.connection_count0 != 2 || test.connection_count1 != 2 || test.connection_count2 != 2)
|
||||
{
|
||||
uv_run(&loop, UV_RUN_ONCE);
|
||||
}
|
||||
@ -556,18 +543,18 @@ void tf_ssb_test_following(const tf_test_options_t* options)
|
||||
JSValue signed_message;
|
||||
bool stored;
|
||||
|
||||
#define FOLLOW_BLOCK(id, priv, contact, follow, block) \
|
||||
message = JS_NewObject(context); \
|
||||
JS_SetPropertyStr(context, message, "type", JS_NewString(context, "contact")); \
|
||||
JS_SetPropertyStr(context, message, "contact", JS_NewString(context, contact)); \
|
||||
JS_SetPropertyStr(context, message, "following", follow ? JS_TRUE : JS_FALSE); \
|
||||
JS_SetPropertyStr(context, message, "blocking", block ? JS_TRUE : JS_FALSE); \
|
||||
signed_message = tf_ssb_sign_message(ssb0, id, priv, message); \
|
||||
stored = false; \
|
||||
tf_ssb_verify_strip_and_store_message(ssb0, signed_message, _message_stored, &stored); \
|
||||
_wait_stored(ssb0, &stored); \
|
||||
JS_FreeValue(context, signed_message); \
|
||||
JS_FreeValue(context, message); \
|
||||
#define FOLLOW_BLOCK(id, priv, contact, follow, block) \
|
||||
message = JS_NewObject(context); \
|
||||
JS_SetPropertyStr(context, message, "type", JS_NewString(context, "contact")); \
|
||||
JS_SetPropertyStr(context, message, "contact", JS_NewString(context, contact)); \
|
||||
JS_SetPropertyStr(context, message, "following", follow ? JS_TRUE : JS_FALSE); \
|
||||
JS_SetPropertyStr(context, message, "blocking", block ? JS_TRUE : JS_FALSE); \
|
||||
signed_message = tf_ssb_sign_message(ssb0, id, priv, message); \
|
||||
stored = false; \
|
||||
tf_ssb_verify_strip_and_store_message(ssb0, signed_message, _message_stored, &stored); \
|
||||
_wait_stored(ssb0, &stored); \
|
||||
JS_FreeValue(context, signed_message); \
|
||||
JS_FreeValue(context, message);
|
||||
|
||||
FOLLOW_BLOCK(id0, priv0, id1, true, false);
|
||||
FOLLOW_BLOCK(id1, priv1, id2, true, false);
|
||||
@ -582,7 +569,7 @@ void tf_ssb_test_following(const tf_test_options_t* options)
|
||||
_assert_visible(ssb0, id0, id2, true);
|
||||
_assert_visible(ssb0, id0, id3, false);
|
||||
|
||||
#undef FOLLOW_BLOCK
|
||||
#undef FOLLOW_BLOCK
|
||||
|
||||
uv_run(&loop, UV_RUN_DEFAULT);
|
||||
|
||||
@ -705,10 +692,7 @@ void tf_ssb_test_bench(const tf_test_options_t* options)
|
||||
|
||||
static void _ssb_test_room_connections_changed(tf_ssb_t* ssb, tf_ssb_change_t change, tf_ssb_connection_t* connection, void* user_data)
|
||||
{
|
||||
const char* changes[] =
|
||||
{
|
||||
"create", "connect", "remove"
|
||||
};
|
||||
const char* changes[] = { "create", "connect", "remove" };
|
||||
tf_printf("change=%s %p connection=%s:%d\n", changes[change], connection, tf_ssb_connection_get_host(connection), tf_ssb_connection_get_port(connection));
|
||||
}
|
||||
|
||||
@ -731,15 +715,8 @@ static void _close_callback(uv_timer_t* timer)
|
||||
close_t* data = timer->data;
|
||||
tf_printf("breaking %s %p\n", data->id, data->connection);
|
||||
const char* message = "{\"name\":\"Error\",\"message\":\"whoops\",\"stack\":\"nah\"}";
|
||||
tf_ssb_connection_rpc_send(
|
||||
data->connection,
|
||||
k_ssb_rpc_flag_stream | k_ssb_rpc_flag_json | k_ssb_rpc_flag_end_error,
|
||||
data->request_number,
|
||||
(const uint8_t*)message,
|
||||
strlen(message),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
tf_ssb_connection_rpc_send(data->connection, k_ssb_rpc_flag_stream | k_ssb_rpc_flag_json | k_ssb_rpc_flag_end_error, data->request_number, (const uint8_t*)message,
|
||||
strlen(message), NULL, NULL, NULL);
|
||||
uv_close((uv_handle_t*)timer, _timer_close);
|
||||
}
|
||||
|
||||
@ -767,9 +744,7 @@ static void _ssb_test_room_broadcasts_visit(const char* host, const struct socka
|
||||
char id[k_id_base64_len] = { 0 };
|
||||
tf_ssb_id_bin_to_str(id, sizeof(id), pub);
|
||||
tf_ssb_connection_t* connections[8];
|
||||
if (tunnel &&
|
||||
strcmp(id, "@Jqm63iKumgaWfUI6mXtmQCDHiQJhzMiEWXYUqtcGs9o=.ed25519") != 0 &&
|
||||
tf_ssb_get_connections(ssb, connections, 8) == 1)
|
||||
if (tunnel && strcmp(id, "@Jqm63iKumgaWfUI6mXtmQCDHiQJhzMiEWXYUqtcGs9o=.ed25519") != 0 && tf_ssb_get_connections(ssb, connections, 8) == 1)
|
||||
{
|
||||
tf_printf("%s %p %s\n", host, tunnel, id);
|
||||
|
||||
@ -794,14 +769,7 @@ static void _ssb_test_room_broadcasts_visit(const char* host, const struct socka
|
||||
JS_SetPropertyStr(context, message, "args", args);
|
||||
JS_SetPropertyStr(context, message, "type", JS_NewString(context, "duplex"));
|
||||
|
||||
tf_ssb_connection_rpc_send_json(
|
||||
tunnel,
|
||||
k_ssb_rpc_flag_stream | k_ssb_rpc_flag_new_request,
|
||||
tunnel_request_number,
|
||||
message,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
tf_ssb_connection_rpc_send_json(tunnel, k_ssb_rpc_flag_stream | k_ssb_rpc_flag_new_request, tunnel_request_number, message, NULL, NULL, NULL);
|
||||
JS_FreeValue(context, message);
|
||||
|
||||
tf_printf("tunnel create ssb=%p portal=%s rn=%d target=%s\n", ssb, portal, (int)tunnel_request_number, target);
|
||||
|
Reference in New Issue
Block a user