X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Ftest_peer.c;h=e6ab557dd89dcdb09780537e5f85169063c3e250;hb=2587d268f7c92b09bfc1b0130105b378d6055329;hp=395d40712a6c79b2a225e698b47e1312086c9ec9;hpb=502af2167f7c218366666ca4944bd7cc54b5b19a;p=oweals%2Fgnunet.git diff --git a/src/util/test_peer.c b/src/util/test_peer.c index 395d40712..e6ab557dd 100644 --- a/src/util/test_peer.c +++ b/src/util/test_peer.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2009 Christian Grothoff (and other contributing authors) + Copyright (C) 2009 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -14,8 +14,8 @@ 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. + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /** * @file util/test_peer.c @@ -24,15 +24,13 @@ */ #include "platform.h" -#include "gnunet_crypto_lib.h" -#include "gnunet_peer_lib.h" +#include "gnunet_util_lib.h" +#include #define NUMBER_OF_PEERS 10 -#define DEBUG GNUNET_NO - /** - * A list of Peer ID's to play with + * A list of Peer ID's to play with */ static struct GNUNET_PeerIdentity pidArr[NUMBER_OF_PEERS]; @@ -44,11 +42,11 @@ generatePeerIdList () for (i = 0; i < NUMBER_OF_PEERS; i++) { - GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, - &pidArr[i].hashPubKey); -#if DEBUG - printf ("Peer %d: %s\n", i, GNUNET_i2s (&pidArr[i])); -#endif + gcry_randomize (&pidArr[i], + sizeof (struct GNUNET_PeerIdentity), + GCRY_STRONG_RANDOM); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Peer %d: %s\n", i, GNUNET_i2s (&pidArr[i])); } } @@ -69,7 +67,7 @@ check () pid = GNUNET_PEER_intern (&pidArr[i]); if (pid != (i + 1)) { - fprintf (stderr, "Unexpected Peer ID returned by intern function\n"); + FPRINTF (stderr, "%s", "Unexpected Peer ID returned by intern function\n"); return 1; } } @@ -80,7 +78,7 @@ check () pid = GNUNET_PEER_intern (&pidArr[i]); if (pid != (i + 1)) { - fprintf (stderr, "Unexpected Peer ID returned by intern function\n"); + FPRINTF (stderr, "%s", "Unexpected Peer ID returned by intern function\n"); return 1; } } @@ -99,10 +97,10 @@ check () GNUNET_PEER_resolve (1, &res); GNUNET_assert (0 == memcmp (&res, &pidArr[0], sizeof (res))); - /* - * Attempt to convert pid = 0 (which is reserved) + /* + * Attempt to convert pid = 0 (which is reserved) * into a peer identity object, the peer identity memory - * is expected to be set to zero + * is expected to be set to zero */ memset (&zero, 0, sizeof (struct GNUNET_PeerIdentity)); GNUNET_log_skip (1, GNUNET_YES); @@ -124,7 +122,7 @@ check () int main () { - int i; + unsigned int i; GNUNET_log_setup ("test-peer", "ERROR", NULL); for (i = 0; i < 1; i++)