forked from cory/tildefriends
Make -t peer_exchange complete and test that something happened.
This commit is contained in:
parent
6ea08cc5dc
commit
f360e886ff
@ -871,6 +871,19 @@ void tf_ssb_test_encrypt(const tf_test_options_t* options)
|
|||||||
assert(WEXITSTATUS(result) == 0);
|
assert(WEXITSTATUS(result) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _count_broadcasts_callback(const char* host, const struct sockaddr_in* addr, tf_ssb_broadcast_origin_t origin, tf_ssb_connection_t* tunnel, const uint8_t* pub, void* user_data)
|
||||||
|
{
|
||||||
|
int* count = user_data;
|
||||||
|
(*count)++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _count_broadcasts(tf_ssb_t* ssb)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
tf_ssb_visit_broadcasts(ssb, _count_broadcasts_callback, &count);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
void tf_ssb_test_peer_exchange(const tf_test_options_t* options)
|
void tf_ssb_test_peer_exchange(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
uv_loop_t loop = { 0 };
|
uv_loop_t loop = { 0 };
|
||||||
@ -907,7 +920,16 @@ void tf_ssb_test_peer_exchange(const tf_test_options_t* options)
|
|||||||
tf_ssb_connect(ssb1, "127.0.0.1", 12347, id0bin);
|
tf_ssb_connect(ssb1, "127.0.0.1", 12347, id0bin);
|
||||||
tf_ssb_connect(ssb2, "127.0.0.1", 12347, id0bin);
|
tf_ssb_connect(ssb2, "127.0.0.1", 12347, id0bin);
|
||||||
|
|
||||||
uv_run(&loop, UV_RUN_DEFAULT);
|
while (_count_broadcasts(ssb0) != 2 ||
|
||||||
|
_count_broadcasts(ssb1) != 1 ||
|
||||||
|
_count_broadcasts(ssb2) != 1)
|
||||||
|
{
|
||||||
|
uv_run(&loop, UV_RUN_ONCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
tf_ssb_send_close(ssb0);
|
||||||
|
tf_ssb_send_close(ssb1);
|
||||||
|
tf_ssb_send_close(ssb2);
|
||||||
|
|
||||||
tf_ssb_destroy(ssb0);
|
tf_ssb_destroy(ssb0);
|
||||||
tf_ssb_destroy(ssb1);
|
tf_ssb_destroy(ssb1);
|
||||||
|
Loading…
Reference in New Issue
Block a user