summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/exchange-lib/test_exchange_api_new.c2
-rw-r--r--src/exchange-lib/test_exchange_api_twisted.c44
-rw-r--r--src/exchange-lib/test_exchange_api_twisted.conf18
-rw-r--r--src/exchange-lib/testing_api_cmd_refresh.c69
-rw-r--r--src/exchange/taler-exchange-httpd_refresh_melt.c3
-rw-r--r--src/include/taler_testing_lib.h20
6 files changed, 154 insertions, 2 deletions
diff --git a/src/exchange-lib/test_exchange_api_new.c b/src/exchange-lib/test_exchange_api_new.c
index a33f8d014..8d39ca087 100644
--- a/src/exchange-lib/test_exchange_api_new.c
+++ b/src/exchange-lib/test_exchange_api_new.c
@@ -290,7 +290,7 @@ run (void *cls,
/**
* Melt the rest of the coin's value
* (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */
- TALER_TESTING_cmd_refresh_melt
+ TALER_TESTING_cmd_refresh_melt_double
("refresh-melt-1", is->exchange, "EUR:4",
"refresh-withdraw-coin-1", MHD_HTTP_OK),
/**
diff --git a/src/exchange-lib/test_exchange_api_twisted.c b/src/exchange-lib/test_exchange_api_twisted.c
index 8c2492816..3b875cd5e 100644
--- a/src/exchange-lib/test_exchange_api_twisted.c
+++ b/src/exchange-lib/test_exchange_api_twisted.c
@@ -114,7 +114,7 @@ static struct GNUNET_OS_Process *twisterd;
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
TALER_TESTING_cmd_fakebank_transfer (label, amount, \
fakebank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \
- USER_LOGIN_NAME, USER_LOGIN_PASS, EXCHANGE_URL)
+ USER_LOGIN_NAME, USER_LOGIN_PASS, exchange_url)
/**
* Run wire transfer of funds from some user's account to the
@@ -142,6 +142,48 @@ run (void *cls,
struct TALER_TESTING_Command commands[] = {
+ CMD_TRANSFER_TO_EXCHANGE ("refresh-create-reserve",
+ "EUR:5.01"),
+
+ /**
+ * Make previous command effective.
+ */
+ CMD_EXEC_WIREWATCH ("wirewatch"),
+
+ /**
+ * Withdraw EUR:5.
+ */
+ TALER_TESTING_cmd_withdraw_amount
+ ("refresh-withdraw-coin",
+ is->exchange,
+ "refresh-create-reserve",
+ "EUR:5",
+ MHD_HTTP_OK),
+
+ TALER_TESTING_cmd_deposit
+ ("refresh-deposit-partial",
+ is->exchange,
+ "refresh-withdraw-coin",
+ 0,
+ TALER_TESTING_make_wire_details
+ (42,
+ fakebank_url),
+ "{\"items\":[{\"name\":\"ice cream\",\
+ \"value\":\"EUR:1\"}]}",
+ GNUNET_TIME_UNIT_ZERO,
+ "EUR:1",
+ MHD_HTTP_OK),
+
+ /**
+ * Melt the rest of the coin's value
+ * (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */
+ TALER_TESTING_cmd_refresh_melt
+ ("refresh-melt",
+ is->exchange,
+ "EUR:4",
+ "refresh-withdraw-coin",
+ MHD_HTTP_OK),
+
/**
* End the suite. Fixme: better to have a label for this
* too, as it shows a "(null)" token on logs.
diff --git a/src/exchange-lib/test_exchange_api_twisted.conf b/src/exchange-lib/test_exchange_api_twisted.conf
index 992e878c7..d64ea6596 100644
--- a/src/exchange-lib/test_exchange_api_twisted.conf
+++ b/src/exchange-lib/test_exchange_api_twisted.conf
@@ -33,6 +33,24 @@ TALER_TEST_HOME = test_exchange_api_home/
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
+[exchange_keys]
+
+# how long is one signkey valid?
+signkey_duration = 4 weeks
+
+# how long are the signatures with the signkey valid?
+legal_duration = 2 years
+
+# how long do we generate denomination and signing keys
+# ahead of time?
+lookahead_sign = 32 weeks 1 day
+
+# how long do we provide to clients denomination and signing keys
+# ahead of time?
+lookahead_provide = 4 weeks 1 day
+
+
+
[exchange]
# HTTP port the exchange listens to
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.
*
diff --git a/src/exchange/taler-exchange-httpd_refresh_melt.c b/src/exchange/taler-exchange-httpd_refresh_melt.c
index 384589df1..08ceaa868 100644
--- a/src/exchange/taler-exchange-httpd_refresh_melt.c
+++ b/src/exchange/taler-exchange-httpd_refresh_melt.c
@@ -259,9 +259,12 @@ refresh_melt_transaction (void *cls,
&rm);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
{
+ TALER_LOG_DEBUG ("Found already-melted coin\n");
*mhd_ret = reply_refresh_melt_success (connection,
&rmc->refresh_session.rc,
rm.session.noreveal_index);
+ /* FIXME: is it normal to return "hard error" upon
+ * _finding_ some data into the database? */
return GNUNET_DB_STATUS_HARD_ERROR;
}
if (0 > qs)
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index dce92ceae..910495e4b 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -660,6 +660,26 @@ TALER_TESTING_cmd_refresh_melt
const char *coin_reference,
unsigned int expected_response_code);
+/**
+ * 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);
+
/**
* Create a "refresh reveal" command.