diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/consensus/test_consensus_api.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/consensus/test_consensus_api.c')
-rw-r--r-- | src/consensus/test_consensus_api.c | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/src/consensus/test_consensus_api.c b/src/consensus/test_consensus_api.c index a2ae36222..d32bc06ed 100644 --- a/src/consensus/test_consensus_api.c +++ b/src/consensus/test_consensus_api.c | |||
@@ -36,31 +36,31 @@ static unsigned int elements_received; | |||
36 | 36 | ||
37 | 37 | ||
38 | static void | 38 | static void |
39 | conclude_done(void *cls) | 39 | conclude_done (void *cls) |
40 | { | 40 | { |
41 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "conclude over\n"); | 41 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "conclude over\n"); |
42 | if (2 != elements_received) | 42 | if (2 != elements_received) |
43 | GNUNET_assert(0); | 43 | GNUNET_assert (0); |
44 | GNUNET_SCHEDULER_shutdown(); | 44 | GNUNET_SCHEDULER_shutdown (); |
45 | } | 45 | } |
46 | 46 | ||
47 | static void | 47 | static void |
48 | on_new_element(void *cls, | 48 | on_new_element (void *cls, |
49 | const struct GNUNET_SET_Element *element) | 49 | const struct GNUNET_SET_Element *element) |
50 | { | 50 | { |
51 | elements_received++; | 51 | elements_received++; |
52 | } | 52 | } |
53 | 53 | ||
54 | static void | 54 | static void |
55 | insert_done(void *cls, int success) | 55 | insert_done (void *cls, int success) |
56 | { | 56 | { |
57 | /* make sure cb is only called once */ | 57 | /* make sure cb is only called once */ |
58 | static int called = GNUNET_NO; | 58 | static int called = GNUNET_NO; |
59 | 59 | ||
60 | GNUNET_assert(GNUNET_NO == called); | 60 | GNUNET_assert (GNUNET_NO == called); |
61 | called = GNUNET_YES; | 61 | called = GNUNET_YES; |
62 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "insert done\n"); | 62 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "insert done\n"); |
63 | GNUNET_CONSENSUS_conclude(consensus, &conclude_done, NULL); | 63 | GNUNET_CONSENSUS_conclude (consensus, &conclude_done, NULL); |
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | ||
@@ -70,47 +70,49 @@ insert_done(void *cls, int success) | |||
70 | * @param cls closure | 70 | * @param cls closure |
71 | */ | 71 | */ |
72 | static void | 72 | static void |
73 | on_shutdown(void *cls) | 73 | on_shutdown (void *cls) |
74 | { | 74 | { |
75 | if (NULL != consensus) | 75 | if (NULL != consensus) |
76 | { | 76 | { |
77 | GNUNET_CONSENSUS_destroy(consensus); | 77 | GNUNET_CONSENSUS_destroy (consensus); |
78 | consensus = NULL; | 78 | consensus = NULL; |
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | static void | 83 | static void |
84 | run(void *cls, | 84 | run (void *cls, |
85 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 85 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
86 | struct GNUNET_TESTING_Peer *peer) | 86 | struct GNUNET_TESTING_Peer *peer) |
87 | { | 87 | { |
88 | char *str = "foo"; | 88 | char *str = "foo"; |
89 | 89 | ||
90 | struct GNUNET_SET_Element el1 = { 4, 0, "foo" }; | 90 | struct GNUNET_SET_Element el1 = { 4, 0, "foo" }; |
91 | struct GNUNET_SET_Element el2 = { 5, 0, "quux" }; | 91 | struct GNUNET_SET_Element el2 = { 5, 0, "quux" }; |
92 | 92 | ||
93 | GNUNET_log_setup("test_consensus_api", | 93 | GNUNET_log_setup ("test_consensus_api", |
94 | "INFO", | 94 | "INFO", |
95 | NULL); | 95 | NULL); |
96 | GNUNET_SCHEDULER_add_shutdown(&on_shutdown, NULL); | 96 | GNUNET_SCHEDULER_add_shutdown (&on_shutdown, NULL); |
97 | 97 | ||
98 | GNUNET_CRYPTO_hash(str, strlen(str), &session_id); | 98 | GNUNET_CRYPTO_hash (str, strlen (str), &session_id); |
99 | consensus = GNUNET_CONSENSUS_create(cfg, 0, NULL, &session_id, | 99 | consensus = GNUNET_CONSENSUS_create (cfg, 0, NULL, &session_id, |
100 | GNUNET_TIME_relative_to_absolute(GNUNET_TIME_UNIT_SECONDS), | 100 | GNUNET_TIME_relative_to_absolute ( |
101 | GNUNET_TIME_relative_to_absolute(GNUNET_TIME_UNIT_MINUTES), | 101 | GNUNET_TIME_UNIT_SECONDS), |
102 | on_new_element, &consensus); | 102 | GNUNET_TIME_relative_to_absolute ( |
103 | GNUNET_assert(consensus != NULL); | 103 | GNUNET_TIME_UNIT_MINUTES), |
104 | 104 | on_new_element, &consensus); | |
105 | GNUNET_CONSENSUS_insert(consensus, &el1, NULL, &consensus); | 105 | GNUNET_assert (consensus != NULL); |
106 | GNUNET_CONSENSUS_insert(consensus, &el2, &insert_done, &consensus); | 106 | |
107 | GNUNET_CONSENSUS_insert (consensus, &el1, NULL, &consensus); | ||
108 | GNUNET_CONSENSUS_insert (consensus, &el2, &insert_done, &consensus); | ||
107 | } | 109 | } |
108 | 110 | ||
109 | 111 | ||
110 | int | 112 | int |
111 | main(int argc, char **argv) | 113 | main (int argc, char **argv) |
112 | { | 114 | { |
113 | return GNUNET_TESTING_peer_run("test_consensus_api", | 115 | return GNUNET_TESTING_peer_run ("test_consensus_api", |
114 | "test_consensus.conf", | 116 | "test_consensus.conf", |
115 | &run, NULL); | 117 | &run, NULL); |
116 | } | 118 | } |