*/
/**
- * @file testing_old/gnunet-testing.c
+ * @file testing/gnunet-testing.c
* @brief tool to use testing functionality from cmd line
* @author Christian Grothoff
*/
#include "platform.h"
#include "gnunet_util_lib.h"
-#include "gnunet_testing_lib-new.h"
+#include "gnunet_testing_lib.h"
-#define HOSTKEYFILESIZE 914
-
/**
* Final status code.
*/
if ((create_cfg_template != NULL) && (GNUNET_OK != GNUNET_CONFIGURATION_load(cfg_tmpl, create_cfg_template)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not load template `%s'\n", create_cfg_template);
- GNUNET_CONFIGURATION_destroy(cfg_tmpl);
+ GNUNET_CONFIGURATION_destroy (cfg_tmpl);
return 1;
}
/* load defaults */
if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg_tmpl, NULL))
{
- GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not load template `%s'\n", create_cfg_template);
+ GNUNET_CONFIGURATION_destroy (cfg_tmpl);
return 1;
}
fail = GNUNET_NO;
- system = GNUNET_TESTING_system_create ("testing", NULL /* controller */);
+ system = GNUNET_TESTING_system_create ("testing", NULL /* controller */, NULL);
for (cur = 0; cur < no; cur++)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n", cur);
static int
create_hostkeys (const unsigned int no)
{
+ static char pad[GNUNET_TESTING_HOSTKEYFILESIZE];
struct GNUNET_TESTING_System *system;
struct GNUNET_PeerIdentity id;
struct GNUNET_DISK_FileHandle *fd;
- struct GNUNET_CRYPTO_RsaPrivateKey *pk;
- struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkb;
+ struct GNUNET_CRYPTO_EccPrivateKey *pk;
+ struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *pkb;
+ ssize_t ret;
- system = GNUNET_TESTING_system_create ("testing", NULL);
+ system = GNUNET_TESTING_system_create ("testing", NULL, NULL);
pk = GNUNET_TESTING_hostkey_get (system, create_no, &id);
if (NULL == pk)
{
fprintf (stderr, _("Could not extract hostkey %u (offset too large?)\n"), create_no);
+ GNUNET_TESTING_system_destroy (system, GNUNET_YES);
return 1;
}
(void) GNUNET_DISK_directory_create_for_file (create_hostkey);
GNUNET_DISK_PERM_USER_READ |
GNUNET_DISK_PERM_USER_WRITE);
GNUNET_assert (fd != NULL);
- pkb = GNUNET_CRYPTO_rsa_encode_key (pk);
- GNUNET_assert (HOSTKEYFILESIZE ==
- GNUNET_DISK_file_write (fd, pkb, ntohs (pkb->len)));
+ pkb = GNUNET_CRYPTO_ecc_encode_key (pk);
+ ret = GNUNET_DISK_file_write (fd, pkb,
+ ntohs (pkb->size));
+ GNUNET_assert (ntohs (pkb->size) == ret);
+ GNUNET_assert (ntohs (pkb->size) < GNUNET_TESTING_HOSTKEYFILESIZE);
+ GNUNET_assert (GNUNET_TESTING_HOSTKEYFILESIZE - ret ==
+ GNUNET_DISK_file_write (fd, pad,
+ GNUNET_TESTING_HOSTKEYFILESIZE - ret));
+
GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
"Wrote hostkey to file: `%s'\n", create_hostkey);
GNUNET_free (pkb);
- GNUNET_CRYPTO_rsa_key_free (pk);
+ GNUNET_CRYPTO_ecc_key_free (pk);
+ GNUNET_TESTING_system_destroy (system, GNUNET_YES);
return 0;
}
GNUNET_YES, &GNUNET_GETOPT_set_string, &create_cfg_template},
GNUNET_GETOPT_OPTION_END
};
-
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
- return (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc, argv, "gnunet-testing",
- gettext_noop ("Command line tool to access the testing library"), options, &run,
- NULL)) ? ret : 1;
+ ret = (GNUNET_OK ==
+ GNUNET_PROGRAM_run (argc, argv, "gnunet-testing",
+ gettext_noop ("Command line tool to access the testing library"), options, &run,
+ NULL)) ? ret : 1;
+ GNUNET_free ((void*) argv);
+ return ret;
}
/* end of gnunet-testing.c */