- added check against statistics
[oweals/gnunet.git] / src / gns / test_gns_simple_shorten.c
index c9989dd177be633302d6e5aa94ab25cf5d476562..8a4dd2ec9c29dd17ae360ce299929d33b66428f2 100644 (file)
@@ -36,7 +36,7 @@
 #define VERBOSE GNUNET_YES
 
 /* Timeout for entire testcase */
-#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
+#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
 
 /* If number of peers not in config file, use this number */
 #define DEFAULT_NUM_PEERS 2
@@ -196,8 +196,8 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
   struct GNUNET_CRYPTO_RsaPrivateKey *our_key;
   struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
   struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
-  GNUNET_HashCode bob_hash;
-  GNUNET_HashCode alice_hash;
+  struct GNUNET_CRYPTO_ShortHashCode bob_hash;
+  struct GNUNET_CRYPTO_ShortHashCode alice_hash;
   struct GNUNET_CRYPTO_RsaSignature *sig;
   char* our_keyfile;
 
@@ -237,9 +237,9 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
   rd.expiration = GNUNET_TIME_absolute_get_forever ();
   GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
   
-  GNUNET_CRYPTO_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
+  GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
 
-  rd.data_size = sizeof(GNUNET_HashCode);
+  rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
   rd.data = &bob_hash;
   rd.record_type = GNUNET_GNS_RECORD_PKEY;
   
@@ -252,9 +252,11 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
                                   NULL);
   
   /* put alice into bobs zone */
-  GNUNET_CRYPTO_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash);
+  GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash);
   rd.data = &alice_hash;
-  sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_absolute_get_forever(), TEST_AUTHORITY_ALICE,
+  sig = GNUNET_NAMESTORE_create_signature(bob_key,
+                                          GNUNET_TIME_absolute_get_forever(),
+                                          TEST_AUTHORITY_ALICE,
                                           &rd, 1);
 
   GNUNET_NAMESTORE_record_put (namestore_handle,
@@ -266,13 +268,15 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
                                sig,
                                NULL,
                                NULL);
-
+  GNUNET_free(sig);
   /* put www A record and PSEU into alice's zone */
 
   rd.data_size = sizeof(struct in_addr);
   rd.data = web;
   rd.record_type = GNUNET_DNSPARSER_TYPE_A;
-  sig = GNUNET_NAMESTORE_create_signature(alice_key,GNUNET_TIME_absolute_get_forever(),  TEST_RECORD_NAME,
+  sig = GNUNET_NAMESTORE_create_signature(alice_key,
+                                          GNUNET_TIME_absolute_get_forever(),
+                                          TEST_RECORD_NAME,
                                           &rd, 1);
 
   GNUNET_NAMESTORE_record_put (namestore_handle,
@@ -284,8 +288,8 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
                                sig,
                                NULL,
                                NULL);
-
-  rd.data_size = sizeof(GNUNET_HashCode);
+  
+  rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
   rd.data = &alice_hash;
   rd.record_type = GNUNET_GNS_RECORD_PKEY;
   GNUNET_free(sig);
@@ -297,7 +301,10 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
                                &commence_testing,
                                NULL);
 
-
+  GNUNET_free(web);
+  GNUNET_CRYPTO_rsa_key_free(our_key);
+  GNUNET_CRYPTO_rsa_key_free(bob_key);
+  GNUNET_CRYPTO_rsa_key_free(alice_key);
 }
 
 static void