Triggering doubled /refresh/melt, plus prepare ground for twisting the /refresh/reveal
This commit is contained in:
parent
6a0be254cc
commit
08824870e6
@ -290,7 +290,7 @@ run (void *cls,
|
|||||||
/**
|
/**
|
||||||
* Melt the rest of the coin's value
|
* Melt the rest of the coin's value
|
||||||
* (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */
|
* (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-melt-1", is->exchange, "EUR:4",
|
||||||
"refresh-withdraw-coin-1", MHD_HTTP_OK),
|
"refresh-withdraw-coin-1", MHD_HTTP_OK),
|
||||||
/**
|
/**
|
||||||
|
@ -114,7 +114,7 @@ static struct GNUNET_OS_Process *twisterd;
|
|||||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||||
TALER_TESTING_cmd_fakebank_transfer (label, amount, \
|
TALER_TESTING_cmd_fakebank_transfer (label, amount, \
|
||||||
fakebank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \
|
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
|
* Run wire transfer of funds from some user's account to the
|
||||||
@ -142,6 +142,48 @@ run (void *cls,
|
|||||||
|
|
||||||
struct TALER_TESTING_Command commands[] = {
|
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
|
* End the suite. Fixme: better to have a label for this
|
||||||
* too, as it shows a "(null)" token on logs.
|
* too, as it shows a "(null)" token on logs.
|
||||||
|
@ -33,6 +33,24 @@ TALER_TEST_HOME = test_exchange_api_home/
|
|||||||
# Currency supported by the exchange (can only be one)
|
# Currency supported by the exchange (can only be one)
|
||||||
CURRENCY = EUR
|
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]
|
[exchange]
|
||||||
|
|
||||||
# HTTP port the exchange listens to
|
# HTTP port the exchange listens to
|
||||||
|
@ -56,6 +56,20 @@ struct MeltDetails
|
|||||||
*/
|
*/
|
||||||
struct RefreshMeltState
|
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.
|
* Fixme: figure out this data purpose.
|
||||||
*/
|
*/
|
||||||
@ -628,6 +642,18 @@ melt_cb (void *cls,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rms->noreveal_index = noreveal_index;
|
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);
|
TALER_TESTING_interpreter_next (rms->is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,6 +892,49 @@ TALER_TESTING_cmd_refresh_melt
|
|||||||
return cmd;
|
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
|
* Extract information from a command that is useful for other
|
||||||
* commands.
|
* commands.
|
||||||
|
@ -259,9 +259,12 @@ refresh_melt_transaction (void *cls,
|
|||||||
&rm);
|
&rm);
|
||||||
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
|
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
|
||||||
{
|
{
|
||||||
|
TALER_LOG_DEBUG ("Found already-melted coin\n");
|
||||||
*mhd_ret = reply_refresh_melt_success (connection,
|
*mhd_ret = reply_refresh_melt_success (connection,
|
||||||
&rmc->refresh_session.rc,
|
&rmc->refresh_session.rc,
|
||||||
rm.session.noreveal_index);
|
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;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
}
|
}
|
||||||
if (0 > qs)
|
if (0 > qs)
|
||||||
|
@ -660,6 +660,26 @@ TALER_TESTING_cmd_refresh_melt
|
|||||||
const char *coin_reference,
|
const char *coin_reference,
|
||||||
unsigned int expected_response_code);
|
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.
|
* Create a "refresh reveal" command.
|
||||||
|
Loading…
Reference in New Issue
Block a user