commit aef6d798c8982e93bc68c94b1c9c09b160672d54
parent 430c95c21b478703f3191327afa74253b9d79d48
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Tue, 4 Jul 2017 19:32:44 +0200
testcase extracts merchant priv from config
Diffstat:
1 file changed, 34 insertions(+), 0 deletions(-)
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
@@ -717,6 +717,40 @@ struct InterpreterState
*/
static struct GNUNET_DISK_PipeHandle *sigpipe;
+/**
+ * Return instance private key from config
+ *
+ * @param config configuration handle
+ * @param instance instance name
+ * @return pointer to private key, NULL on error
+ */
+struct GNUNET_CRYPTO_EddsaPrivateKey *
+get_instance_priv (struct GNUNET_CONFIGURATION_Handle *config,
+ const char *instance)
+{
+ char *config_section;
+ char *filename;
+ struct GNUNET_CRYPTO_EddsaPrivateKey *ret;
+
+ (void) GNUNET_asprintf (&config_section,
+ "merchant-instance-%s",
+ instance);
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (config,
+ config_section,
+ "KEYFILE",
+ &filename))
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+ if (NULL ==
+ (ret = GNUNET_CRYPTO_eddsa_key_create_from_file (filename)))
+ GNUNET_break (0);
+
+ return ret;
+}
/**
* The testcase failed, return with an error code.