summaryrefslogtreecommitdiff
path: root/src/core/test_core_api_send_to_self.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/test_core_api_send_to_self.c')
-rw-r--r--src/core/test_core_api_send_to_self.c150
1 files changed, 75 insertions, 75 deletions
diff --git a/src/core/test_core_api_send_to_self.c b/src/core/test_core_api_send_to_self.c
index 703a635e3..dc132380f 100644
--- a/src/core/test_core_api_send_to_self.c
+++ b/src/core/test_core_api_send_to_self.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file core/test_core_api_send_to_self.c 22 * @file core/test_core_api_send_to_self.c
@@ -56,20 +56,20 @@ static struct GNUNET_CORE_Handle *core;
56 * Function scheduled as very last function, cleans up after us 56 * Function scheduled as very last function, cleans up after us
57 */ 57 */
58static void 58static void
59cleanup (void *cls) 59cleanup(void *cls)
60{ 60{
61 if (NULL != die_task) 61 if (NULL != die_task)
62 { 62 {
63 GNUNET_SCHEDULER_cancel (die_task); 63 GNUNET_SCHEDULER_cancel(die_task);
64 die_task = NULL; 64 die_task = NULL;
65 } 65 }
66 if (NULL != core) 66 if (NULL != core)
67 { 67 {
68 GNUNET_CORE_disconnect (core); 68 GNUNET_CORE_disconnect(core);
69 core = NULL; 69 core = NULL;
70 } 70 }
71 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 71 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
72 "Ending test.\n"); 72 "Ending test.\n");
73} 73}
74 74
75 75
@@ -77,64 +77,64 @@ cleanup (void *cls)
77 * Function scheduled as very last function, cleans up after us 77 * Function scheduled as very last function, cleans up after us
78 */ 78 */
79static void 79static void
80do_timeout (void *cls) 80do_timeout(void *cls)
81{ 81{
82 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 82 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
83 "Test timeout.\n"); 83 "Test timeout.\n");
84 die_task = NULL; 84 die_task = NULL;
85 GNUNET_SCHEDULER_shutdown (); 85 GNUNET_SCHEDULER_shutdown();
86} 86}
87 87
88 88
89static void 89static void
90handle_test (void *cls, 90handle_test(void *cls,
91 const struct GNUNET_MessageHeader *message) 91 const struct GNUNET_MessageHeader *message)
92{ 92{
93 GNUNET_SCHEDULER_shutdown (); 93 GNUNET_SCHEDULER_shutdown();
94 ret = 0; 94 ret = 0;
95} 95}
96 96
97 97
98static void 98static void
99init (void *cls, 99init(void *cls,
100 const struct GNUNET_PeerIdentity *my_identity) 100 const struct GNUNET_PeerIdentity *my_identity)
101{ 101{
102 if (NULL == my_identity) 102 if (NULL == my_identity)
103 { 103 {
104 GNUNET_break (0); 104 GNUNET_break(0);
105 return; 105 return;
106 } 106 }
107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 107 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
108 "Correctly connected to CORE; we are the peer %s.\n", 108 "Correctly connected to CORE; we are the peer %s.\n",
109 GNUNET_i2s (my_identity)); 109 GNUNET_i2s(my_identity));
110 GNUNET_memcpy (&myself, 110 GNUNET_memcpy(&myself,
111 my_identity, 111 my_identity,
112 sizeof (struct GNUNET_PeerIdentity)); 112 sizeof(struct GNUNET_PeerIdentity));
113} 113}
114 114
115 115
116static void * 116static void *
117connect_cb (void *cls, 117connect_cb(void *cls,
118 const struct GNUNET_PeerIdentity *peer, 118 const struct GNUNET_PeerIdentity *peer,
119 struct GNUNET_MQ_Handle *mq) 119 struct GNUNET_MQ_Handle *mq)
120{ 120{
121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 121 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
122 "Connected to peer %s.\n", 122 "Connected to peer %s.\n",
123 GNUNET_i2s (peer)); 123 GNUNET_i2s(peer));
124 if (0 == memcmp (peer, 124 if (0 == memcmp(peer,
125 &myself, 125 &myself,
126 sizeof (struct GNUNET_PeerIdentity))) 126 sizeof(struct GNUNET_PeerIdentity)))
127 { 127 {
128 struct GNUNET_MQ_Envelope *env; 128 struct GNUNET_MQ_Envelope *env;
129 struct GNUNET_MessageHeader *msg; 129 struct GNUNET_MessageHeader *msg;
130 130
131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 131 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
132 "Connected to myself; sending message!\n"); 132 "Connected to myself; sending message!\n");
133 env = GNUNET_MQ_msg (msg, 133 env = GNUNET_MQ_msg(msg,
134 GNUNET_MESSAGE_TYPE_DUMMY); 134 GNUNET_MESSAGE_TYPE_DUMMY);
135 GNUNET_MQ_send (mq, 135 GNUNET_MQ_send(mq,
136 env); 136 env);
137 } 137 }
138 return NULL; 138 return NULL;
139} 139}
140 140
@@ -146,30 +146,30 @@ connect_cb (void *cls,
146 * @param cfg configuration 146 * @param cfg configuration
147 */ 147 */
148static void 148static void
149run (void *cls, 149run(void *cls,
150 const struct GNUNET_CONFIGURATION_Handle *cfg, 150 const struct GNUNET_CONFIGURATION_Handle *cfg,
151 struct GNUNET_TESTING_Peer *peer) 151 struct GNUNET_TESTING_Peer *peer)
152{ 152{
153 struct GNUNET_MQ_MessageHandler handlers[] = { 153 struct GNUNET_MQ_MessageHandler handlers[] = {
154 GNUNET_MQ_hd_fixed_size (test, 154 GNUNET_MQ_hd_fixed_size(test,
155 GNUNET_MESSAGE_TYPE_DUMMY, 155 GNUNET_MESSAGE_TYPE_DUMMY,
156 struct GNUNET_MessageHeader, 156 struct GNUNET_MessageHeader,
157 NULL), 157 NULL),
158 GNUNET_MQ_handler_end () 158 GNUNET_MQ_handler_end()
159 }; 159 };
160 160
161 core = 161 core =
162 GNUNET_CORE_connect (cfg, 162 GNUNET_CORE_connect(cfg,
163 NULL, 163 NULL,
164 &init, 164 &init,
165 &connect_cb, 165 &connect_cb,
166 NULL, 166 NULL,
167 handlers); 167 handlers);
168 GNUNET_SCHEDULER_add_shutdown (&cleanup, 168 GNUNET_SCHEDULER_add_shutdown(&cleanup,
169 NULL); 169 NULL);
170 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, 170 die_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_MINUTES,
171 &do_timeout, 171 &do_timeout,
172 NULL); 172 NULL);
173} 173}
174 174
175 175
@@ -181,12 +181,12 @@ run (void *cls,
181 * @return 0 ok, 1 on error 181 * @return 0 ok, 1 on error
182 */ 182 */
183int 183int
184main (int argc, char *argv[]) 184main(int argc, char *argv[])
185{ 185{
186 ret = 1; 186 ret = 1;
187 if (0 != GNUNET_TESTING_peer_run ("test-core-api-send-to-self", 187 if (0 != GNUNET_TESTING_peer_run("test-core-api-send-to-self",
188 "test_core_api_peer1.conf", 188 "test_core_api_peer1.conf",
189 &run, NULL)) 189 &run, NULL))
190 return 1; 190 return 1;
191 return ret; 191 return ret;
192} 192}