2 This file is part of GNUnet.
3 (C) 2014 Christian Grothoff (and other contributing authors)
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
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file secretsharing/test_secretsharing_api.c
23 * @brief testcase for the secretsharing api
26 #include "gnunet_util_lib.h"
27 #include "gnunet_testing_lib.h"
28 #include "gnunet_secretsharing_service.h"
33 static struct GNUNET_SECRETSHARING_Session *keygen;
36 static void secret_ready_cb (void *cls,
37 struct GNUNET_SECRETSHARING_Share *my_share,
38 struct GNUNET_SECRETSHARING_PublicKey *public_key,
39 unsigned int num_ready_peers,
40 struct GNUNET_PeerIdentity *ready_peers)
43 if (num_ready_peers == 1)
45 // FIXME: check that our share is valid, which we can do as there's only
47 GNUNET_SCHEDULER_shutdown ();
51 handle_shutdown (void *cls,
52 const struct GNUNET_SCHEDULER_TaskContext * tc)
56 GNUNET_SECRETSHARING_session_destroy (keygen);
63 const struct GNUNET_CONFIGURATION_Handle *cfg,
64 struct GNUNET_TESTING_Peer *peer)
66 struct GNUNET_HashCode session_id;
67 struct GNUNET_TIME_Absolute start;
68 struct GNUNET_TIME_Absolute deadline;
70 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
71 handle_shutdown, NULL);
73 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "testing secretsharing api\n");
75 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &session_id);
77 start = GNUNET_TIME_absolute_get ();
78 deadline = GNUNET_TIME_absolute_add (start, GNUNET_TIME_UNIT_SECONDS);
80 keygen = GNUNET_SECRETSHARING_create_session (cfg,
81 0, NULL, /* only the local peer */
85 secret_ready_cb, NULL);
92 main (int argc, char **argv)
96 ret = GNUNET_TESTING_peer_run ("test_secretsharing_api",
97 "test_secretsharing.conf",
101 return (GNUNET_YES == success) ? 0 : 1;