/*
* 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
*
* 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
/**
* Number of matching bits to use for generating proof-of-work
*/
-#define MATCHING_BITS 2
+#define MATCHING_BITS 5
/**
* Test timeout
/**
* Task used to shutdown / expire the test
*/
-static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
+static struct GNUNET_SCHEDULER_Task * shutdown_task;
/**
* Message to be exchanged
/**
* 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;
/**
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);