forked from cory/tildefriends
Add the beginnings of a peers.exchange test and begin to fix fallout.
This commit is contained in:
@ -870,4 +870,52 @@ void tf_ssb_test_encrypt(const tf_test_options_t* options)
|
||||
printf("returned %d\n", WEXITSTATUS(result));
|
||||
assert(WEXITSTATUS(result) == 0);
|
||||
}
|
||||
|
||||
void tf_ssb_test_peer_exchange(const tf_test_options_t* options)
|
||||
{
|
||||
uv_loop_t loop = { 0 };
|
||||
uv_loop_init(&loop);
|
||||
|
||||
unlink("out/test_db0.sqlite");
|
||||
tf_ssb_t* ssb0 = tf_ssb_create(&loop, NULL, "file:out/test_db0.sqlite", NULL);
|
||||
tf_ssb_set_is_room(ssb0, false);
|
||||
tf_ssb_set_is_replicator(ssb0, false);
|
||||
tf_ssb_set_is_peer_exchange(ssb0, true);
|
||||
tf_ssb_register(tf_ssb_get_context(ssb0), ssb0);
|
||||
tf_ssb_server_open(ssb0, 12347);
|
||||
|
||||
unlink("out/test_db1.sqlite");
|
||||
tf_ssb_t* ssb1 = tf_ssb_create(&loop, NULL, "file:out/test_db1.sqlite", NULL);
|
||||
tf_ssb_set_is_room(ssb1, false);
|
||||
tf_ssb_set_is_replicator(ssb1, false);
|
||||
tf_ssb_set_is_peer_exchange(ssb1, true);
|
||||
tf_ssb_register(tf_ssb_get_context(ssb1), ssb1);
|
||||
tf_ssb_server_open(ssb1, 12348);
|
||||
|
||||
unlink("out/test_db2.sqlite");
|
||||
tf_ssb_t* ssb2 = tf_ssb_create(&loop, NULL, "file:out/test_db2.sqlite", NULL);
|
||||
tf_ssb_set_is_room(ssb2, false);
|
||||
tf_ssb_set_is_replicator(ssb2, false);
|
||||
tf_ssb_set_is_peer_exchange(ssb2, true);
|
||||
tf_ssb_register(tf_ssb_get_context(ssb2), ssb2);
|
||||
tf_ssb_server_open(ssb2, 12349);
|
||||
|
||||
char id0[k_id_base64_len] = { 0 };
|
||||
tf_ssb_whoami(ssb0, id0, sizeof(id0));
|
||||
uint8_t id0bin[k_id_bin_len];
|
||||
tf_ssb_id_str_to_bin(id0bin, id0);
|
||||
tf_ssb_connect(ssb1, "127.0.0.1", 12347, id0bin);
|
||||
tf_ssb_connect(ssb2, "127.0.0.1", 12347, id0bin);
|
||||
|
||||
uv_run(&loop, UV_RUN_DEFAULT);
|
||||
|
||||
tf_ssb_destroy(ssb0);
|
||||
tf_ssb_destroy(ssb1);
|
||||
tf_ssb_destroy(ssb2);
|
||||
|
||||
uv_run(&loop, UV_RUN_DEFAULT);
|
||||
|
||||
uv_loop_close(&loop);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user