summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/auditor/test-auditor.sh8
-rw-r--r--src/bank-lib/fakebank.c7
-rw-r--r--src/exchange/taler-exchange-httpd_extensions.c5
-rw-r--r--src/exchange/taler-exchange-httpd_keys.c20
-rw-r--r--src/exchange/taler-exchange-httpd_keys.h12
-rw-r--r--src/exchange/taler-exchange-httpd_management_post_keys.c3
-rw-r--r--src/lib/exchange_api_withdraw.c2
-rw-r--r--src/templating/mustach-jansson.c156
-rw-r--r--src/testing/testing_api_cmd_contract_get.c1
-rw-r--r--src/testing/testing_api_cmd_exec_closer.c1
-rw-r--r--src/testing/testing_api_cmd_purse_deposit.c11
-rw-r--r--src/testing/testing_api_cmd_purse_get.c9
-rw-r--r--src/testing/testing_api_cmd_reserve_get.c9
-rw-r--r--src/testing/testing_api_cmd_wire.c6
14 files changed, 135 insertions, 115 deletions
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index 2fc97283b..60cc00bd2 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -240,7 +240,13 @@ function audit_only () {
echo -n "."
$VALGRIND taler-helper-auditor-reserves -i -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-reserves-inc.json 2> ${MY_TMP_DIR}/test-audit-reserves-inc.log || exit_fail "incremental reserves audit failed"
echo -n "."
- $VALGRIND taler-helper-auditor-wire -i -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire.json 2> ${MY_TMP_DIR}/test-wire-audit.log || exit_fail "wire audit failed"
+ rm -f ${MY_TMP_DIR}/test-wire-audit.log
+ thaw() {
+ $VALGRIND taler-helper-auditor-wire -i -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire.json 2>> ${MY_TMP_DIR}/test-wire-audit.log
+ }
+ thaw || ( echo -e " FIRST CALL TO taler-helper-auditor-wire FAILED,\nRETRY AFTER TWO SECONDS..." | tee -a ${MY_TMP_DIR}/test-wire-audit.log
+ sleep 2
+ thaw || exit_fail "wire audit failed" )
echo -n "."
$VALGRIND taler-helper-auditor-wire -i -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire-inc.json 2> ${MY_TMP_DIR}/test-wire-audit-inc.log || exit_fail "wire audit inc failed"
echo -n "."
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 34b87be57..b3d3250a1 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -1484,6 +1484,8 @@ TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h)
while (NULL != (lp = GNUNET_CONTAINER_heap_remove_root (h->lp_heap)))
lp_trigger (lp,
h);
+ GNUNET_assert (0 ==
+ pthread_mutex_unlock (&h->big_lock));
GNUNET_break (sizeof (val) ==
#ifdef __linux__
write (h->lp_event,
@@ -1492,8 +1494,6 @@ TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h)
#endif
&val,
sizeof (val)));
- GNUNET_assert (0 ==
- pthread_mutex_unlock (&h->big_lock));
GNUNET_break (0 ==
pthread_join (h->lp_thread,
&ret));
@@ -3012,7 +3012,7 @@ handle_bank_integration (struct TALER_FAKEBANK_Handle *h,
char dummy;
if (1 != sscanf (lp_s,
- "%lld%c",
+ "%llu%c",
&d,
&dummy))
{
@@ -3427,6 +3427,7 @@ post_testing_register (struct TALER_FAKEBANK_Handle *h,
acc = lookup_account (h,
username,
username);
+ GNUNET_assert (NULL != acc);
acc->password = GNUNET_strdup (password);
acc->balance = h->signup_bonus; /* magic money creation! */
}
diff --git a/src/exchange/taler-exchange-httpd_extensions.c b/src/exchange/taler-exchange-httpd_extensions.c
index 30d1c5ac9..c89a00411 100644
--- a/src/exchange/taler-exchange-httpd_extensions.c
+++ b/src/exchange/taler-exchange-httpd_extensions.c
@@ -20,6 +20,7 @@
#include "platform.h"
#include <gnunet/gnunet_json_lib.h>
#include "taler_dbevents.h"
+#include "taler-exchange-httpd_keys.h"
#include "taler-exchange-httpd_responses.h"
#include "taler-exchange-httpd_extensions.h"
#include "taler_json_lib.h"
@@ -156,6 +157,10 @@ extension_update_event_cb (void *cls,
TALER_age_mask_to_string (&conf->mask));
}
+
+ // Finally, call TEH_keys_update_states in order to refresh the cached
+ // values.
+ TEH_keys_update_states ();
}
diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c
index edfe50e58..b37c68d95 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -2623,8 +2623,8 @@ TEH_keys_update_states ()
}
-struct TEH_KeyStateHandle *
-TEH_keys_get_state2 (bool management_only)
+static struct TEH_KeyStateHandle *
+keys_get_state (bool management_only)
{
struct TEH_KeyStateHandle *old_ksh;
struct TEH_KeyStateHandle *ksh;
@@ -2660,19 +2660,28 @@ TEH_keys_get_state2 (bool management_only)
struct TEH_KeyStateHandle *
+TEH_keys_get_state_for_management_only (void)
+{
+ return keys_get_state (true);
+}
+
+
+struct TEH_KeyStateHandle *
TEH_keys_get_state (void)
{
struct TEH_KeyStateHandle *ksh;
- ksh = TEH_keys_get_state2 (false);
+ ksh = keys_get_state (false);
if (NULL == ksh)
return NULL;
+
if (ksh->management_only)
{
if (GNUNET_OK !=
finish_keys_response (ksh))
return NULL;
}
+
return ksh;
}
@@ -2715,6 +2724,7 @@ TEH_keys_denomination_by_hash (
NULL);
return NULL;
}
+
return TEH_keys_denomination_by_hash2 (ksh,
h_denom_pub,
conn,
@@ -3410,7 +3420,7 @@ TEH_keys_get_timing (const struct TALER_ExchangePublicKeyP *exchange_pub,
struct HelperSignkey *hsk;
struct GNUNET_PeerIdentity pid;
- ksh = TEH_keys_get_state2 (true);
+ ksh = TEH_keys_get_state_for_management_only ();
if (NULL == ksh)
{
GNUNET_break (0);
@@ -3580,7 +3590,7 @@ TEH_keys_management_get_keys_handler (const struct TEH_RequestHandler *rh,
json_t *reply;
(void) rh;
- ksh = TEH_keys_get_state2 (true);
+ ksh = TEH_keys_get_state_for_management_only ();
if (NULL == ksh)
{
return TALER_MHD_reply_with_error (connection,
diff --git a/src/exchange/taler-exchange-httpd_keys.h b/src/exchange/taler-exchange-httpd_keys.h
index 7e8c1e995..8758afb71 100644
--- a/src/exchange/taler-exchange-httpd_keys.h
+++ b/src/exchange/taler-exchange-httpd_keys.h
@@ -168,18 +168,12 @@ TEH_check_invariants (void);
struct TEH_KeyStateHandle *
TEH_keys_get_state (void);
-
/**
- * Obtain the key state. Should ONLY be used
- * directly if @a management_only is true. Otherwise use #TEH_keys_get_state().
- *
- * @param management_only if we should NOT run finish_keys_response()
- * because we only need the state for the /management/keys API
- * @return NULL on error
+ * Obtain the key state if we should NOT run finish_keys_response() because we
+ * only need the state for the /management/keys API
*/
struct TEH_KeyStateHandle *
-TEH_keys_get_state2 (bool management_only);
-
+TEH_keys_get_state_for_management_only (void);
/**
* Something changed in the database. Rebuild all key states. This function
diff --git a/src/exchange/taler-exchange-httpd_management_post_keys.c b/src/exchange/taler-exchange-httpd_management_post_keys.c
index 7d9853e9b..df351ad5f 100644
--- a/src/exchange/taler-exchange-httpd_management_post_keys.c
+++ b/src/exchange/taler-exchange-httpd_management_post_keys.c
@@ -376,8 +376,7 @@ TEH_handler_management_post_keys (
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received /management/keys\n");
- akc.ksh = TEH_keys_get_state2 (true); /* may start its own transaction, thus
- must be done here, before we run ours! */
+ akc.ksh = TEH_keys_get_state_for_management_only (); /* may start its own transaction, thus must be done here, before we run ours! */
if (NULL == akc.ksh)
{
GNUNET_break_op (0);
diff --git a/src/lib/exchange_api_withdraw.c b/src/lib/exchange_api_withdraw.c
index 6643cac6c..62c042039 100644
--- a/src/lib/exchange_api_withdraw.c
+++ b/src/lib/exchange_api_withdraw.c
@@ -232,7 +232,7 @@ withdraw_cs_stage_two_callback (
&wh->pd))
{
GNUNET_break (0);
- GNUNET_free (wh);
+ break;
}
wh->wh2 = TALER_EXCHANGE_withdraw2 (wh->exchange,
&wh->pd,
diff --git a/src/templating/mustach-jansson.c b/src/templating/mustach-jansson.c
index 2aed58291..c65fe2b01 100644
--- a/src/templating/mustach-jansson.c
+++ b/src/templating/mustach-jansson.c
@@ -82,7 +82,7 @@ struct JanssonClosure
* Last bang we found.
*/
enum Bang found_bang;
-
+
/**
* Language for i18n lookups.
*/
@@ -129,11 +129,11 @@ find (struct JanssonClosure *e, const char *name)
if (0 == strcmp (bang, "i18n"))
e->found_bang = BANG_I18N;
- else if (0 == strcmp(bang, "stringify"))
+ else if (0 == strcmp (bang, "stringify"))
e->found_bang = BANG_STRINGIFY;
- else if (0 == strcmp(bang, "amount_decimal"))
+ else if (0 == strcmp (bang, "amount_decimal"))
e->found_bang = BANG_AMOUNT_CURRENCY;
- else if (0 == strcmp(bang, "amount_currency"))
+ else if (0 == strcmp (bang, "amount_currency"))
e->found_bang = BANG_AMOUNT_DECIMAL;
}
@@ -157,7 +157,7 @@ find (struct JanssonClosure *e, const char *name)
static int
-start(void *closure)
+start (void *closure)
{
struct JanssonClosure *e = closure;
e->depth = 0;
@@ -174,25 +174,25 @@ static int
emituw (void *closure, const char *buffer, size_t size, int escape, FILE *file)
{
struct JanssonClosure *e = closure;
- if (!escape)
+ if (! escape)
e->writecb (file, buffer, size);
else
do
{
switch (*buffer)
{
- case '<':
- e->writecb (file, "&lt;", 4);
- break;
- case '>':
- e->writecb (file, "&gt;", 4);
- break;
- case '&':
- e->writecb (file, "&amp;", 5);
- break;
- default:
- e->writecb (file, buffer, 1);
- break;
+ case '<':
+ e->writecb (file, "&lt;", 4);
+ break;
+ case '>':
+ e->writecb (file, "&gt;", 4);
+ break;
+ case '&':
+ e->writecb (file, "&amp;", 5);
+ break;
+ default:
+ e->writecb (file, buffer, 1);
+ break;
}
buffer++;
}
@@ -202,10 +202,10 @@ emituw (void *closure, const char *buffer, size_t size, int escape, FILE *file)
static int
-enter(void *closure, const char *name)
+enter (void *closure, const char *name)
{
struct JanssonClosure *e = closure;
- json_t *o = find(e, name);
+ json_t *o = find (e, name);
if (++e->depth >= MUSTACH_MAX_DEPTH)
return MUSTACH_ERROR_TOO_DEEP;
@@ -277,6 +277,7 @@ next (void *closure)
return 1;
}
+
static int
leave (void *closure)
{
@@ -287,12 +288,14 @@ leave (void *closure)
return 0;
}
+
static void
freecb (void *v)
{
free (v);
}
+
static int
get (void *closure, const char *name, struct mustach_sbuf *sbuf)
{
@@ -300,7 +303,7 @@ get (void *closure, const char *name, struct mustach_sbuf *sbuf)
json_t *obj;
if ( (0 == strcmp (name, "*") ) &&
- (e->stack[e->depth].is_objiter ) )
+ (e->stack[e->depth].is_objiter) )
{
sbuf->value = json_object_iter_key (e->stack[e->depth].iter);
return MUSTACH_OK;
@@ -310,64 +313,65 @@ get (void *closure, const char *name, struct mustach_sbuf *sbuf)
{
switch (e->found_bang)
{
- case BANG_I18N:
- case BANG_NONE:
- {
- const char *s = json_string_value (obj);
- if (NULL != s)
- {
- sbuf->value = s;
- return MUSTACH_OK;
- }
- }
- break;
- case BANG_STRINGIFY:
- sbuf->value = json_dumps (obj, JSON_INDENT (2));
- sbuf->freecb = freecb;
- return MUSTACH_OK;
- case BANG_AMOUNT_DECIMAL:
+ case BANG_I18N:
+ case BANG_NONE:
+ {
+ const char *s = json_string_value (obj);
+ if (NULL != s)
{
- char *s;
- char *c;
- if (!json_is_string (obj))
- break;
- s = strdup (json_string_value (obj));
- c = strchr (s, ':');
- if (NULL != c)
- *c = 0;
sbuf->value = s;
- sbuf->freecb = freecb;
- return MUSTACH_OK;
- }
- break;
- case BANG_AMOUNT_CURRENCY:
- {
- const char *s;
- if (!json_is_string (obj))
- break;
- s = json_string_value (obj);
- s = strchr (s, ':');
- if (NULL == s)
- break;
- sbuf->value = s + 1;
return MUSTACH_OK;
}
- break;
- default:
- break;
+ }
+ break;
+ case BANG_STRINGIFY:
+ sbuf->value = json_dumps (obj, JSON_INDENT (2));
+ sbuf->freecb = freecb;
+ return MUSTACH_OK;
+ case BANG_AMOUNT_DECIMAL:
+ {
+ char *s;
+ char *c;
+ if (! json_is_string (obj))
+ break;
+ s = GNUNET_strdup (json_string_value (obj));
+ c = strchr (s, ':');
+ if (NULL != c)
+ *c = 0;
+ sbuf->value = s;
+ sbuf->freecb = freecb;
+ return MUSTACH_OK;
+ }
+ break;
+ case BANG_AMOUNT_CURRENCY:
+ {
+ const char *s;
+ if (! json_is_string (obj))
+ break;
+ s = json_string_value (obj);
+ s = strchr (s, ':');
+ if (NULL == s)
+ break;
+ sbuf->value = s + 1;
+ return MUSTACH_OK;
+ }
+ break;
+ default:
+ break;
}
}
sbuf->value = "";
return MUSTACH_OK;
}
+
static struct mustach_itf itf = {
.start = start,
.put = NULL,
.enter = enter,
.next = next,
.leave = leave,
- .partial =NULL,
+ .partial = NULL,
.get = get,
.emit = NULL,
.stop = NULL
@@ -385,33 +389,41 @@ static struct mustach_itf itfuw = {
.stop = NULL
};
-int fmustach_jansson (const char *template, json_t *root, FILE *file)
+int
+fmustach_jansson (const char *template, json_t *root, FILE *file)
{
struct JanssonClosure e = { 0 };
e.root = root;
- return fmustach(template, &itf, &e, file);
+ return fmustach (template, &itf, &e, file);
}
-int fdmustach_jansson (const char *template, json_t *root, int fd)
+
+int
+fdmustach_jansson (const char *template, json_t *root, int fd)
{
struct JanssonClosure e = { 0 };
e.root = root;
- return fdmustach(template, &itf, &e, fd);
+ return fdmustach (template, &itf, &e, fd);
}
-int mustach_jansson (const char *template, json_t *root, char **result, size_t *size)
+
+int
+mustach_jansson (const char *template, json_t *root, char **result,
+ size_t *size)
{
struct JanssonClosure e = { 0 };
e.root = root;
e.writecb = NULL;
- return mustach(template, &itf, &e, result, size);
+ return mustach (template, &itf, &e, result, size);
}
-int umustach_jansson (const char *template, json_t *root, mustach_jansson_write_cb writecb, void *closure)
+
+int
+umustach_jansson (const char *template, json_t *root, mustach_jansson_write_cb
+ writecb, void *closure)
{
struct JanssonClosure e = { 0 };
e.root = root;
e.writecb = writecb;
- return fmustach(template, &itfuw, &e, closure);
+ return fmustach (template, &itfuw, &e, closure);
}
-
diff --git a/src/testing/testing_api_cmd_contract_get.c b/src/testing/testing_api_cmd_contract_get.c
index 10a43aa3b..428bf7e8c 100644
--- a/src/testing/testing_api_cmd_contract_get.c
+++ b/src/testing/testing_api_cmd_contract_get.c
@@ -115,6 +115,7 @@ get_cb (void *cls,
}
ref = TALER_TESTING_interpreter_lookup_command (ds->is,
ds->contract_ref);
+ GNUNET_assert (NULL != ref);
if (MHD_HTTP_OK == dr->hr.http_status)
{
const struct TALER_PurseMergePrivateKeyP *mp;
diff --git a/src/testing/testing_api_cmd_exec_closer.c b/src/testing/testing_api_cmd_exec_closer.c
index 9ee436af0..2501b39a6 100644
--- a/src/testing/testing_api_cmd_exec_closer.c
+++ b/src/testing/testing_api_cmd_exec_closer.c
@@ -91,6 +91,7 @@ closer_run (void *cls,
rcmd = TALER_TESTING_interpreter_lookup_command (is,
as->reserve_ref);
+ GNUNET_assert (NULL != rcmd);
if (GNUNET_OK !=
TALER_TESTING_get_trait_reserve_pub (rcmd,
&reserve_pubp))
diff --git a/src/testing/testing_api_cmd_purse_deposit.c b/src/testing/testing_api_cmd_purse_deposit.c
index b056497e3..ff8e6d2e3 100644
--- a/src/testing/testing_api_cmd_purse_deposit.c
+++ b/src/testing/testing_api_cmd_purse_deposit.c
@@ -163,7 +163,7 @@ deposit_cb (void *cls,
purse_cmd = TALER_TESTING_interpreter_lookup_command (ds->is,
ds->purse_ref);
-
+ GNUNET_assert (NULL != purse_cmd);
if (GNUNET_OK !=
TALER_TESTING_get_trait_reserve_sig (purse_cmd,
&reserve_sig))
@@ -270,6 +270,7 @@ deposit_run (void *cls,
purse_cmd = TALER_TESTING_interpreter_lookup_command (is,
ds->purse_ref);
+ GNUNET_assert (NULL != purse_cmd);
if (GNUNET_OK !=
TALER_TESTING_get_trait_purse_pub (purse_cmd,
&purse_pub))
@@ -291,13 +292,7 @@ deposit_run (void *cls,
coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
cr->command_ref);
- if (NULL == coin_cmd)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (is);
- return;
- }
-
+ GNUNET_assert (NULL != coin_cmd);
if ( (GNUNET_OK !=
TALER_TESTING_get_trait_coin_priv (coin_cmd,
cr->coin_index,
diff --git a/src/testing/testing_api_cmd_purse_get.c b/src/testing/testing_api_cmd_purse_get.c
index 61873721b..3e7da38f0 100644
--- a/src/testing/testing_api_cmd_purse_get.c
+++ b/src/testing/testing_api_cmd_purse_get.c
@@ -188,13 +188,7 @@ status_run (void *cls,
create_purse
= TALER_TESTING_interpreter_lookup_command (is,
ss->purse_reference);
-
- if (NULL == create_purse)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (is);
- return;
- }
+ GNUNET_assert (NULL != create_purse);
if (GNUNET_OK !=
TALER_TESTING_get_trait_purse_pub (create_purse,
&ss->purse_pub))
@@ -311,6 +305,7 @@ finish_run (void *cls,
poll_purse
= TALER_TESTING_interpreter_lookup_command (is,
ps->poll_reference);
+ GNUNET_assert (NULL != poll_purse);
GNUNET_assert (poll_purse->run == &status_run);
ss = poll_purse->cls;
if (NULL == ss->pgh)
diff --git a/src/testing/testing_api_cmd_reserve_get.c b/src/testing/testing_api_cmd_reserve_get.c
index f9b8ff6cd..22c29a3be 100644
--- a/src/testing/testing_api_cmd_reserve_get.c
+++ b/src/testing/testing_api_cmd_reserve_get.c
@@ -183,13 +183,7 @@ status_run (void *cls,
create_reserve
= TALER_TESTING_interpreter_lookup_command (is,
ss->reserve_reference);
-
- if (NULL == create_reserve)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (is);
- return;
- }
+ GNUNET_assert (NULL != create_reserve);
if (GNUNET_OK !=
TALER_TESTING_get_trait_reserve_pub (create_reserve,
&ss->reserve_pubp))
@@ -328,6 +322,7 @@ finish_run (void *cls,
poll_reserve
= TALER_TESTING_interpreter_lookup_command (is,
ps->poll_reference);
+ GNUNET_assert (NULL != poll_reserve);
GNUNET_assert (poll_reserve->run == &status_run);
ss = poll_reserve->cls;
if (NULL == ss->rsh)
diff --git a/src/testing/testing_api_cmd_wire.c b/src/testing/testing_api_cmd_wire.c
index 4b0a177b5..6e44403bc 100644
--- a/src/testing/testing_api_cmd_wire.c
+++ b/src/testing/testing_api_cmd_wire.c
@@ -105,6 +105,12 @@ wire_cb (void *cls,
char *method;
method = TALER_payto_get_method (accounts[i].payto_uri);
+ if (NULL == method)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ws->is);
+ return;
+ }
if (0 == strcmp (ws->expected_method,
method))
{