aboutsummaryrefslogtreecommitdiff
path: root/src/core/test_core_api_start_only.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-30 23:07:34 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-30 23:07:34 +0000
commitb9ea28763dbf7fc8b43c0c78d315838fcf21bec0 (patch)
tree53f7deb49511a8fa675504ad2034796f28995096 /src/core/test_core_api_start_only.c
parentc4f4203aaff577fdbe60a7a0976e913dbb77f03e (diff)
downloadgnunet-b9ea28763dbf7fc8b43c0c78d315838fcf21bec0.tar.gz
gnunet-b9ea28763dbf7fc8b43c0c78d315838fcf21bec0.zip
starting to convert core tests to new MQ API
Diffstat (limited to 'src/core/test_core_api_start_only.c')
-rw-r--r--src/core/test_core_api_start_only.c68
1 files changed, 26 insertions, 42 deletions
diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c
index 07a402189..6abc3cc89 100644
--- a/src/core/test_core_api_start_only.c
+++ b/src/core/test_core_api_start_only.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009 GNUnet e.V. 3 Copyright (C) 2009, 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -21,6 +21,7 @@
21 * @file transport/test_core_api_start_only.c 21 * @file transport/test_core_api_start_only.c
22 * @brief testcase for core_api.c that only starts two peers, 22 * @brief testcase for core_api.c that only starts two peers,
23 * connects to the core service and shuts down again 23 * connects to the core service and shuts down again
24 * @author Christian Grothoff
24 */ 25 */
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_arm_service.h" 27#include "gnunet_arm_service.h"
@@ -48,49 +49,34 @@ static struct GNUNET_SCHEDULER_Task *timeout_task_id;
48static int ok; 49static int ok;
49 50
50 51
51static void 52static void *
52connect_notify (void *cls, 53connect_notify (void *cls,
53 const struct GNUNET_PeerIdentity *peer) 54 const struct GNUNET_PeerIdentity *peer,
55 struct GNUNET_MQ_Handle *mq)
54{ 56{
57 return NULL;
55} 58}
56 59
57 60
58static void 61static void
59disconnect_notify (void *cls, 62disconnect_notify (void *cls,
60 const struct GNUNET_PeerIdentity *peer) 63 const struct GNUNET_PeerIdentity *peer,
61{ 64 void *internal_cls)
62}
63
64
65static int
66inbound_notify (void *cls,
67 const struct GNUNET_PeerIdentity *other,
68 const struct GNUNET_MessageHeader *message)
69{
70 return GNUNET_OK;
71}
72
73
74static int
75outbound_notify (void *cls,
76 const struct GNUNET_PeerIdentity *other,
77 const struct GNUNET_MessageHeader *message)
78{ 65{
79 return GNUNET_OK;
80} 66}
81 67
82 68
83static struct GNUNET_CORE_MessageHandler handlers[] = { 69static struct GNUNET_MQ_MessageHandler handlers[] = {
84 {NULL, 0, 0} 70 GNUNET_MQ_handler_end ()
85}; 71};
86 72
87 73
88static void 74static void
89shutdown_task (void *cls) 75shutdown_task (void *cls)
90{ 76{
91 GNUNET_CORE_disconnect (p1.ch); 77 GNUNET_CORE_disconnecT (p1.ch);
92 p1.ch = NULL; 78 p1.ch = NULL;
93 GNUNET_CORE_disconnect (p2.ch); 79 GNUNET_CORE_disconnecT (p2.ch);
94 p2.ch = NULL; 80 p2.ch = NULL;
95 ok = 0; 81 ok = 0;
96} 82}
@@ -105,15 +91,12 @@ init_notify (void *cls,
105 if (p == &p1) 91 if (p == &p1)
106 { 92 {
107 /* connect p2 */ 93 /* connect p2 */
108 p2.ch = 94 p2.ch = GNUNET_CORE_connecT (p2.cfg,
109 GNUNET_CORE_connect (p2.cfg, 95 &p2,
110 &p2, 96 &init_notify,
111 &init_notify, 97 &connect_notify,
112 &connect_notify, 98 &disconnect_notify,
113 &disconnect_notify, 99 handlers);
114 &inbound_notify, GNUNET_YES,
115 &outbound_notify, GNUNET_YES,
116 handlers);
117 } 100 }
118 else 101 else
119 { 102 {
@@ -152,15 +135,17 @@ setup_peer (struct PeerContext *p,
152static void 135static void
153timeout_task (void *cls) 136timeout_task (void *cls)
154{ 137{
155 FPRINTF (stderr, "%s", "Timeout.\n"); 138 FPRINTF (stderr,
139 "%s",
140 "Timeout.\n");
156 if (NULL != p1.ch) 141 if (NULL != p1.ch)
157 { 142 {
158 GNUNET_CORE_disconnect (p1.ch); 143 GNUNET_CORE_disconnecT (p1.ch);
159 p1.ch = NULL; 144 p1.ch = NULL;
160 } 145 }
161 if (NULL != p2.ch) 146 if (NULL != p2.ch)
162 { 147 {
163 GNUNET_CORE_disconnect (p2.ch); 148 GNUNET_CORE_disconnecT (p2.ch);
164 p2.ch = NULL; 149 p2.ch = NULL;
165 } 150 }
166 ok = 42; 151 ok = 42;
@@ -181,14 +166,13 @@ run (void *cls,
181 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 166 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
182 (GNUNET_TIME_UNIT_MINUTES, 167 (GNUNET_TIME_UNIT_MINUTES,
183 TIMEOUT), 168 TIMEOUT),
184 &timeout_task, NULL); 169 &timeout_task,
185 p1.ch = GNUNET_CORE_connect (p1.cfg, 170 NULL);
171 p1.ch = GNUNET_CORE_connecT (p1.cfg,
186 &p1, 172 &p1,
187 &init_notify, 173 &init_notify,
188 &connect_notify, 174 &connect_notify,
189 &disconnect_notify, 175 &disconnect_notify,
190 &inbound_notify, GNUNET_YES,
191 &outbound_notify, GNUNET_YES,
192 handlers); 176 handlers);
193} 177}
194 178