diff options
author | Florian Dold <florian.dold@gmail.com> | 2013-09-06 11:37:39 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2013-09-06 11:37:39 +0000 |
commit | e81bbc8f2131c4ad7f7d27b4060694efefbdd13d (patch) | |
tree | 30459e4c0748662b45aeeb3a47974196b858a556 /src/consensus/test_consensus_api.c | |
parent | 831dc785eccaa364ff00ff8e2f46372578b4f74b (diff) | |
download | gnunet-e81bbc8f2131c4ad7f7d27b4060694efefbdd13d.tar.gz gnunet-e81bbc8f2131c4ad7f7d27b4060694efefbdd13d.zip |
- initialize set type in test case
- handle 1-peer consensus correcly
- don't store peers in consensus api
- updated consensus test case
Diffstat (limited to 'src/consensus/test_consensus_api.c')
-rw-r--r-- | src/consensus/test_consensus_api.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/consensus/test_consensus_api.c b/src/consensus/test_consensus_api.c index c79a6221c..37a5eb692 100644 --- a/src/consensus/test_consensus_api.c +++ b/src/consensus/test_consensus_api.c | |||
@@ -32,26 +32,23 @@ static struct GNUNET_CONSENSUS_Handle *consensus; | |||
32 | 32 | ||
33 | static struct GNUNET_HashCode session_id; | 33 | static struct GNUNET_HashCode session_id; |
34 | 34 | ||
35 | static unsigned int elements_received; | ||
35 | 36 | ||
36 | static int | 37 | |
37 | conclude_done (void *cls, const struct GNUNET_CONSENSUS_Group *group) | 38 | static void |
39 | conclude_done (void *cls) | ||
38 | { | 40 | { |
39 | if (NULL == group) | 41 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "conclude over\n"); |
40 | { | 42 | if (2 != elements_received) |
41 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "conclude over\n"); | 43 | GNUNET_abort (); |
42 | GNUNET_SCHEDULER_shutdown (); | 44 | GNUNET_SCHEDULER_shutdown (); |
43 | return GNUNET_NO; | ||
44 | } | ||
45 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "concluded\n"); | ||
46 | return GNUNET_YES; | ||
47 | } | 45 | } |
48 | 46 | ||
49 | static int | 47 | static void |
50 | on_new_element (void *cls, | 48 | on_new_element (void *cls, |
51 | struct GNUNET_CONSENSUS_Element *element) | 49 | const struct GNUNET_SET_Element *element) |
52 | { | 50 | { |
53 | GNUNET_assert (0); | 51 | elements_received++; |
54 | return GNUNET_YES; | ||
55 | } | 52 | } |
56 | 53 | ||
57 | static void | 54 | static void |
@@ -62,7 +59,7 @@ insert_done (void *cls, int success) | |||
62 | GNUNET_assert (GNUNET_NO == called); | 59 | GNUNET_assert (GNUNET_NO == called); |
63 | called = GNUNET_YES; | 60 | called = GNUNET_YES; |
64 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "insert done\n"); | 61 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "insert done\n"); |
65 | GNUNET_CONSENSUS_conclude (consensus, GNUNET_TIME_UNIT_SECONDS, 0, &conclude_done, NULL); | 62 | GNUNET_CONSENSUS_conclude (consensus, GNUNET_TIME_UNIT_SECONDS, &conclude_done, NULL); |
66 | } | 63 | } |
67 | 64 | ||
68 | 65 | ||
@@ -91,8 +88,8 @@ run (void *cls, | |||
91 | { | 88 | { |
92 | char *str = "foo"; | 89 | char *str = "foo"; |
93 | 90 | ||
94 | struct GNUNET_CONSENSUS_Element el1 = {"foo", 4, 0}; | 91 | struct GNUNET_SET_Element el1 = {4, 0, "foo"}; |
95 | struct GNUNET_CONSENSUS_Element el2 = {"bar", 4, 0}; | 92 | struct GNUNET_SET_Element el2 = {5, 0, "quux"}; |
96 | 93 | ||
97 | GNUNET_log_setup ("test_consensus_api", | 94 | GNUNET_log_setup ("test_consensus_api", |
98 | "INFO", | 95 | "INFO", |