summaryrefslogtreecommitdiff
path: root/src/exchange-lib/testing_api_cmd_refresh.c
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-05-14 14:50:27 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-05-14 22:32:13 +0200
commit08824870e6cb6b91bf43936357361d82f8017dc6 (patch)
treeea0b0fe85d31d901456e984f09968216dd988147 /src/exchange-lib/testing_api_cmd_refresh.c
parent6a0be254cc7a630da2f508119573338245277e56 (diff)
downloadexchange-08824870e6cb6b91bf43936357361d82f8017dc6.tar.gz
exchange-08824870e6cb6b91bf43936357361d82f8017dc6.tar.bz2
exchange-08824870e6cb6b91bf43936357361d82f8017dc6.zip
Triggering doubled /refresh/melt, plus prepare ground for twisting the /refresh/reveal
Diffstat (limited to 'src/exchange-lib/testing_api_cmd_refresh.c')
-rw-r--r--src/exchange-lib/testing_api_cmd_refresh.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/exchange-lib/testing_api_cmd_refresh.c b/src/exchange-lib/testing_api_cmd_refresh.c
index 8233f673c..97f06cc30 100644
--- a/src/exchange-lib/testing_api_cmd_refresh.c
+++ b/src/exchange-lib/testing_api_cmd_refresh.c
@@ -56,6 +56,20 @@ struct MeltDetails
*/
struct RefreshMeltState
{
+
+ /**
+ * if set to GNUNET_YES, then two /refresh/melt operations
+ * will be performed. This is needed to trigger the code
+ * path that manages those already-made requests. Note: it
+ * is not possible to just copy-and-paste a test refresh melt
+ * CMD to have the same effect, because every data preparation
+ * generates new planchets that (in turn) make the whole "hash"
+ * different from any previous one, therefore NOT allowing the
+ * exchange to pick any previous /rerfesh/melt operation from
+ * the database.
+ */
+ unsigned int double_melt;
+
/**
* Fixme: figure out this data purpose.
*/
@@ -628,6 +642,18 @@ melt_cb (void *cls,
return;
}
rms->noreveal_index = noreveal_index;
+
+ if (GNUNET_YES == rms->double_melt)
+ {
+ TALER_LOG_DEBUG ("Doubling the melt (%s)\n",
+ rms->is->commands[rms->is->ip].label);
+ rms->rmh = TALER_EXCHANGE_refresh_melt
+ (rms->exchange, rms->refresh_data_length,
+ rms->refresh_data, &melt_cb, rms);
+ rms->double_melt = GNUNET_NO;
+ return;
+ }
+
TALER_TESTING_interpreter_next (rms->is);
}
@@ -867,6 +893,49 @@ TALER_TESTING_cmd_refresh_melt
}
/**
+ * Create a "refresh melt" command, that does TWO /refresh/melt
+ * requests.
+ *
+ * @param label command label
+ * @param exchange connection to the exchange
+ * @param amount Fixme
+ * @param coin_reference reference to a command that will provide
+ * a coin to refresh
+ * @param expected_response_code expected HTTP code
+ */
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_refresh_melt_double
+ (const char *label,
+ struct TALER_EXCHANGE_Handle *exchange,
+ const char *amount,
+ const char *coin_reference,
+ unsigned int expected_response_code)
+{
+ struct RefreshMeltState *rms;
+ struct MeltDetails md;
+ struct TALER_TESTING_Command cmd;
+
+ md.coin_reference = coin_reference;
+ md.amount = amount;
+
+ rms = GNUNET_new (struct RefreshMeltState);
+ rms->amount = amount;
+ rms->melted_coin = md;
+ rms->expected_response_code = expected_response_code;
+ rms->exchange = exchange;
+ rms->double_melt = GNUNET_YES;
+
+ cmd.label = label;
+ cmd.cls = rms;
+ cmd.run = &refresh_melt_run;
+ cmd.cleanup = &refresh_melt_cleanup;
+ cmd.traits = &refresh_melt_traits;
+
+ return cmd;
+}
+
+/**
* Extract information from a command that is useful for other
* commands.
*