aboutsummaryrefslogtreecommitdiff
path: root/src/nse/test_nse_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nse/test_nse_api.c')
-rw-r--r--src/nse/test_nse_api.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/nse/test_nse_api.c b/src/nse/test_nse_api.c
index 67ca17127..b739e05a2 100644
--- a/src/nse/test_nse_api.c
+++ b/src/nse/test_nse_api.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 * @file nse/test_nse_api.c 21 * @file nse/test_nse_api.c
22 * @brief testcase for nse_api.c 22 * @brief testcase for nse_api.c
@@ -38,13 +38,13 @@ static struct GNUNET_SCHEDULER_Task * die_task;
38 * @param cls closure 38 * @param cls closure
39 */ 39 */
40static void 40static void
41end_test (void *cls) 41end_test(void *cls)
42{ 42{
43 if (h != NULL) 43 if (h != NULL)
44 { 44 {
45 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from NSE service.\n"); 45 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from NSE service.\n");
46 GNUNET_NSE_disconnect (h); 46 GNUNET_NSE_disconnect(h);
47 } 47 }
48} 48}
49 49
50/** 50/**
@@ -58,46 +58,46 @@ end_test (void *cls)
58 * 58 *
59 */ 59 */
60static void 60static void
61check_nse_message (void *cls, struct GNUNET_TIME_Absolute timestamp, 61check_nse_message(void *cls, struct GNUNET_TIME_Absolute timestamp,
62 double estimate, double std_dev) 62 double estimate, double std_dev)
63{ 63{
64 int *ok = cls; 64 int *ok = cls;
65 65
66 fprintf (stderr, 66 fprintf(stderr,
67 "Received NSE message, estimate %f, standard deviation %f.\n", 67 "Received NSE message, estimate %f, standard deviation %f.\n",
68 estimate, std_dev); 68 estimate, std_dev);
69 /* Fantastic check below. Expect NaN, the only thing not equal to itself. */ 69 /* Fantastic check below. Expect NaN, the only thing not equal to itself. */
70 (*ok) = 0; 70 (*ok) = 0;
71 if (die_task != NULL) 71 if (die_task != NULL)
72 GNUNET_SCHEDULER_cancel (die_task); 72 GNUNET_SCHEDULER_cancel(die_task);
73 die_task = GNUNET_SCHEDULER_add_now (&end_test, NULL); 73 die_task = GNUNET_SCHEDULER_add_now(&end_test, NULL);
74} 74}
75 75
76 76
77static void 77static void
78run (void *cls, 78run(void *cls,
79 const struct GNUNET_CONFIGURATION_Handle *cfg, 79 const struct GNUNET_CONFIGURATION_Handle *cfg,
80 struct GNUNET_TESTING_Peer *peer) 80 struct GNUNET_TESTING_Peer *peer)
81{ 81{
82 die_task = 82 die_task =
83 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 83 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply
84 (GNUNET_TIME_UNIT_MINUTES, 1), &end_test, 84 (GNUNET_TIME_UNIT_MINUTES, 1), &end_test,
85 NULL); 85 NULL);
86 86
87 h = GNUNET_NSE_connect (cfg, &check_nse_message, cls); 87 h = GNUNET_NSE_connect(cfg, &check_nse_message, cls);
88 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to NSE service.\n"); 88 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting to NSE service.\n");
89 GNUNET_assert (h != NULL); 89 GNUNET_assert(h != NULL);
90} 90}
91 91
92 92
93int 93int
94main (int argc, char *argv[]) 94main(int argc, char *argv[])
95{ 95{
96 int ok = 1; 96 int ok = 1;
97 97
98 if (0 != GNUNET_TESTING_peer_run ("test_nse_api", 98 if (0 != GNUNET_TESTING_peer_run("test_nse_api",
99 "test_nse.conf", 99 "test_nse.conf",
100 &run, &ok)) 100 &run, &ok))
101 return 1; 101 return 1;
102 return ok; 102 return ok;
103} 103}