diff options
author | Julius Bünger <buenger@mytum.de> | 2018-10-11 16:35:33 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-10-11 16:35:33 +0200 |
commit | 89297d37878edb0f8dd76d0e6980831cadc93958 (patch) | |
tree | bda2aafbf61d0d53cf8a408bd8ab2d13432c93f0 /src | |
parent | 70bdd2cc27981f415ee80cb44cc31ec99b12bc00 (diff) | |
download | gnunet-89297d37878edb0f8dd76d0e6980831cadc93958.tar.gz gnunet-89297d37878edb0f8dd76d0e6980831cadc93958.zip |
RPS tests: Refine tests for subs
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/test_rps.c | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index cbd3ba845..f26a9d424 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -190,6 +190,11 @@ struct RPSPeer | |||
190 | struct GNUNET_RPS_Handle *rps_handle; | 190 | struct GNUNET_RPS_Handle *rps_handle; |
191 | 191 | ||
192 | /** | 192 | /** |
193 | * Handle to stream requests | ||
194 | */ | ||
195 | struct GNUNET_RPS_StreamRequestHandle *rps_srh; | ||
196 | |||
197 | /** | ||
193 | * ID of the peer. | 198 | * ID of the peer. |
194 | */ | 199 | */ |
195 | struct GNUNET_PeerIdentity *peer_id; | 200 | struct GNUNET_PeerIdentity *peer_id; |
@@ -1116,6 +1121,11 @@ rps_disconnect_adapter (void *cls, | |||
1116 | struct RPSPeer *peer = cls; | 1121 | struct RPSPeer *peer = cls; |
1117 | struct GNUNET_RPS_Handle *h = op_result; | 1122 | struct GNUNET_RPS_Handle *h = op_result; |
1118 | 1123 | ||
1124 | if (NULL != peer->rps_srh) | ||
1125 | { | ||
1126 | GNUNET_RPS_stream_cancel (peer->rps_srh); | ||
1127 | peer->rps_srh = NULL; | ||
1128 | } | ||
1119 | GNUNET_assert (NULL != peer); | 1129 | GNUNET_assert (NULL != peer); |
1120 | GNUNET_RPS_disconnect (h); | 1130 | GNUNET_RPS_disconnect (h); |
1121 | peer->rps_handle = NULL; | 1131 | peer->rps_handle = NULL; |
@@ -1547,17 +1557,35 @@ churn_test_cb (struct RPSPeer *rps_peer) | |||
1547 | * SUB | 1557 | * SUB |
1548 | ***********************************/ | 1558 | ***********************************/ |
1549 | 1559 | ||
1550 | void sub_post (struct RPSPeer *rps_peer) | 1560 | static void |
1561 | got_stream_peer_cb (void *cls, | ||
1562 | uint64_t num_peers, | ||
1563 | const struct GNUNET_PeerIdentity *peers) | ||
1551 | { | 1564 | { |
1552 | GNUNET_RPS_sub_stop (rps_peer->rps_handle, "test"); | 1565 | const struct RPSPeer *rps_peer = cls; |
1566 | |||
1567 | for (uint64_t i = 0; i < num_peers; i++) | ||
1568 | { | ||
1569 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1570 | "Peer %" PRIu32 " received [%s] from stream.\n", | ||
1571 | rps_peer->index, | ||
1572 | GNUNET_i2s (&peers[i])); | ||
1573 | if (0 != rps_peer->index && | ||
1574 | 0 == memcmp (&peers[i], | ||
1575 | &rps_peers[0].peer_id, | ||
1576 | sizeof (struct GNUNET_PeerIdentity))) | ||
1577 | { | ||
1578 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Received a peer id outside sub\n"); | ||
1579 | ok = 1; | ||
1580 | } | ||
1581 | } | ||
1553 | } | 1582 | } |
1554 | 1583 | ||
1584 | |||
1555 | static void | 1585 | static void |
1556 | sub_stop_op (void *cls) | 1586 | sub_post (struct RPSPeer *rps_peer) |
1557 | { | 1587 | { |
1558 | struct GNUNET_RPS_Handle *h = cls; | 1588 | if (0 != rps_peer->index) GNUNET_RPS_sub_stop (rps_peer->rps_handle, "test"); |
1559 | |||
1560 | GNUNET_RPS_sub_stop (h, "test"); | ||
1561 | } | 1589 | } |
1562 | 1590 | ||
1563 | static void | 1591 | static void |
@@ -1565,7 +1593,11 @@ sub_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) | |||
1565 | { | 1593 | { |
1566 | (void) rps_peer; | 1594 | (void) rps_peer; |
1567 | 1595 | ||
1568 | GNUNET_RPS_sub_start (h, "test"); | 1596 | if (0 != rps_peer->index) GNUNET_RPS_sub_start (h, "test"); |
1597 | rps_peer->rps_srh = GNUNET_RPS_stream_request (h, | ||
1598 | 0, | ||
1599 | &got_stream_peer_cb, | ||
1600 | rps_peer); | ||
1569 | } | 1601 | } |
1570 | 1602 | ||
1571 | /*********************************** | 1603 | /*********************************** |
@@ -2986,7 +3018,7 @@ main (int argc, char *argv[]) | |||
2986 | } | 3018 | } |
2987 | 3019 | ||
2988 | ret_value = cur_test_run.eval_cb(); | 3020 | ret_value = cur_test_run.eval_cb(); |
2989 | 3021 | ||
2990 | if (NO_COLLECT_VIEW == cur_test_run.have_collect_view) | 3022 | if (NO_COLLECT_VIEW == cur_test_run.have_collect_view) |
2991 | { | 3023 | { |
2992 | GNUNET_array_grow (rps_peers->cur_view, | 3024 | GNUNET_array_grow (rps_peers->cur_view, |
@@ -2999,4 +3031,5 @@ main (int argc, char *argv[]) | |||
2999 | return ret_value; | 3031 | return ret_value; |
3000 | } | 3032 | } |
3001 | 3033 | ||
3034 | |||
3002 | /* end of test_rps.c */ | 3035 | /* end of test_rps.c */ |