aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing_api_cmd_refresh.c31
-rw-r--r--src/testing/testing_api_helpers_exchange.c32
2 files changed, 39 insertions, 24 deletions
diff --git a/src/testing/testing_api_cmd_refresh.c b/src/testing/testing_api_cmd_refresh.c
index dd861fae1..2f91df377 100644
--- a/src/testing/testing_api_cmd_refresh.c
+++ b/src/testing/testing_api_cmd_refresh.c
@@ -28,6 +28,10 @@
#include "taler_signatures.h"
#include "backoff.h"
+/**
+ * How often do we retry before giving up?
+ */
+#define NUM_RETRIES 5
/**
* Information about a fresh coin generated by the refresh
@@ -149,9 +153,9 @@ struct RefreshMeltState
unsigned int double_melt;
/**
- * Should we retry on (transient) failures?
+ * How often should we retry on (transient) failures?
*/
- int do_retry;
+ unsigned int do_retry;
/**
* Set by the melt callback as it comes from the exchange.
@@ -210,9 +214,9 @@ struct RefreshRevealState
unsigned int expected_response_code;
/**
- * Should we retry on (transient) failures?
+ * How often should we retry on (transient) failures?
*/
- int do_retry;
+ unsigned int do_retry;
};
@@ -253,9 +257,9 @@ struct RefreshLinkState
unsigned int expected_response_code;
/**
- * Should we retry on (transient) failures?
+ * How often should we retry on (transient) failures?
*/
- int do_retry;
+ unsigned int do_retry;
};
@@ -322,8 +326,9 @@ reveal_cb (void *cls,
rrs->rrh = NULL;
if (rrs->expected_response_code != http_status)
{
- if (GNUNET_YES == rrs->do_retry)
+ if (0 != rrs->do_retry)
{
+ rrs->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@@ -548,8 +553,9 @@ link_cb (void *cls,
rls->rlh = NULL;
if (rls->expected_response_code != http_status)
{
- if (GNUNET_YES == rls->do_retry)
+ if (0 != rls->do_retry)
{
+ rls->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@@ -830,8 +836,9 @@ melt_cb (void *cls,
rms->rmh = NULL;
if (rms->expected_response_code != http_status)
{
- if (GNUNET_YES == rms->do_retry)
+ if (0 != rms->do_retry)
{
+ rms->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@@ -1246,7 +1253,7 @@ TALER_TESTING_cmd_melt_with_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&melt_run == cmd.run);
rms = cmd.cls;
- rms->do_retry = GNUNET_YES;
+ rms->do_retry = NUM_RETRIES;
return cmd;
}
@@ -1356,7 +1363,7 @@ TALER_TESTING_cmd_refresh_reveal_with_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&refresh_reveal_run == cmd.run);
rrs = cmd.cls;
- rrs->do_retry = GNUNET_YES;
+ rrs->do_retry = NUM_RETRIES;
return cmd;
}
@@ -1405,6 +1412,6 @@ TALER_TESTING_cmd_refresh_link_with_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&refresh_link_run == cmd.run);
rls = cmd.cls;
- rls->do_retry = GNUNET_YES;
+ rls->do_retry = NUM_RETRIES;
return cmd;
}
diff --git a/src/testing/testing_api_helpers_exchange.c b/src/testing/testing_api_helpers_exchange.c
index bed6bc8d5..56f8bd548 100644
--- a/src/testing/testing_api_helpers_exchange.c
+++ b/src/testing/testing_api_helpers_exchange.c
@@ -368,6 +368,11 @@ struct SignInfo
* calling #TALER_TESTING_sign_keys_for_exchange.
*/
const char *auditor_sign_input_filename;
+
+ /**
+ * Did we reset the database?
+ */
+ int db_reset;
};
@@ -448,23 +453,25 @@ sign_keys_for_exchange (void *cls,
ret = GNUNET_SYSERR;
goto fail;
}
- if (GNUNET_OK !=
- TALER_TESTING_run_auditor_exchange (si->config_filename,
- exchange_master_pub,
- si->ec->exchange_url,
- GNUNET_NO))
+ if ( (GNUNET_OK !=
+ TALER_TESTING_run_auditor_exchange (si->config_filename,
+ exchange_master_pub,
+ si->ec->exchange_url,
+ GNUNET_NO)) &&
+ (GNUNET_YES == si->db_reset) )
{
GNUNET_free (signed_keys_out);
ret = GNUNET_NO;
goto fail;
}
- if (GNUNET_OK !=
- TALER_TESTING_run_auditor_sign (si->config_filename,
- exchange_master_pub,
- si->ec->auditor_url,
- si->auditor_sign_input_filename,
- signed_keys_out))
+ if ( (GNUNET_OK !=
+ TALER_TESTING_run_auditor_sign (si->config_filename,
+ exchange_master_pub,
+ si->ec->auditor_url,
+ si->auditor_sign_input_filename,
+ signed_keys_out)) &&
+ (GNUNET_YES == si->db_reset) )
{
GNUNET_free (signed_keys_out);
GNUNET_free (exchange_master_pub);
@@ -503,7 +510,8 @@ TALER_TESTING_prepare_exchange (const char *config_filename,
struct SignInfo si = {
.config_filename = config_filename,
.ec = ec,
- .auditor_sign_input_filename = "auditor.in"
+ .auditor_sign_input_filename = "auditor.in",
+ .db_reset = reset_db
};
if (GNUNET_OK !=