work towards testing auditor deposit-confirmation API
This commit is contained in:
parent
17edb09f38
commit
4d058c4eb7
@ -41,6 +41,7 @@ libtalerauditortesting_la_LDFLAGS = \
|
|||||||
-no-undefined
|
-no-undefined
|
||||||
libtalerauditortesting_la_SOURCES = \
|
libtalerauditortesting_la_SOURCES = \
|
||||||
testing_auditor_api_helpers.c \
|
testing_auditor_api_helpers.c \
|
||||||
|
testing_auditor_api_cmd_deposit_confirmation.c \
|
||||||
testing_auditor_api_cmd_exec_auditor.c \
|
testing_auditor_api_cmd_exec_auditor.c \
|
||||||
testing_auditor_api_cmd_exec_wire_auditor.c
|
testing_auditor_api_cmd_exec_wire_auditor.c
|
||||||
libtalerauditortesting_la_LIBADD = \
|
libtalerauditortesting_la_LIBADD = \
|
||||||
|
@ -156,7 +156,7 @@ verify_signatures (const struct GNUNET_HashCode *h_wire,
|
|||||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
||||||
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
||||||
const struct TALER_CoinSpendSignatureP *exchange_sig,
|
const struct TALER_ExchangeSignatureP *exchange_sig,
|
||||||
const struct TALER_MasterPublicKeyP *master_pub,
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
struct GNUNET_TIME_Absolute ep_start,
|
struct GNUNET_TIME_Absolute ep_start,
|
||||||
struct GNUNET_TIME_Absolute ep_expire,
|
struct GNUNET_TIME_Absolute ep_expire,
|
||||||
@ -181,7 +181,7 @@ verify_signatures (const struct GNUNET_HashCode *h_wire,
|
|||||||
&dc.purpose,
|
&dc.purpose,
|
||||||
&exchange_sig->eddsa_signature,
|
&exchange_sig->eddsa_signature,
|
||||||
&exchange_pub->eddsa_pub))
|
&exchange_pub->eddsa_pub))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
TALER_LOG_WARNING ("Invalid signature on /deposit-confirmation request!\n");
|
TALER_LOG_WARNING ("Invalid signature on /deposit-confirmation request!\n");
|
||||||
{
|
{
|
||||||
@ -261,7 +261,7 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor,
|
|||||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
||||||
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
||||||
const struct TALER_CoinSpendSignatureP *exchange_sig,
|
const struct TALER_ExchangeSignatureP *exchange_sig,
|
||||||
const struct TALER_MasterPublicKeyP *master_pub,
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
struct GNUNET_TIME_Absolute ep_start,
|
struct GNUNET_TIME_Absolute ep_start,
|
||||||
struct GNUNET_TIME_Absolute ep_expire,
|
struct GNUNET_TIME_Absolute ep_expire,
|
||||||
|
374
src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c
Normal file
374
src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c
Normal file
@ -0,0 +1,374 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2018 Taler Systems SA
|
||||||
|
|
||||||
|
TALER is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
TALER is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public
|
||||||
|
License along with TALER; see the file COPYING. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c
|
||||||
|
* @brief command for testing /deposit_confirmation.
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include <gnunet/gnunet_curl_lib.h>
|
||||||
|
#include "taler_auditor_service.h"
|
||||||
|
#include "taler_testing_lib.h"
|
||||||
|
#include "taler_signatures.h"
|
||||||
|
#include "backoff.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* State for a "deposit confirmation" CMD.
|
||||||
|
*/
|
||||||
|
struct DepositConfirmationState
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to any command that is able to provide a deposit.
|
||||||
|
*/
|
||||||
|
const char *deposit_reference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which coin of the @e deposit_reference should we confirm.
|
||||||
|
*/
|
||||||
|
unsigned int coin_index;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DepositConfirmation handle while operation is running.
|
||||||
|
*/
|
||||||
|
struct TALER_AUDITOR_DepositConfirmationHandle *dc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auditor connection.
|
||||||
|
*/
|
||||||
|
struct TALER_AUDITOR_Handle *auditor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interpreter state.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Interpreter *is;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task scheduled to try later.
|
||||||
|
*/
|
||||||
|
struct GNUNET_SCHEDULER_Task *retry_task;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How long do we wait until we retry?
|
||||||
|
*/
|
||||||
|
struct GNUNET_TIME_Relative backoff;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expected HTTP response code.
|
||||||
|
*/
|
||||||
|
unsigned int expected_response_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should we retry on (transient) failures?
|
||||||
|
*/
|
||||||
|
int do_retry;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the command.
|
||||||
|
*
|
||||||
|
* @param cls closure.
|
||||||
|
* @param cmd the command to execute.
|
||||||
|
* @param is the interpreter state.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
deposit_confirmation_run (void *cls,
|
||||||
|
const struct TALER_TESTING_Command *cmd,
|
||||||
|
struct TALER_TESTING_Interpreter *is);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task scheduled to re-try #deposit_confirmation_run.
|
||||||
|
*
|
||||||
|
* @param cls a `struct DepositConfirmationState`
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
do_retry (void *cls)
|
||||||
|
{
|
||||||
|
struct DepositConfirmationState *dcs = cls;
|
||||||
|
|
||||||
|
dcs->retry_task = NULL;
|
||||||
|
deposit_confirmation_run (dcs,
|
||||||
|
NULL,
|
||||||
|
dcs->is);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback to analyze the /deposit-confirmation response, just used
|
||||||
|
* to check if the response code is acceptable.
|
||||||
|
*
|
||||||
|
* @param cls closure.
|
||||||
|
* @param http_status HTTP response code.
|
||||||
|
* @param ec taler-specific error code.
|
||||||
|
* @param obj raw response from the auditor.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
deposit_confirmation_cb (void *cls,
|
||||||
|
unsigned int http_status,
|
||||||
|
enum TALER_ErrorCode ec,
|
||||||
|
const json_t *obj)
|
||||||
|
{
|
||||||
|
struct DepositConfirmationState *dcs = cls;
|
||||||
|
|
||||||
|
dcs->dc = NULL;
|
||||||
|
if (dcs->expected_response_code != http_status)
|
||||||
|
{
|
||||||
|
if (GNUNET_YES == dcs->do_retry)
|
||||||
|
{
|
||||||
|
if ( (0 == http_status) ||
|
||||||
|
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
|
||||||
|
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
|
"Retrying deposit confirmation failed with %u/%d\n",
|
||||||
|
http_status,
|
||||||
|
(int) ec);
|
||||||
|
/* on DB conflicts, do not use backoff */
|
||||||
|
if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
|
||||||
|
dcs->backoff = GNUNET_TIME_UNIT_ZERO;
|
||||||
|
else
|
||||||
|
dcs->backoff = AUDITOR_LIB_BACKOFF (dcs->backoff);
|
||||||
|
dcs->retry_task = GNUNET_SCHEDULER_add_delayed (dcs->backoff,
|
||||||
|
&do_retry,
|
||||||
|
dcs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Unexpected response code %u to command %s in %s:%u\n",
|
||||||
|
http_status,
|
||||||
|
dcs->is->commands[dcs->is->ip].label,
|
||||||
|
__FILE__,
|
||||||
|
__LINE__);
|
||||||
|
json_dumpf (obj, stderr, 0);
|
||||||
|
TALER_TESTING_interpreter_fail (dcs->is);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TALER_TESTING_interpreter_next (dcs->is);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the command.
|
||||||
|
*
|
||||||
|
* @param cls closure.
|
||||||
|
* @param cmd the command to execute.
|
||||||
|
* @param is the interpreter state.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
deposit_confirmation_run (void *cls,
|
||||||
|
const struct TALER_TESTING_Command *cmd,
|
||||||
|
struct TALER_TESTING_Interpreter *is)
|
||||||
|
{
|
||||||
|
struct DepositConfirmationState *dcs = cls;
|
||||||
|
const struct TALER_TESTING_Command *deposit_cmd;
|
||||||
|
struct TALER_TESTING_Command *this_cmd;
|
||||||
|
struct GNUNET_HashCode h_wire;
|
||||||
|
struct GNUNET_HashCode h_contract_terms;
|
||||||
|
struct GNUNET_TIME_Absolute timestamp;
|
||||||
|
struct GNUNET_TIME_Absolute refund_deadline;
|
||||||
|
const struct TALER_Amount *amount_without_fee;
|
||||||
|
const struct TALER_CoinSpendPublicKeyP *coin_pub;
|
||||||
|
const struct TALER_MerchantPublicKeyP *merchant_pub;
|
||||||
|
const struct TALER_ExchangePublicKeyP *exchange_pub;
|
||||||
|
const struct TALER_ExchangeSignatureP *exchange_sig;
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub;
|
||||||
|
struct GNUNET_TIME_Absolute ep_start;
|
||||||
|
struct GNUNET_TIME_Absolute ep_expire;
|
||||||
|
struct GNUNET_TIME_Absolute ep_end;
|
||||||
|
const struct TALER_MasterSignatureP *master_sig;
|
||||||
|
const json_t *wire_details;
|
||||||
|
const json_t *contract_terms;
|
||||||
|
|
||||||
|
dcs->is = is;
|
||||||
|
this_cmd = &is->commands[is->ip]; // use this_cmd->label for logging!
|
||||||
|
GNUNET_assert (NULL != dcs->deposit_reference);
|
||||||
|
deposit_cmd
|
||||||
|
= TALER_TESTING_interpreter_lookup_command (is,
|
||||||
|
dcs->deposit_reference);
|
||||||
|
if (NULL == deposit_cmd)
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
TALER_TESTING_interpreter_fail (is);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
TALER_TESTING_get_trait_exchange_pub (deposit_cmd,
|
||||||
|
dcs->coin_index,
|
||||||
|
&exchange_pub));
|
||||||
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
TALER_TESTING_get_trait_exchange_sig (deposit_cmd,
|
||||||
|
dcs->coin_index,
|
||||||
|
&exchange_sig));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
TALER_TESTING_get_trait_contract_terms (deposit_cmd,
|
||||||
|
dcs->coin_index,
|
||||||
|
&contract_terms));
|
||||||
|
TALER_JSON_hash (contract_terms,
|
||||||
|
&h_contract_terms);
|
||||||
|
#endif
|
||||||
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
TALER_TESTING_get_trait_wire_details (deposit_cmd,
|
||||||
|
dcs->coin_index,
|
||||||
|
&wire_details));
|
||||||
|
TALER_JSON_hash (wire_details,
|
||||||
|
&h_wire);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// FIXME: extract from deposit trait!
|
||||||
|
/* Fixme: do prefer "interpreter fail" over assertions,
|
||||||
|
* as the former takes care of shutting down processes, too */
|
||||||
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
TALER_TESTING_get_trait_coin_priv (deposit_cmd,
|
||||||
|
ds->coin_index,
|
||||||
|
&coin_priv));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dcs->dc = TALER_AUDITOR_deposit_confirmation
|
||||||
|
(dcs->auditor,
|
||||||
|
&h_wire,
|
||||||
|
&h_contract_terms,
|
||||||
|
timestamp,
|
||||||
|
refund_deadline,
|
||||||
|
amount_without_fee,
|
||||||
|
coin_pub,
|
||||||
|
merchant_pub,
|
||||||
|
exchange_pub,
|
||||||
|
exchange_sig,
|
||||||
|
master_pub,
|
||||||
|
ep_start,
|
||||||
|
ep_expire,
|
||||||
|
ep_end,
|
||||||
|
master_sig,
|
||||||
|
&deposit_confirmation_cb,
|
||||||
|
dcs);
|
||||||
|
|
||||||
|
if (NULL == dcs->dc)
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
TALER_TESTING_interpreter_fail (is);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free the state of a "deposit_confirmation" CMD, and possibly cancel a
|
||||||
|
* pending operation thereof.
|
||||||
|
*
|
||||||
|
* @param cls closure, a `struct DepositConfirmationState`
|
||||||
|
* @param cmd the command which is being cleaned up.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
deposit_confirmation_cleanup (void *cls,
|
||||||
|
const struct TALER_TESTING_Command *cmd)
|
||||||
|
{
|
||||||
|
struct DepositConfirmationState *dcs = cls;
|
||||||
|
|
||||||
|
if (NULL != dcs->dc)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||||
|
"Command %u (%s) did not complete\n",
|
||||||
|
dcs->is->ip,
|
||||||
|
cmd->label);
|
||||||
|
TALER_AUDITOR_deposit_confirmation_cancel (dcs->dc);
|
||||||
|
dcs->dc = NULL;
|
||||||
|
}
|
||||||
|
if (NULL != dcs->retry_task)
|
||||||
|
{
|
||||||
|
GNUNET_SCHEDULER_cancel (dcs->retry_task);
|
||||||
|
dcs->retry_task = NULL;
|
||||||
|
}
|
||||||
|
GNUNET_free (dcs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a "deposit-confirmation" command.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param auditor auditor connection.
|
||||||
|
* @param deposit_reference reference to any operation that can
|
||||||
|
* provide a coin.
|
||||||
|
* @param coin_index if @a deposit_reference offers an array of
|
||||||
|
* coins, this parameter selects which one in that array.
|
||||||
|
* This value is currently ignored, as only one-coin
|
||||||
|
* deposits are implemented.
|
||||||
|
* @param expected_response_code expected HTTP response code.
|
||||||
|
*
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_deposit_confirmation
|
||||||
|
(const char *label,
|
||||||
|
struct TALER_AUDITOR_Handle *auditor,
|
||||||
|
const char *deposit_reference,
|
||||||
|
unsigned int coin_index,
|
||||||
|
unsigned int expected_response_code)
|
||||||
|
{
|
||||||
|
struct TALER_TESTING_Command cmd = {0}; /* need explicit zeroing..*/
|
||||||
|
struct DepositConfirmationState *dcs;
|
||||||
|
|
||||||
|
dcs = GNUNET_new (struct DepositConfirmationState);
|
||||||
|
dcs->auditor = auditor;
|
||||||
|
dcs->deposit_reference = deposit_reference;
|
||||||
|
dcs->coin_index = coin_index;
|
||||||
|
dcs->expected_response_code = expected_response_code;
|
||||||
|
|
||||||
|
cmd.cls = dcs;
|
||||||
|
cmd.label = label;
|
||||||
|
cmd.run = &deposit_confirmation_run;
|
||||||
|
cmd.cleanup = &deposit_confirmation_cleanup;
|
||||||
|
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify a deposit confirmation command to enable retries when we get
|
||||||
|
* transient errors from the auditor.
|
||||||
|
*
|
||||||
|
* @param cmd a deposit confirmation command
|
||||||
|
* @return the command with retries enabled
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_deposit_confirmation_with_retry (struct TALER_TESTING_Command cmd)
|
||||||
|
{
|
||||||
|
struct DepositConfirmationState *dcs;
|
||||||
|
|
||||||
|
GNUNET_assert (&deposit_confirmation_run == cmd.run);
|
||||||
|
dcs = cmd.cls;
|
||||||
|
dcs->do_retry = GNUNET_YES;
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* end of testing_auditor_api_cmd_deposit_confirmation.c */
|
@ -137,11 +137,10 @@ auditor_traits (void *cls,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the "auditor" CMD.
|
* Make the "exec-auditor" CMD.
|
||||||
*
|
*
|
||||||
* @param label command label.
|
* @param label command label.
|
||||||
* @param config_filename configuration filename.
|
* @param config_filename configuration filename.
|
||||||
*
|
|
||||||
* @return the command.
|
* @return the command.
|
||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
|
@ -137,11 +137,10 @@ wire_auditor_traits (void *cls,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the "wire-auditor" CMD.
|
* Make the "exec wire-auditor" CMD.
|
||||||
*
|
*
|
||||||
* @param label command label.
|
* @param label command label.
|
||||||
* @param config_filename configuration filename.
|
* @param config_filename configuration filename.
|
||||||
*
|
|
||||||
* @return the command.
|
* @return the command.
|
||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
|
@ -65,6 +65,8 @@ libtalertesting_la_SOURCES = \
|
|||||||
testing_api_trait_coin_priv.c \
|
testing_api_trait_coin_priv.c \
|
||||||
testing_api_trait_denom_pub.c \
|
testing_api_trait_denom_pub.c \
|
||||||
testing_api_trait_denom_sig.c \
|
testing_api_trait_denom_sig.c \
|
||||||
|
testing_api_trait_exchange_pub.c \
|
||||||
|
testing_api_trait_exchange_sig.c \
|
||||||
testing_api_trait_json.c \
|
testing_api_trait_json.c \
|
||||||
testing_api_trait_process.c \
|
testing_api_trait_process.c \
|
||||||
testing_api_trait_reserve_priv.c \
|
testing_api_trait_reserve_priv.c \
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2014, 2015 GNUnet e.V.
|
Copyright (C) 2014, 2015, 2018 GNUnet e.V.
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
TALER is free software; you can redistribute it and/or modify it under the
|
||||||
terms of the GNU General Public License as published by the Free Software
|
terms of the GNU General Public License as published by the Free Software
|
||||||
@ -93,19 +93,19 @@ struct TALER_EXCHANGE_DepositHandle
|
|||||||
*
|
*
|
||||||
* @param dh deposit handle
|
* @param dh deposit handle
|
||||||
* @param json json reply with the signature
|
* @param json json reply with the signature
|
||||||
* @param exchange_pub set to the exchange's public key
|
* @param exchange_sig[out] set to the exchange's signature
|
||||||
|
* @param exchange_pub[out] set to the exchange's public key
|
||||||
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
|
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
verify_deposit_signature_ok (const struct TALER_EXCHANGE_DepositHandle *dh,
|
verify_deposit_signature_ok (const struct TALER_EXCHANGE_DepositHandle *dh,
|
||||||
const json_t *json,
|
const json_t *json,
|
||||||
|
struct TALER_ExchangeSignatureP *exchange_sig,
|
||||||
struct TALER_ExchangePublicKeyP *exchange_pub)
|
struct TALER_ExchangePublicKeyP *exchange_pub)
|
||||||
{
|
{
|
||||||
struct TALER_ExchangeSignatureP exchange_sig;
|
|
||||||
|
|
||||||
const struct TALER_EXCHANGE_Keys *key_state;
|
const struct TALER_EXCHANGE_Keys *key_state;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
GNUNET_JSON_spec_fixed_auto ("sig", &exchange_sig),
|
GNUNET_JSON_spec_fixed_auto ("sig", exchange_sig),
|
||||||
GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub),
|
GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub),
|
||||||
GNUNET_JSON_spec_end()
|
GNUNET_JSON_spec_end()
|
||||||
};
|
};
|
||||||
@ -129,7 +129,7 @@ verify_deposit_signature_ok (const struct TALER_EXCHANGE_DepositHandle *dh,
|
|||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT,
|
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT,
|
||||||
&dh->depconf.purpose,
|
&dh->depconf.purpose,
|
||||||
&exchange_sig.eddsa_signature,
|
&exchange_sig->eddsa_signature,
|
||||||
&exchange_pub->eddsa_pub))
|
&exchange_pub->eddsa_pub))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
@ -158,9 +158,9 @@ verify_deposit_signature_forbidden (const struct TALER_EXCHANGE_DepositHandle *d
|
|||||||
"history");
|
"history");
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_EXCHANGE_verify_coin_history (dh->coin_value.currency,
|
TALER_EXCHANGE_verify_coin_history (dh->coin_value.currency,
|
||||||
&dh->depconf.coin_pub,
|
&dh->depconf.coin_pub,
|
||||||
history,
|
history,
|
||||||
&total))
|
&total))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -201,7 +201,9 @@ handle_deposit_finished (void *cls,
|
|||||||
const void *response)
|
const void *response)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGE_DepositHandle *dh = cls;
|
struct TALER_EXCHANGE_DepositHandle *dh = cls;
|
||||||
|
struct TALER_ExchangeSignatureP exchange_sig;
|
||||||
struct TALER_ExchangePublicKeyP exchange_pub;
|
struct TALER_ExchangePublicKeyP exchange_pub;
|
||||||
|
struct TALER_ExchangeSignatureP *es = NULL;
|
||||||
struct TALER_ExchangePublicKeyP *ep = NULL;
|
struct TALER_ExchangePublicKeyP *ep = NULL;
|
||||||
const json_t *j = response;
|
const json_t *j = response;
|
||||||
|
|
||||||
@ -214,6 +216,7 @@ handle_deposit_finished (void *cls,
|
|||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
verify_deposit_signature_ok (dh,
|
verify_deposit_signature_ok (dh,
|
||||||
j,
|
j,
|
||||||
|
&exchange_sig,
|
||||||
&exchange_pub))
|
&exchange_pub))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
@ -221,6 +224,7 @@ handle_deposit_finished (void *cls,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
es = &exchange_sig;
|
||||||
ep = &exchange_pub;
|
ep = &exchange_pub;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -263,6 +267,7 @@ handle_deposit_finished (void *cls,
|
|||||||
dh->cb (dh->cb_cls,
|
dh->cb (dh->cb_cls,
|
||||||
response_code,
|
response_code,
|
||||||
TALER_JSON_get_error_code (j),
|
TALER_JSON_get_error_code (j),
|
||||||
|
es,
|
||||||
ep,
|
ep,
|
||||||
j);
|
j);
|
||||||
TALER_EXCHANGE_deposit_cancel (dh);
|
TALER_EXCHANGE_deposit_cancel (dh);
|
||||||
|
@ -112,6 +112,24 @@ struct DepositState
|
|||||||
*/
|
*/
|
||||||
int do_retry;
|
int do_retry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to #GNUNET_YES if the /deposit succeeded
|
||||||
|
* and we now can provide the resulting traits.
|
||||||
|
*/
|
||||||
|
int traits_ready;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signing key used by the exchange to sign the
|
||||||
|
* deposit confirmation.
|
||||||
|
*/
|
||||||
|
struct TALER_ExchangePublicKeyP exchange_pub;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signature from the exchange on the
|
||||||
|
* deposit confirmation.
|
||||||
|
*/
|
||||||
|
struct TALER_ExchangeSignatureP exchange_sig;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -152,6 +170,8 @@ do_retry (void *cls)
|
|||||||
* @param cls closure.
|
* @param cls closure.
|
||||||
* @param http_status HTTP response code.
|
* @param http_status HTTP response code.
|
||||||
* @param ec taler-specific error code.
|
* @param ec taler-specific error code.
|
||||||
|
* @param exchange_sig signature provided by the exchange
|
||||||
|
* (NULL on errors)
|
||||||
* @param exchange_pub public key of the exchange,
|
* @param exchange_pub public key of the exchange,
|
||||||
* used for signing the response.
|
* used for signing the response.
|
||||||
* @param obj raw response from the exchange.
|
* @param obj raw response from the exchange.
|
||||||
@ -160,6 +180,7 @@ static void
|
|||||||
deposit_cb (void *cls,
|
deposit_cb (void *cls,
|
||||||
unsigned int http_status,
|
unsigned int http_status,
|
||||||
enum TALER_ErrorCode ec,
|
enum TALER_ErrorCode ec,
|
||||||
|
const struct TALER_ExchangeSignatureP *exchange_sig,
|
||||||
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
||||||
const json_t *obj)
|
const json_t *obj)
|
||||||
{
|
{
|
||||||
@ -183,9 +204,10 @@ deposit_cb (void *cls,
|
|||||||
ds->backoff = GNUNET_TIME_UNIT_ZERO;
|
ds->backoff = GNUNET_TIME_UNIT_ZERO;
|
||||||
else
|
else
|
||||||
ds->backoff = EXCHANGE_LIB_BACKOFF (ds->backoff);
|
ds->backoff = EXCHANGE_LIB_BACKOFF (ds->backoff);
|
||||||
ds->retry_task = GNUNET_SCHEDULER_add_delayed (ds->backoff,
|
ds->retry_task
|
||||||
&do_retry,
|
= GNUNET_SCHEDULER_add_delayed (ds->backoff,
|
||||||
ds);
|
&do_retry,
|
||||||
|
ds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,6 +221,12 @@ deposit_cb (void *cls,
|
|||||||
TALER_TESTING_interpreter_fail (ds->is);
|
TALER_TESTING_interpreter_fail (ds->is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (MHD_HTTP_OK == http_status)
|
||||||
|
{
|
||||||
|
ds->traits_ready = GNUNET_YES;
|
||||||
|
ds->exchange_pub = *exchange_pub;
|
||||||
|
ds->exchange_sig = *exchange_sig;
|
||||||
|
}
|
||||||
TALER_TESTING_interpreter_next (ds->is);
|
TALER_TESTING_interpreter_next (ds->is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,7 +453,8 @@ deposit_traits (void *cls,
|
|||||||
struct TALER_CoinSpendPrivateKeyP *coin_spent_priv;
|
struct TALER_CoinSpendPrivateKeyP *coin_spent_priv;
|
||||||
|
|
||||||
coin_cmd = TALER_TESTING_interpreter_lookup_command
|
coin_cmd = TALER_TESTING_interpreter_lookup_command
|
||||||
(ds->is, ds->coin_reference);
|
(ds->is,
|
||||||
|
ds->coin_reference);
|
||||||
|
|
||||||
if (NULL == coin_cmd)
|
if (NULL == coin_cmd)
|
||||||
{
|
{
|
||||||
@ -434,8 +463,10 @@ deposit_traits (void *cls,
|
|||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv
|
if (GNUNET_OK !=
|
||||||
(coin_cmd, ds->coin_index, &coin_spent_priv))
|
TALER_TESTING_get_trait_coin_priv (coin_cmd,
|
||||||
|
ds->coin_index,
|
||||||
|
&coin_spent_priv))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
TALER_TESTING_interpreter_fail (ds->is);
|
TALER_TESTING_interpreter_fail (ds->is);
|
||||||
@ -443,16 +474,27 @@ deposit_traits (void *cls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct TALER_TESTING_Trait traits[] = {
|
struct TALER_TESTING_Trait traits[] = {
|
||||||
TALER_TESTING_make_trait_coin_priv (0, coin_spent_priv),
|
/* First two traits are only available if
|
||||||
TALER_TESTING_make_trait_wire_details (0, ds->wire_details),
|
ds->traits is #GNUNET_YES */
|
||||||
TALER_TESTING_make_trait_contract_terms
|
TALER_TESTING_make_trait_exchange_pub (0,
|
||||||
(0, ds->contract_terms),
|
&ds->exchange_pub),
|
||||||
TALER_TESTING_make_trait_peer_key
|
TALER_TESTING_make_trait_exchange_sig (0,
|
||||||
(0, &ds->merchant_priv.eddsa_priv),
|
&ds->exchange_sig),
|
||||||
|
/* These traits are always available */
|
||||||
|
TALER_TESTING_make_trait_coin_priv (0,
|
||||||
|
coin_spent_priv),
|
||||||
|
TALER_TESTING_make_trait_wire_details (0,
|
||||||
|
ds->wire_details),
|
||||||
|
TALER_TESTING_make_trait_contract_terms (0,
|
||||||
|
ds->contract_terms),
|
||||||
|
TALER_TESTING_make_trait_peer_key (0,
|
||||||
|
&ds->merchant_priv.eddsa_priv),
|
||||||
TALER_TESTING_trait_end ()
|
TALER_TESTING_trait_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
return TALER_TESTING_get_trait (traits,
|
return TALER_TESTING_get_trait ((ds->traits_ready)
|
||||||
|
? traits
|
||||||
|
: &traits[2],
|
||||||
ret,
|
ret,
|
||||||
trait,
|
trait,
|
||||||
index);
|
index);
|
||||||
|
77
src/exchange-lib/testing_api_trait_exchange_pub.c
Normal file
77
src/exchange-lib/testing_api_trait_exchange_pub.c
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2018 Taler Systems SA
|
||||||
|
|
||||||
|
TALER is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published
|
||||||
|
by the Free Software Foundation; either version 3, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
TALER is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public
|
||||||
|
License along with TALER; see the file COPYING. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file exchange-lib/testing_api_trait_exchange_pub.c
|
||||||
|
* @brief exchange pub traits.
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include <gnunet/gnunet_curl_lib.h>
|
||||||
|
#include "exchange_api_handle.h"
|
||||||
|
#include "taler_signatures.h"
|
||||||
|
#include "taler_testing_lib.h"
|
||||||
|
|
||||||
|
#define TALER_TESTING_TRAIT_EXCHANGE_PUB "exchange-public-key"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a exchange public key from a @a cmd.
|
||||||
|
*
|
||||||
|
* @param cmd command to extract trait from
|
||||||
|
* @param index index number of the exchange to obtain.
|
||||||
|
* @param exchange_pub[out] set to the offered exchange pub.
|
||||||
|
* @return #GNUNET_OK on success.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_TESTING_get_trait_exchange_pub
|
||||||
|
(const struct TALER_TESTING_Command *cmd,
|
||||||
|
unsigned int index,
|
||||||
|
const struct TALER_ExchangePublicKeyP **exchange_pub)
|
||||||
|
{
|
||||||
|
return cmd->traits (cmd->cls,
|
||||||
|
(void **) exchange_pub,
|
||||||
|
TALER_TESTING_TRAIT_EXCHANGE_PUB,
|
||||||
|
index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a trait for a exchange public key.
|
||||||
|
*
|
||||||
|
* @param index index number to associate to the offered exchange pub.
|
||||||
|
* @param exchange_pub exchange pub to offer with this trait.
|
||||||
|
*
|
||||||
|
* @return the trait.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Trait
|
||||||
|
TALER_TESTING_make_trait_exchange_pub
|
||||||
|
(unsigned int index,
|
||||||
|
const struct TALER_ExchangePublicKeyP *exchange_pub)
|
||||||
|
{
|
||||||
|
struct TALER_TESTING_Trait ret = {
|
||||||
|
.index = index,
|
||||||
|
.trait_name = TALER_TESTING_TRAIT_EXCHANGE_PUB,
|
||||||
|
.ptr = (const void *) exchange_pub
|
||||||
|
};
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end of testing_api_trait_exchange_pub.c */
|
77
src/exchange-lib/testing_api_trait_exchange_sig.c
Normal file
77
src/exchange-lib/testing_api_trait_exchange_sig.c
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2018 Taler Systems SA
|
||||||
|
|
||||||
|
TALER is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published
|
||||||
|
by the Free Software Foundation; either version 3, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
TALER is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public
|
||||||
|
License along with TALER; see the file COPYING. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file exchange-lib/testing_api_trait_exchange_sig.c
|
||||||
|
* @brief exchange pub traits.
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include <gnunet/gnunet_curl_lib.h>
|
||||||
|
#include "exchange_api_handle.h"
|
||||||
|
#include "taler_signatures.h"
|
||||||
|
#include "taler_testing_lib.h"
|
||||||
|
|
||||||
|
#define TALER_TESTING_TRAIT_EXCHANGE_SIG "exchange-online-signature"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a exchange signature (online sig) from a @a cmd.
|
||||||
|
*
|
||||||
|
* @param cmd command to extract trait from
|
||||||
|
* @param index index number of the exchange to obtain.
|
||||||
|
* @param exchange_sig[out] set to the offered exchange signature.
|
||||||
|
* @return #GNUNET_OK on success.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_TESTING_get_trait_exchange_sig
|
||||||
|
(const struct TALER_TESTING_Command *cmd,
|
||||||
|
unsigned int index,
|
||||||
|
const struct TALER_ExchangeSignatureP **exchange_sig)
|
||||||
|
{
|
||||||
|
return cmd->traits (cmd->cls,
|
||||||
|
(void **) exchange_sig,
|
||||||
|
TALER_TESTING_TRAIT_EXCHANGE_SIG,
|
||||||
|
index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a trait for a exchange signature.
|
||||||
|
*
|
||||||
|
* @param index index number to associate to the offered exchange pub.
|
||||||
|
* @param exchange_sig exchange signature to offer with this trait.
|
||||||
|
*
|
||||||
|
* @return the trait.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Trait
|
||||||
|
TALER_TESTING_make_trait_exchange_sig
|
||||||
|
(unsigned int index,
|
||||||
|
const struct TALER_ExchangeSignatureP *exchange_sig)
|
||||||
|
{
|
||||||
|
struct TALER_TESTING_Trait ret = {
|
||||||
|
.index = index,
|
||||||
|
.trait_name = TALER_TESTING_TRAIT_EXCHANGE_SIG,
|
||||||
|
.ptr = (const void *) exchange_sig
|
||||||
|
};
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end of testing_api_trait_exchange_sig.c */
|
@ -221,7 +221,7 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor,
|
|||||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
||||||
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
||||||
const struct TALER_CoinSpendSignatureP *exchange_sig,
|
const struct TALER_ExchangeSignatureP *exchange_sig,
|
||||||
const struct TALER_MasterPublicKeyP *master_pub,
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
struct GNUNET_TIME_Absolute ep_start,
|
struct GNUNET_TIME_Absolute ep_start,
|
||||||
struct GNUNET_TIME_Absolute ep_expire,
|
struct GNUNET_TIME_Absolute ep_expire,
|
||||||
|
@ -628,6 +628,7 @@ struct TALER_EXCHANGE_DepositHandle;
|
|||||||
* @param cls closure
|
* @param cls closure
|
||||||
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful deposit;
|
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful deposit;
|
||||||
* 0 if the exchange's reply is bogus (fails to follow the protocol)
|
* 0 if the exchange's reply is bogus (fails to follow the protocol)
|
||||||
|
* @param exchange_sig signature provided by the exchange
|
||||||
* @param sign_key exchange key used to sign @a obj, or NULL
|
* @param sign_key exchange key used to sign @a obj, or NULL
|
||||||
* @param obj the received JSON reply, should be kept as proof (and, in case of errors,
|
* @param obj the received JSON reply, should be kept as proof (and, in case of errors,
|
||||||
* be forwarded to the customer)
|
* be forwarded to the customer)
|
||||||
@ -636,7 +637,8 @@ typedef void
|
|||||||
(*TALER_EXCHANGE_DepositResultCallback) (void *cls,
|
(*TALER_EXCHANGE_DepositResultCallback) (void *cls,
|
||||||
unsigned int http_status,
|
unsigned int http_status,
|
||||||
enum TALER_ErrorCode ec,
|
enum TALER_ErrorCode ec,
|
||||||
const struct TALER_ExchangePublicKeyP *sign_key,
|
const struct TALER_ExchangeSignatureP *exchange_sig,
|
||||||
|
const struct TALER_ExchangePublicKeyP *sign_key,
|
||||||
const json_t *obj);
|
const json_t *obj);
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +33,67 @@
|
|||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* ********************* Commands ********************* */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make the "exec-auditor" CMD.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param config_filename configuration filename.
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_exec_auditor (const char *label,
|
||||||
|
const char *config_filename);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make the "exec wire-auditor" CMD.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param config_filename configuration filename.
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_exec_wire_auditor (const char *label,
|
||||||
|
const char *config_filename);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a "deposit-confirmation" command.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param auditor auditor connection.
|
||||||
|
* @param deposit_reference reference to any operation that can
|
||||||
|
* provide a coin.
|
||||||
|
* @param coin_index if @a deposit_reference offers an array of
|
||||||
|
* coins, this parameter selects which one in that array.
|
||||||
|
* This value is currently ignored, as only one-coin
|
||||||
|
* deposits are implemented.
|
||||||
|
* @param expected_response_code expected HTTP response code.
|
||||||
|
*
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_deposit_confirmation
|
||||||
|
(const char *label,
|
||||||
|
struct TALER_AUDITOR_Handle *auditor,
|
||||||
|
const char *deposit_reference,
|
||||||
|
unsigned int coin_index,
|
||||||
|
unsigned int expected_response_code);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify a deposit confirmation command to enable retries when we get
|
||||||
|
* transient errors from the auditor.
|
||||||
|
*
|
||||||
|
* @param cmd a deposit confirmation command
|
||||||
|
* @return the command with retries enabled
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_deposit_confirmation_with_retry (struct TALER_TESTING_Command cmd);
|
||||||
|
|
||||||
|
|
||||||
/* ********************* Helper functions ********************* */
|
/* ********************* Helper functions ********************* */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1538,6 +1538,64 @@ TALER_TESTING_get_trait_reserve_priv
|
|||||||
struct TALER_ReservePrivateKeyP **reserve_priv);
|
struct TALER_ReservePrivateKeyP **reserve_priv);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a trait for a exchange signature.
|
||||||
|
*
|
||||||
|
* @param index index number to associate to the offered exchange pub.
|
||||||
|
* @param exchange_sig exchange signature to offer with this trait.
|
||||||
|
*
|
||||||
|
* @return the trait.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Trait
|
||||||
|
TALER_TESTING_make_trait_exchange_sig
|
||||||
|
(unsigned int index,
|
||||||
|
const struct TALER_ExchangeSignatureP *exchange_sig);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a exchange signature (online sig) from a @a cmd.
|
||||||
|
*
|
||||||
|
* @param cmd command to extract trait from
|
||||||
|
* @param index index number of the exchange to obtain.
|
||||||
|
* @param exchange_sig[out] set to the offered exchange signature.
|
||||||
|
* @return #GNUNET_OK on success.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_TESTING_get_trait_exchange_sig
|
||||||
|
(const struct TALER_TESTING_Command *cmd,
|
||||||
|
unsigned int index,
|
||||||
|
const struct TALER_ExchangeSignatureP **exchange_sig);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a trait for a exchange public key.
|
||||||
|
*
|
||||||
|
* @param index index number to associate to the offered exchange pub.
|
||||||
|
* @param exchange_pub exchange pub to offer with this trait.
|
||||||
|
*
|
||||||
|
* @return the trait.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Trait
|
||||||
|
TALER_TESTING_make_trait_exchange_pub
|
||||||
|
(unsigned int index,
|
||||||
|
const struct TALER_ExchangePublicKeyP *exchange_pub);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a exchange public key from a @a cmd.
|
||||||
|
*
|
||||||
|
* @param cmd command to extract trait from
|
||||||
|
* @param index index number of the exchange to obtain.
|
||||||
|
* @param exchange_pub[out] set to the offered exchange pub.
|
||||||
|
* @return #GNUNET_OK on success.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_TESTING_get_trait_exchange_pub
|
||||||
|
(const struct TALER_TESTING_Command *cmd,
|
||||||
|
unsigned int index,
|
||||||
|
const struct TALER_ExchangePublicKeyP **exchange_pub);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain location where a command stores a pointer to a process.
|
* Obtain location where a command stores a pointer to a process.
|
||||||
*
|
*
|
||||||
@ -1798,6 +1856,7 @@ TALER_TESTING_get_trait_fresh_coins
|
|||||||
unsigned int index,
|
unsigned int index,
|
||||||
struct FreshCoin **fresh_coins);
|
struct FreshCoin **fresh_coins);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain contract terms from @a cmd.
|
* Obtain contract terms from @a cmd.
|
||||||
*
|
*
|
||||||
@ -1805,7 +1864,6 @@ TALER_TESTING_get_trait_fresh_coins
|
|||||||
* @param index contract terms index number.
|
* @param index contract terms index number.
|
||||||
* @param contract_terms[out] where to write the contract
|
* @param contract_terms[out] where to write the contract
|
||||||
* terms.
|
* terms.
|
||||||
*
|
|
||||||
* @return #GNUNET_OK on success.
|
* @return #GNUNET_OK on success.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@ -1814,12 +1872,12 @@ TALER_TESTING_get_trait_contract_terms
|
|||||||
unsigned int index,
|
unsigned int index,
|
||||||
const char **contract_terms);
|
const char **contract_terms);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offer contract terms.
|
* Offer contract terms.
|
||||||
*
|
*
|
||||||
* @param index contract terms index number.
|
* @param index contract terms index number.
|
||||||
* @param contract_terms contract terms to offer.
|
* @param contract_terms contract terms to offer.
|
||||||
*
|
|
||||||
* @return the trait.
|
* @return the trait.
|
||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Trait
|
struct TALER_TESTING_Trait
|
||||||
|
Loading…
Reference in New Issue
Block a user