add changelog
[oweals/gnunet.git] / src / secretsharing / test_secretsharing_api.c
index d131805e753acbe874b4f5ffc4fa58e71c2637d6..227af1c3eaff5f9a1f6a9978b9bac56789a2363d 100644 (file)
@@ -1,22 +1,22 @@
 /*
      This file is part of GNUnet.
-     (C) 2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2014 GNUnet e.V.
 
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
+     Affero General Public License for more details.
 
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+ */
 
 /**
  * @file secretsharing/test_secretsharing_api.c
@@ -33,23 +33,25 @@ static int success;
 static struct GNUNET_SECRETSHARING_Session *keygen;
 
 
-static void secret_ready_cb (void *cls,
-                             struct GNUNET_SECRETSHARING_Share *my_share,
-                             struct GNUNET_SECRETSHARING_PublicKey *public_key,
-                             unsigned int num_ready_peers,
-                             struct GNUNET_PeerIdentity *ready_peers)
+static void
+secret_ready_cb (void *cls,
+                 struct GNUNET_SECRETSHARING_Share *my_share,
+                 struct GNUNET_SECRETSHARING_PublicKey *public_key,
+                 unsigned int num_ready_peers,
+                 const struct GNUNET_PeerIdentity *ready_peers)
 {
   keygen = NULL;
   if (num_ready_peers == 1)
     success = 1;
   // FIXME: check that our share is valid, which we can do as there's only
   // one peer.
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "secret ready, shutting down\n");
   GNUNET_SCHEDULER_shutdown ();
 }
 
+
 static void
-handle_shutdown (void *cls,
-                 const struct GNUNET_SCHEDULER_TaskContext * tc)
+handle_shutdown (void *cls)
 {
   if (NULL != keygen)
   {
@@ -58,17 +60,17 @@ handle_shutdown (void *cls,
   }
 }
 
+
 static void
 run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *cfg,
      struct GNUNET_TESTING_Peer *peer)
 {
-  struct GNUNET_HashCode session_id; 
+  struct GNUNET_HashCode session_id;
   struct GNUNET_TIME_Absolute start;
   struct GNUNET_TIME_Absolute deadline;
 
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
-                                handle_shutdown, NULL);
+  GNUNET_SCHEDULER_add_shutdown (&handle_shutdown, NULL);
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "testing secretsharing api\n");
 
@@ -83,16 +85,14 @@ run (void *cls,
                                                 start, deadline,
                                                 1,
                                                 secret_ready_cb, NULL);
-
-
 }
 
 
 int
 main (int argc, char **argv)
 {
-
   int ret;
+
   ret = GNUNET_TESTING_peer_run ("test_secretsharing_api",
                                  "test_secretsharing.conf",
                                  &run, NULL);
@@ -100,4 +100,3 @@ main (int argc, char **argv)
     return ret;
   return (GNUNET_YES == success) ? 0 : 1;
 }
-