[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: clean up libanastasisrest
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: clean up libanastasisrest |
Date: |
Fri, 05 Feb 2021 11:13:06 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new e43268e clean up libanastasisrest
e43268e is described below
commit e43268e2587dba42e827fb8c78d3eaf534f7c8a8
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Feb 5 11:13:01 2021 +0100
clean up libanastasisrest
---
src/include/anastasis.h | 34 +++++++++-------
src/lib/Makefile.am | 5 ++-
src/lib/anastasis.c | 52 ++++++++++++------------
src/lib/anastasis_api_challenge_run.c | 40 +++++++++---------
src/lib/anastasis_api_curl_defaults.c | 7 +---
src/lib/anastasis_api_keyshare_lookup.c | 56 +++++++++----------------
src/lib/anastasis_api_policy_lookup.c | 41 ++++---------------
src/lib/anastasis_api_policy_store.c | 35 +++-------------
src/lib/anastasis_api_truth_store.c | 24 ++---------
src/lib/testing_api_helpers.c | 72 +++++++++++++--------------------
src/lib/testing_cmd_policy_create.c | 8 +++-
src/lib/testing_cmd_recover_secret.c | 4 --
12 files changed, 137 insertions(+), 241 deletions(-)
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 9c38345..0875b89 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -73,6 +73,7 @@ struct ANASTASIS_DecryptionPolicy
struct ANASTASIS_CRYPTO_SaltP salt;
};
+
/**
* Defines the recovery information (possible policies and version of the
recovery document)
*/
@@ -91,6 +92,7 @@ struct ANASTASIS_RecoveryInformation
unsigned int version; // actual version obtained
};
+
/**
* Core Secret Callback is opened at the begin of a recovery process, it
passes back the core secret of
* the user after the recovery process is completed.
@@ -271,22 +273,24 @@ ANASTASIS_challenge_start (struct GNUNET_CURL_Context
*ctx,
ANASTASIS_ChallengeStartCallback csc,
void *csc_cls);
+
/**
-* Callback which passes back the recovery document and its possible policies.
Also passes
-* back the version of the document for the user to check.
-*
-* @param cls closure for the callback
-* @param ri recovery information struct which contains the policies (NULL if
all provider candidates gave us 404/errors)
-* @param ecs array of error codes, one per provider, #TALER_EC_NONE-terminated
-*/
+ * Callback which passes back the recovery document and its possible policies.
Also passes
+ * back the version of the document for the user to check.
+ *
+ * @param cls closure for the callback
+ * @param ri recovery information struct which contains the policies (NULL if
all provider candidates gave us 404/errors)
+ * @param ecs array of error codes, one per provider, #TALER_EC_NONE-terminated
+ */
typedef void
(*ANASTASIS_PolicyCallback)(void *cls,
const struct ANASTASIS_RecoveryInformation *ri,
const enum TALER_ErrorCode ec);
+
/**
* stores provider URIs, identity key material, decrypted recovery document
(internally!)
-*/
+ */
struct ANASTASIS_Recovery;
@@ -315,17 +319,19 @@ ANASTASIS_recovery_begin (struct GNUNET_CURL_Context *ctx,
void *csc_cls);
/**
-* Cancels the recovery process
-* @param r handle to the recovery struct
-*/
+ * Cancels the recovery process
+ *
+ * @param r handle to the recovery struct
+ */
void
ANASTASIS_recovery_abort (struct ANASTASIS_Recovery *r);
/**
-* Frees the recovery struct
-* @param r handle to the recovery struct
-*/
+ * Frees the recovery struct
+ *
+ * @param r handle to the recovery struct
+ */
void
ANASTASIS_recovery_free (struct ANASTASIS_Recovery *r);
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index cbab0b2..9305a48 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -52,6 +52,7 @@ libanastasis_la_SOURCES = \
anastasis.c
libanastasis_la_LIBADD = \
$(top_builddir)/src/util/libanastasisutil.la \
+ $(top_builddir)/src/lib/libanastasisrest.la \
-lgnunetutil \
-ljansson \
-ltalerutil \
@@ -75,13 +76,13 @@ libanastasistesting_la_SOURCES = \
testing_api_trait_truth_pub.c \
testing_api_trait_hash.c \
testing_api_trait_salt.c \
- testing_api_trait_code.c \
+ testing_api_trait_code.c \
testing_cmd_truth_upload.c \
testing_cmd_policy_create.c \
testing_cmd_secret_share.c \
testing_cmd_recover_secret.c \
testing_cmd_challenge_answer.c \
- testing_cmd_challenge_start.c \
+ testing_cmd_challenge_start.c \
testing_trait_truth.c \
testing_trait_policy.c \
testing_trait_core_secret.c \
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index e1724ea..e7db6c1 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -699,10 +699,16 @@ policy_lookup_cb (void *cls,
const struct ANASTASIS_DownloadDetails *dd)
{
struct ANASTASIS_Recovery *r = cls;
+ void *plaintext;
+ size_t size_plaintext;
+ json_t *recovery_document;
+ json_error_t json_error;
+ json_t *dec_policies;
+ json_t *esc_methods;
+
r->response_code = http_status;
r->ri = GNUNET_new (struct ANASTASIS_RecoveryInformation);
r->plo = NULL;
-
if (http_status != r->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -718,7 +724,7 @@ policy_lookup_cb (void *cls,
ANASTASIS_recovery_abort (r);
return;
}
- if (dd->policy == NULL)
+ if (NULL == dd->policy)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No recovery data available");
@@ -729,20 +735,14 @@ policy_lookup_cb (void *cls,
ANASTASIS_recovery_abort (r);
return;
}
- void *plaintext;
- size_t size_plaintext;
- json_t *recovery_document;
- json_error_t json_error;
- json_t *dec_policies;
- json_t *esc_methods;
-
ANASTASIS_CRYPTO_recovery_document_decrypt (&r->id,
dd->policy,
dd->policy_size,
&plaintext,
&size_plaintext);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d rec doc after enc is %s \n", __FILE__, __LINE__,
+ "At %s:%d rec doc after enc is %s \n",
+ __FILE__, __LINE__,
TALER_b2s (plaintext, size_plaintext));
// FIXME COMPRESSION
@@ -913,19 +913,21 @@ policy_lookup_cb (void *cls,
&r->ri->dps[j].nonces[n_index],
sizeof (struct ANASTASIS_CRYPTO_NonceP));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d escrow nonce is %s-%llu b\n", __FILE__, __LINE__,
+ "At %s:%d escrow nonce is %s-%llu b\n",
+ __FILE__, __LINE__,
TALER_B2S (&r->ri->dps[j].nonces[n_index]),
(unsigned long long) sizeof (r->ri->dps[j].nonces[n_index]));
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d encrypted master key is %s-%llu b\n", __FILE__,
- __LINE__,
+ "At %s:%d encrypted master key is %s-%llu b\n",
+ __FILE__, __LINE__,
TALER_B2S (&r->ri->dps[j].emk),
(unsigned long long) sizeof (r->ri->dps[j].emk));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d policy salt is %s-%llu b\n", __FILE__, __LINE__,
+ "At %s:%d policy salt is %s-%llu b\n",
+ __FILE__, __LINE__,
TALER_B2S (&r->ri->dps[j].salt),
(unsigned long long) sizeof (r->ri->dps[j].salt));
}
@@ -941,7 +943,6 @@ policy_lookup_cb (void *cls,
}
json_decref (esc_methods);
json_decref (dec_policies);
- return;
}
@@ -971,6 +972,7 @@ ANASTASIS_recovery_begin (struct GNUNET_CURL_Context *ctx,
void *csc_cls)
{
struct ANASTASIS_Recovery *r;
+
r = GNUNET_new (struct ANASTASIS_Recovery);
r->csc = csc;
r->csc_cls = csc_cls;
@@ -983,13 +985,15 @@ ANASTASIS_recovery_begin (struct GNUNET_CURL_Context *ctx,
salt,
&r->id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d user_identfier is %s-%llu b\n", __FILE__, __LINE__,
+ "At %s:%d user_identfier is %s-%llu b\n",
+ __FILE__, __LINE__,
TALER_B2S (&r->id),
(unsigned long long) sizeof (r->id));
ANASTASIS_CRYPTO_account_public_key_derive (&r->id,
&r->pub_key);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d public key is %s-%llu b\n", __FILE__, __LINE__,
+ "At %s:%d public key is %s-%llu b\n",
+ __FILE__, __LINE__,
TALER_B2S (&r->pub_key),
(unsigned long long) sizeof (r->pub_key));
@@ -1028,14 +1032,11 @@ ANASTASIS_recovery_begin (struct GNUNET_CURL_Context
*ctx,
void
ANASTASIS_recovery_free (struct ANASTASIS_Recovery *r)
{
- if (NULL != r->solved_challenges)
- GNUNET_free (r->solved_challenges);
- if (NULL != r->encrypted_recovery_document)
- GNUNET_free (r->encrypted_recovery_document);
- if (NULL != r->ri->dps)
- GNUNET_free (r->ri->dps);
- if (NULL != r->ri)
- GNUNET_free (r->ri);
+ GNUNET_free (r->solved_challenges);
+ GNUNET_free (r->encrypted_recovery_document);
+ GNUNET_free (r->ri->dps);
+ GNUNET_free (r->ri->cs);
+ GNUNET_free (r->ri);
GNUNET_free (r);
}
@@ -1157,6 +1158,7 @@ struct ANASTASIS_TruthUpload
const char *paid_order_id;
};
+
static void
truth_store_callback (void *cls,
enum ANASTASIS_ErrorCode ec,
diff --git a/src/lib/anastasis_api_challenge_run.c
b/src/lib/anastasis_api_challenge_run.c
index 43ea3db..fb6a589 100644
--- a/src/lib/anastasis_api_challenge_run.c
+++ b/src/lib/anastasis_api_challenge_run.c
@@ -34,9 +34,6 @@
#include "anastasis_api_curl_defaults.h"
-/**
- * @brief A Contract Operation Handle
- */
struct ANASTASIS_ChallengeRunOperation
{
/**
@@ -73,10 +70,12 @@ struct ANASTASIS_ChallengeRunOperation
* Key to decrypt the truth on the server
*/
const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key;
+
/**
* challenge run response from server(look at number xxx, look at email xxx)
*/
char *response_string;
+
/**
* Payment URI we received from the service, or NULL.
*/
@@ -85,11 +84,6 @@ struct ANASTASIS_ChallengeRunOperation
};
-/**
- * Cancel a pending /truth GET request
- *
- * @param handle from the operation to cancel
- */
void
ANASTASIS_challenge_run_cancel (
struct ANASTASIS_ChallengeRunOperation *cro)
@@ -101,6 +95,7 @@ ANASTASIS_challenge_run_cancel (
}
GNUNET_free (cro->response_string);
GNUNET_free (cro->url);
+ GNUNET_free (cro->pay_uri);
GNUNET_free (cro);
}
@@ -124,7 +119,6 @@ handle_challenge_run_finished (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Backend didn't even return from GET /truth\n");
break;
-
case MHD_HTTP_OK:
{
cro->response_string = GNUNET_STRINGS_data_to_string_alloc (data,
@@ -307,17 +301,20 @@ ANASTASIS_challenge_run (
cro = GNUNET_new (struct ANASTASIS_ChallengeRunOperation);
cro->ctx = ctx;
cro->truth_key = truth_key;
- char *pub_key_str;
+ {
+ char *pub_key_str;
- pub_key_str = GNUNET_STRINGS_data_to_string_alloc (truth_public_key,
- sizeof
(*truth_public_key));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "truth public key in challenge run: %s\n",
- pub_key_str);
+ pub_key_str = GNUNET_STRINGS_data_to_string_alloc (truth_public_key,
+ sizeof
(*truth_public_key));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "truth public key in challenge run: %s\n",
+ pub_key_str);
- GNUNET_asprintf (&path,
- "truth/%s",
- pub_key_str);
+ GNUNET_asprintf (&path,
+ "truth/%s",
+ pub_key_str);
+ GNUNET_free (pub_key_str);
+ }
cro->url = (GNUNET_YES == payment_requested)
? TALER_url_join (backend_url,
path,
@@ -336,9 +333,10 @@ ANASTASIS_challenge_run (
curl_easy_setopt (eh,
CURLOPT_HEADERFUNCTION,
&handle_header));
- GNUNET_assert ((CURLE_OK == curl_easy_setopt (eh,
- CURLOPT_HEADERDATA,
- cro)));
+ GNUNET_assert (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_HEADERDATA,
+ cro));
cro->cb = cb;
cro->cb_cls = cb_cls;
cro->job = GNUNET_CURL_job_add_raw (ctx,
diff --git a/src/lib/anastasis_api_curl_defaults.c
b/src/lib/anastasis_api_curl_defaults.c
index 5e9b200..ce5224f 100644
--- a/src/lib/anastasis_api_curl_defaults.c
+++ b/src/lib/anastasis_api_curl_defaults.c
@@ -22,12 +22,7 @@
#include "anastasis_api_curl_defaults.h"
-/**
- * Get a curl handle with the right defaults
- * for the sync lib.
- *
- * @param url URL to query
- */
+
CURL *
ANASTASIS_curl_easy_get_ (const char *url)
{
diff --git a/src/lib/anastasis_api_keyshare_lookup.c
b/src/lib/anastasis_api_keyshare_lookup.c
index f34b71c..f14d51f 100644
--- a/src/lib/anastasis_api_keyshare_lookup.c
+++ b/src/lib/anastasis_api_keyshare_lookup.c
@@ -81,14 +81,9 @@ struct ANASTASIS_KeyShareLookupOperation
};
-/**
- * Cancel a pending /truth GET request
- *
- * @param handle from the operation to cancel
- */
void
-ANASTASIS_keyshare_lookup_cancel (struct
- ANASTASIS_KeyShareLookupOperation *kslo)
+ANASTASIS_keyshare_lookup_cancel (
+ struct ANASTASIS_KeyShareLookupOperation *kslo)
{
if (NULL != kslo->job)
{
@@ -228,21 +223,6 @@ handle_header (char *buffer,
}
-/**
- * Does a GET /truth.
- *
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param truth_public_key identification of the Truth
- * @param truth_key Key used to Decrypt the Truth on the Server
- * @param payment_request checks if payment was requested
- * @param payment_secret secret from the previously done payment NULL to
trigger payment
- * @param answer Answer for the different authentication methods(code, hash)
- * @param answer_length size of the answer
- * @param cb callback which will work the response gotten from the backend
- * @param cb_cls closure to pass to the callback
- * @return handle for this operation, NULL upon errors
- */
struct ANASTASIS_KeyShareLookupOperation *
ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
@@ -312,17 +292,19 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context
*ctx,
kslo = GNUNET_new (struct ANASTASIS_KeyShareLookupOperation);
kslo->ctx = ctx;
kslo->truth_key = truth_key;
- char *pub_key_str;
-
- pub_key_str = GNUNET_STRINGS_data_to_string_alloc (truth_public_key,
- sizeof
(*truth_public_key));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "truth public key in keyshare lookup: %s\n",
- pub_key_str);
- GNUNET_asprintf (&path,
- "truth/%s",
- pub_key_str);
-
+ {
+ char *pub_key_str;
+
+ pub_key_str = GNUNET_STRINGS_data_to_string_alloc (truth_public_key,
+ sizeof
(*truth_public_key));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "truth public key in keyshare lookup: %s\n",
+ pub_key_str);
+ GNUNET_asprintf (&path,
+ "truth/%s",
+ pub_key_str);
+ GNUNET_free (pub_key_str);
+ }
kslo->url = TALER_url_join (backend_url,
path,
"response",
@@ -338,9 +320,10 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context *ctx,
curl_easy_setopt (eh,
CURLOPT_HEADERFUNCTION,
&handle_header));
- GNUNET_assert ((CURLE_OK == curl_easy_setopt (eh,
- CURLOPT_HEADERDATA,
- kslo)));
+ GNUNET_assert (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_HEADERDATA,
+ kslo));
kslo->cb = cb;
kslo->cb_cls = cb_cls;
kslo->job = GNUNET_CURL_job_add_raw (ctx,
@@ -349,7 +332,6 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context *ctx,
&handle_keyshare_lookup_finished,
kslo);
GNUNET_free (path);
- GNUNET_free (pub_key_str);
curl_slist_free_all (job_headers);
return kslo;
}
diff --git a/src/lib/anastasis_api_policy_lookup.c
b/src/lib/anastasis_api_policy_lookup.c
index 0f89741..fbe1f92 100644
--- a/src/lib/anastasis_api_policy_lookup.c
+++ b/src/lib/anastasis_api_policy_lookup.c
@@ -90,11 +90,6 @@ struct ANASTASIS_PolicyLookupOperation
};
-/**
- * Cancel a pending /policy GET request
- *
- * @param handle from the operation to cancel
- */
void
ANASTASIS_policy_lookup_cancel (struct ANASTASIS_PolicyLookupOperation *plo)
{
@@ -280,16 +275,6 @@ handle_header (char *buffer,
}
-/**
- * Does a GET /policy.
- *
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param anastasis_pub public key of the user's account
- * @param cb callback which will work the response gotten from the backend
- * @param cb_cls closure to pass to the callback
- * @return handle for this operation, NULL upon errors
- */
struct ANASTASIS_PolicyLookupOperation *
ANASTASIS_policy_lookup (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
@@ -335,26 +320,14 @@ ANASTASIS_policy_lookup (struct GNUNET_CURL_Context *ctx,
}
-/**
- * Does a GET /policy for a specific version.
- *
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param anastasis_pub public key of the user's account
- * @param cb callback which will work the response gotten from the backend
- * @param cb_cls closure to pass to the callback
- * @param version version of the policy to be requested
- * @return handle for this operation, NULL upon errors
- */
struct ANASTASIS_PolicyLookupOperation *
-ANASTASIS_policy_lookup_version (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct
- ANASTASIS_CRYPTO_AccountPublicKeyP *
- anastasis_pub,
- ANASTASIS_PolicyLookupCallback cb,
- void *cb_cls,
- uint32_t *version)
+ANASTASIS_policy_lookup_version (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub,
+ ANASTASIS_PolicyLookupCallback cb,
+ void *cb_cls,
+ uint32_t *version)
{
struct ANASTASIS_PolicyLookupOperation *plo;
CURL *eh;
diff --git a/src/lib/anastasis_api_policy_store.c
b/src/lib/anastasis_api_policy_store.c
index 190b2c1..cac5b82 100644
--- a/src/lib/anastasis_api_policy_store.c
+++ b/src/lib/anastasis_api_policy_store.c
@@ -76,28 +76,18 @@ struct ANASTASIS_PolicyStoreOperation
struct GNUNET_HashCode new_upload_hash;
};
-/**
- * Cancel a POST /policy request.
- *
- * @param pso the policy store operation to cancel
- */
+
void
-ANASTASIS_policy_store_cancel (struct
- ANASTASIS_PolicyStoreOperation *pso)
+ANASTASIS_policy_store_cancel (
+ struct ANASTASIS_PolicyStoreOperation *pso)
{
if (NULL != pso->job)
{
GNUNET_CURL_job_cancel (pso->job);
pso->job = NULL;
}
- if (NULL != pso->pay_uri)
- {
- GNUNET_free (pso->pay_uri);
- }
- if (NULL != pso->url)
- {
- GNUNET_free (pso->url);
- }
+ GNUNET_free (pso->pay_uri);
+ GNUNET_free (pso->url);
GNUNET_free (pso);
}
@@ -271,21 +261,6 @@ handle_header (char *buffer,
}
-/**
- * Store policies, does a POST /policy/$AccountPub
- *
- * @param ctx the CURL context used to connect to the backend
- * @param backend_url backend's base URL, including final "/"
- * @param anastasis_priv private key of the user's account
- * @param prev_recovery_data_hash hash of the previous uploaded recovery
document
- * @param recovery_data policy data to be stored
- * @param recovery_data_size number of bytes in @a recovery_data
- * @param payment_requested #GNUNET_YES if the client wants to pay more for
the account now
- * @param paid_order_id payment identifier of last payment
- * @param cb callback processing the response from /policy
- * @param cb_cls closure for cb
- * @return handle for the operation
- */
struct ANASTASIS_PolicyStoreOperation *
ANASTASIS_policy_store (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
diff --git a/src/lib/anastasis_api_truth_store.c
b/src/lib/anastasis_api_truth_store.c
index 87134a5..5ab0204 100644
--- a/src/lib/anastasis_api_truth_store.c
+++ b/src/lib/anastasis_api_truth_store.c
@@ -72,14 +72,10 @@ struct ANASTASIS_TruthStoreOperation
char *pay_uri;
};
-/**
- * Cancel a POST /truth request.
- *
- * @param tso the truth store operation to cancel
- */
+
void
-ANASTASIS_truth_store_cancel (struct
- ANASTASIS_TruthStoreOperation *tso)
+ANASTASIS_truth_store_cancel (
+ struct ANASTASIS_TruthStoreOperation *tso)
{
if (NULL != tso->job)
{
@@ -248,20 +244,6 @@ handle_header (char *buffer,
}
-/**
- * Store Truth, does a POST /truth/$TRUTH_PUBLIC_KEY
- *
- * @param ctx the CURL context used to connect to the backend
- * @param backend_url backend's base URL, including final "/"
- * @param truth_public_key Identfication of the Truth Upload
- * @param prev_truth_data_hash hash of the previous truth upload, NULL for the
first upload ever
- * @param truth_data contains the data which is stored on the Server in JSON
Format
- * @param payment_requested
- * @param paid_order_id
- * @param cb callback processing the response from /truth
- * @param cb_cls closure for cb
- * @return handle for the operation
- */
struct ANASTASIS_TruthStoreOperation *
ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
diff --git a/src/lib/testing_api_helpers.c b/src/lib/testing_api_helpers.c
index e86cb86..94aeec2 100644
--- a/src/lib/testing_api_helpers.c
+++ b/src/lib/testing_api_helpers.c
@@ -1,6 +1,6 @@
/*
This file is part of ANASTASIS
- Copyright (C) 2014-2018 Taler Systems SA
+ Copyright (C) 2014-2021 Taler Systems SA
ANASTASIS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -30,16 +30,6 @@
#include <gnunet/gnunet_curl_lib.h>
-/**
- * Start the anastasis backend process. Assume the port
- * is available and the database is clean. Use the "prepare
- * anastasis" function to do such tasks.
- *
- * @param config_filename configuration filename.
- *
- * @return the process, or NULL if the process could not
- * be started.
- */
struct GNUNET_OS_Process *
ANASTASIS_TESTING_run_anastasis (const char *config_filename,
const char *anastasis_url)
@@ -71,38 +61,34 @@ ANASTASIS_TESTING_run_anastasis (const char
*config_filename,
iter = 0;
do
{
- if (10 == iter)
+ if (100 == iter)
{
- fprintf (stderr,
- "Failed to launch"
- " `anastasis-httpd' (or `wget')\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to launch `anastasis-httpd' (or `wget')\n");
GNUNET_OS_process_kill (anastasis_proc,
SIGTERM);
GNUNET_OS_process_wait (anastasis_proc);
GNUNET_OS_process_destroy (anastasis_proc);
ANASTASIS_FAIL ();
}
- fprintf (stderr, ".\n");
- sleep (1);
+ {
+ struct timespec req = {
+ .tv_nsec = 10000
+ };
+
+ nanosleep (&req,
+ NULL);
+ }
iter++;
}
while (0 != system (wget_cmd));
GNUNET_free (wget_cmd);
- fprintf (stderr, "\n");
-
+ fprintf (stderr,
+ "\n");
return anastasis_proc;
}
-/**
- * Prepare the anastasis execution. Create tables and check if
- * the port is available.
- *
- * @param config_filename configuration filename.
- *
- * @return the base url, or NULL upon errors. Must be freed
- * by the caller.
- */
char *
ANASTASIS_TESTING_prepare_anastasis (const char *config_filename)
{
@@ -128,7 +114,7 @@ ANASTASIS_TESTING_prepare_anastasis (const char
*config_filename)
"anastasis",
"PORT");
GNUNET_CONFIGURATION_destroy (cfg);
- ANASTASIS_FAIL ();
+ return NULL;
}
GNUNET_CONFIGURATION_destroy (cfg);
@@ -137,10 +123,10 @@ ANASTASIS_TESTING_prepare_anastasis (const char
*config_filename)
GNUNET_NETWORK_test_port_free (IPPROTO_TCP,
(uint16_t) port))
{
- fprintf (stderr,
- "Required port %llu not available, skipping.\n",
- port);
- ANASTASIS_FAIL ();
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Required port %llu not available, skipping.\n",
+ port);
+ return NULL;
}
/* DB preparation */
@@ -154,9 +140,8 @@ ANASTASIS_TESTING_prepare_anastasis (const char
*config_filename)
NULL)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to run anastasis-dbinit."
- " Check your PATH.\n");
- ANASTASIS_FAIL ();
+ "Failed to run anastasis-dbinit. Check your PATH.\n");
+ return NULL;
}
if (GNUNET_SYSERR ==
@@ -170,21 +155,18 @@ ANASTASIS_TESTING_prepare_anastasis (const char
*config_filename)
if ( (type == GNUNET_OS_PROCESS_EXITED) &&
(0 != code) )
{
- fprintf (stderr,
- "Failed to setup database\n");
- ANASTASIS_FAIL ();
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to setup database\n");
+ return NULL;
}
if ( (type != GNUNET_OS_PROCESS_EXITED) ||
(0 != code) )
{
- fprintf (stderr,
- "Unexpected error running"
- " `anastasis-dbinit'!\n");
- ANASTASIS_FAIL ();
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected error running `anastasis-dbinit'!\n");
+ return NULL;
}
GNUNET_OS_process_destroy (dbinit_proc);
-
-
GNUNET_asprintf (&base_url,
"http://localhost:%llu/",
port);
diff --git a/src/lib/testing_cmd_policy_create.c
b/src/lib/testing_cmd_policy_create.c
index 287ddba..b9edc37 100644
--- a/src/lib/testing_cmd_policy_create.c
+++ b/src/lib/testing_cmd_policy_create.c
@@ -143,7 +143,11 @@ policy_create_cleanup (void *cls,
struct PolicyCreateState *pcs = cls;
GNUNET_free (pcs->cmd_label_array);
- ANASTASIS_policy_destroy (pcs->policy);
+ if (NULL != pcs->policy)
+ {
+ ANASTASIS_policy_destroy (pcs->policy);
+ pcs->policy = NULL;
+ }
GNUNET_free (pcs);
}
@@ -223,4 +227,4 @@ ANASTASIS_TESTING_cmd_policy_create (const char *label,
}
-/* end of testing_cmd_policy_create.c */
\ No newline at end of file
+/* end of testing_cmd_policy_create.c */
diff --git a/src/lib/testing_cmd_recover_secret.c
b/src/lib/testing_cmd_recover_secret.c
index 956ae88..364e496 100644
--- a/src/lib/testing_cmd_recover_secret.c
+++ b/src/lib/testing_cmd_recover_secret.c
@@ -228,7 +228,6 @@ static void
recover_secret_cleanup (void *cls,
const struct TALER_TESTING_Command *cmd)
{
- // FIXME: Cleanup logic
struct RecoverSecretState *rss = cls;
if (NULL != rss->recovery)
@@ -241,9 +240,6 @@ recover_secret_cleanup (void *cls,
rss->recovery = NULL;
}
json_decref (rss->id_data);
- GNUNET_free (rss->ri->cs);
- GNUNET_free (rss->ri->dps);
- GNUNET_free (rss->ri);
GNUNET_free (rss);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: clean up libanastasisrest,
gnunet <=