-keep track of messages passed to mq
[oweals/gnunet.git] / src / sensor / test_pow_sign.c
index e1e78a7219efed832a4b2f728cf5124758dac6f2..7f6689e7234f851c98771294969794b29d1137f2 100644 (file)
@@ -1,6 +1,6 @@
   /*
    * This file is part of GNUnet.
-   * (C)
+   * Copyright (C)
    *
    * 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 sensor/test_pow_sign.c
@@ -41,7 +41,7 @@
 /**
  * Number of matching bits to use for generating proof-of-work
  */
-#define MATCHING_BITS 2
+#define MATCHING_BITS 5
 
 /**
  * Test timeout
@@ -66,7 +66,7 @@ static int ok = 1;
 /**
  * Task used to shutdown / expire the test
  */
-static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
+static struct GNUNET_SCHEDULER_Task * shutdown_task;
 
 /**
  * Message to be exchanged
@@ -76,12 +76,12 @@ static char msg[MSG_SIZE];
 /**
  * Private key of sending peer
  */
-struct GNUNET_CRYPTO_EddsaPrivateKey *private_key;
+static struct GNUNET_CRYPTO_EddsaPrivateKey *private_key;
 
 /**
  * Public key of sending peer
  */
-struct GNUNET_CRYPTO_EddsaPublicKey *public_key;
+static struct GNUNET_CRYPTO_EddsaPublicKey *public_key;
 
 
 /**
@@ -111,23 +111,25 @@ static void
 pow_cb (void *cls, struct GNUNET_SENSOR_crypto_pow_block *block)
 {
   void *response;
+  struct GNUNET_TIME_Absolute end_time;
+  struct GNUNET_TIME_Relative duration;
 
+  end_time = GNUNET_TIME_absolute_get();
+  duration = GNUNET_TIME_absolute_get_difference (block->timestamp, end_time);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received block:\n" "pow: %" PRIu64 ".\n", block->pow);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Block generation toke %s.\n",
+              GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_NO));
   /* Test that the block is valid */
   GNUNET_assert (MSG_SIZE ==
                  GNUNET_SENSOR_crypto_verify_pow_sign (block, MATCHING_BITS,
-                                                       public_key,
-                                                       GNUNET_SIGNATURE_PURPOSE_SENSOR_ANOMALY_REPORT,
-                                                       &response));
+                                                       public_key, &response));
   GNUNET_assert (0 == memcmp (msg, response, MSG_SIZE));
   /* Modify the payload and test that verification returns invalid */
   block->pow++;
   GNUNET_assert (0 ==
                  GNUNET_SENSOR_crypto_verify_pow_sign (block, MATCHING_BITS,
-                                                       public_key,
-                                                       GNUNET_SIGNATURE_PURPOSE_SENSOR_ANOMALY_REPORT,
-                                                       &response));
+                                                       public_key, &response));
   ok = 0;
   GNUNET_SCHEDULER_cancel (shutdown_task);
   GNUNET_SCHEDULER_add_now (do_shutdown, NULL);