Triggering doubled /refresh/melt, plus prepare ground for twisting the /refresh/reveal

This commit is contained in:
Marcello Stanisci 2018-05-14 14:50:27 +02:00
parent 6a0be254cc
commit 08824870e6
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
6 changed files with 154 additions and 2 deletions

View File

@ -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),
/**

View File

@ -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.

View File

@ -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

View File

@ -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);
}
@ -866,6 +892,49 @@ TALER_TESTING_cmd_refresh_melt
return cmd;
}
/**
* 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.

View File

@ -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)

View File

@ -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.