aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/auditor-lib/Makefile.am1
-rw-r--r--src/auditor-lib/auditor_api_deposit_confirmation.c6
-rw-r--r--src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c374
-rw-r--r--src/auditor-lib/testing_auditor_api_cmd_exec_auditor.c3
-rw-r--r--src/auditor-lib/testing_auditor_api_cmd_exec_wire_auditor.c3
-rw-r--r--src/exchange-lib/Makefile.am2
-rw-r--r--src/exchange-lib/exchange_api_deposit.c23
-rw-r--r--src/exchange-lib/testing_api_cmd_deposit.c68
-rw-r--r--src/exchange-lib/testing_api_trait_exchange_pub.c77
-rw-r--r--src/exchange-lib/testing_api_trait_exchange_sig.c77
-rw-r--r--src/include/taler_auditor_service.h2
-rw-r--r--src/include/taler_exchange_service.h4
-rw-r--r--src/include/taler_testing_auditor_lib.h61
-rw-r--r--src/include/taler_testing_lib.h62
14 files changed, 730 insertions, 33 deletions
diff --git a/src/auditor-lib/Makefile.am b/src/auditor-lib/Makefile.am
index 4589bc975..44849da22 100644
--- a/src/auditor-lib/Makefile.am
+++ b/src/auditor-lib/Makefile.am
@@ -41,6 +41,7 @@ libtalerauditortesting_la_LDFLAGS = \
-no-undefined
libtalerauditortesting_la_SOURCES = \
testing_auditor_api_helpers.c \
+ testing_auditor_api_cmd_deposit_confirmation.c \
testing_auditor_api_cmd_exec_auditor.c \
testing_auditor_api_cmd_exec_wire_auditor.c
libtalerauditortesting_la_LIBADD = \
diff --git a/src/auditor-lib/auditor_api_deposit_confirmation.c b/src/auditor-lib/auditor_api_deposit_confirmation.c
index 1ad6ddad7..736f326dd 100644
--- a/src/auditor-lib/auditor_api_deposit_confirmation.c
+++ b/src/auditor-lib/auditor_api_deposit_confirmation.c
@@ -156,7 +156,7 @@ verify_signatures (const struct GNUNET_HashCode *h_wire,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_MerchantPublicKeyP *merchant_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,
struct GNUNET_TIME_Absolute ep_start,
struct GNUNET_TIME_Absolute ep_expire,
@@ -181,7 +181,7 @@ verify_signatures (const struct GNUNET_HashCode *h_wire,
&dc.purpose,
&exchange_sig->eddsa_signature,
&exchange_pub->eddsa_pub))
- {
+ {
GNUNET_break_op (0);
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_MerchantPublicKeyP *merchant_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,
struct GNUNET_TIME_Absolute ep_start,
struct GNUNET_TIME_Absolute ep_expire,
diff --git a/src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c b/src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c
new file mode 100644
index 000000000..3509fec52
--- /dev/null
+++ b/src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c
@@ -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 */
diff --git a/src/auditor-lib/testing_auditor_api_cmd_exec_auditor.c b/src/auditor-lib/testing_auditor_api_cmd_exec_auditor.c
index 37d51b781..273612497 100644
--- a/src/auditor-lib/testing_auditor_api_cmd_exec_auditor.c
+++ b/src/auditor-lib/testing_auditor_api_cmd_exec_auditor.c
@@ -137,11 +137,10 @@ auditor_traits (void *cls,
/**
- * Make the "auditor" CMD.
+ * Make the "exec-auditor" CMD.
*
* @param label command label.
* @param config_filename configuration filename.
- *
* @return the command.
*/
struct TALER_TESTING_Command
diff --git a/src/auditor-lib/testing_auditor_api_cmd_exec_wire_auditor.c b/src/auditor-lib/testing_auditor_api_cmd_exec_wire_auditor.c
index 3f7b2ee31..c32130397 100644
--- a/src/auditor-lib/testing_auditor_api_cmd_exec_wire_auditor.c
+++ b/src/auditor-lib/testing_auditor_api_cmd_exec_wire_auditor.c
@@ -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 config_filename configuration filename.
- *
* @return the command.
*/
struct TALER_TESTING_Command
diff --git a/src/exchange-lib/Makefile.am b/src/exchange-lib/Makefile.am
index 3e1b4507e..c22c47b53 100644
--- a/src/exchange-lib/Makefile.am
+++ b/src/exchange-lib/Makefile.am
@@ -65,6 +65,8 @@ libtalertesting_la_SOURCES = \
testing_api_trait_coin_priv.c \
testing_api_trait_denom_pub.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_process.c \
testing_api_trait_reserve_priv.c \
diff --git a/src/exchange-lib/exchange_api_deposit.c b/src/exchange-lib/exchange_api_deposit.c
index c388e6816..355464099 100644
--- a/src/exchange-lib/exchange_api_deposit.c
+++ b/src/exchange-lib/exchange_api_deposit.c
@@ -1,6 +1,6 @@
/*
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
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 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
*/
static int
verify_deposit_signature_ok (const struct TALER_EXCHANGE_DepositHandle *dh,
const json_t *json,
+ struct TALER_ExchangeSignatureP *exchange_sig,
struct TALER_ExchangePublicKeyP *exchange_pub)
{
- struct TALER_ExchangeSignatureP exchange_sig;
-
const struct TALER_EXCHANGE_Keys *key_state;
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_end()
};
@@ -129,7 +129,7 @@ verify_deposit_signature_ok (const struct TALER_EXCHANGE_DepositHandle *dh,
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT,
&dh->depconf.purpose,
- &exchange_sig.eddsa_signature,
+ &exchange_sig->eddsa_signature,
&exchange_pub->eddsa_pub))
{
GNUNET_break_op (0);
@@ -158,9 +158,9 @@ verify_deposit_signature_forbidden (const struct TALER_EXCHANGE_DepositHandle *d
"history");
if (GNUNET_OK !=
TALER_EXCHANGE_verify_coin_history (dh->coin_value.currency,
- &dh->depconf.coin_pub,
- history,
- &total))
+ &dh->depconf.coin_pub,
+ history,
+ &total))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -201,7 +201,9 @@ handle_deposit_finished (void *cls,
const void *response)
{
struct TALER_EXCHANGE_DepositHandle *dh = cls;
+ struct TALER_ExchangeSignatureP exchange_sig;
struct TALER_ExchangePublicKeyP exchange_pub;
+ struct TALER_ExchangeSignatureP *es = NULL;
struct TALER_ExchangePublicKeyP *ep = NULL;
const json_t *j = response;
@@ -214,6 +216,7 @@ handle_deposit_finished (void *cls,
if (GNUNET_OK !=
verify_deposit_signature_ok (dh,
j,
+ &exchange_sig,
&exchange_pub))
{
GNUNET_break_op (0);
@@ -221,6 +224,7 @@ handle_deposit_finished (void *cls,
}
else
{
+ es = &exchange_sig;
ep = &exchange_pub;
}
break;
@@ -263,6 +267,7 @@ handle_deposit_finished (void *cls,
dh->cb (dh->cb_cls,
response_code,
TALER_JSON_get_error_code (j),
+ es,
ep,
j);
TALER_EXCHANGE_deposit_cancel (dh);
diff --git a/src/exchange-lib/testing_api_cmd_deposit.c b/src/exchange-lib/testing_api_cmd_deposit.c
index 604fa949b..4f3757f5d 100644
--- a/src/exchange-lib/testing_api_cmd_deposit.c
+++ b/src/exchange-lib/testing_api_cmd_deposit.c
@@ -112,6 +112,24 @@ struct DepositState
*/
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 http_status HTTP response 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,
* used for signing the response.
* @param obj raw response from the exchange.
@@ -160,6 +180,7 @@ static void
deposit_cb (void *cls,
unsigned int http_status,
enum TALER_ErrorCode ec,
+ const struct TALER_ExchangeSignatureP *exchange_sig,
const struct TALER_ExchangePublicKeyP *exchange_pub,
const json_t *obj)
{
@@ -183,9 +204,10 @@ deposit_cb (void *cls,
ds->backoff = GNUNET_TIME_UNIT_ZERO;
else
ds->backoff = EXCHANGE_LIB_BACKOFF (ds->backoff);
- ds->retry_task = GNUNET_SCHEDULER_add_delayed (ds->backoff,
- &do_retry,
- ds);
+ ds->retry_task
+ = GNUNET_SCHEDULER_add_delayed (ds->backoff,
+ &do_retry,
+ ds);
return;
}
}
@@ -199,6 +221,12 @@ deposit_cb (void *cls,
TALER_TESTING_interpreter_fail (ds->is);
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);
}
@@ -425,7 +453,8 @@ deposit_traits (void *cls,
struct TALER_CoinSpendPrivateKeyP *coin_spent_priv;
coin_cmd = TALER_TESTING_interpreter_lookup_command
- (ds->is, ds->coin_reference);
+ (ds->is,
+ ds->coin_reference);
if (NULL == coin_cmd)
{
@@ -434,8 +463,10 @@ deposit_traits (void *cls,
return GNUNET_NO;
}
- if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv
- (coin_cmd, ds->coin_index, &coin_spent_priv))
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_coin_priv (coin_cmd,
+ ds->coin_index,
+ &coin_spent_priv))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (ds->is);
@@ -443,16 +474,27 @@ deposit_traits (void *cls,
}
struct TALER_TESTING_Trait traits[] = {
- 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),
+ /* First two traits are only available if
+ ds->traits is #GNUNET_YES */
+ TALER_TESTING_make_trait_exchange_pub (0,
+ &ds->exchange_pub),
+ TALER_TESTING_make_trait_exchange_sig (0,
+ &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 ()
};
- return TALER_TESTING_get_trait (traits,
+ return TALER_TESTING_get_trait ((ds->traits_ready)
+ ? traits
+ : &traits[2],
ret,
trait,
index);
diff --git a/src/exchange-lib/testing_api_trait_exchange_pub.c b/src/exchange-lib/testing_api_trait_exchange_pub.c
new file mode 100644
index 000000000..4bef98af6
--- /dev/null
+++ b/src/exchange-lib/testing_api_trait_exchange_pub.c
@@ -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 */
diff --git a/src/exchange-lib/testing_api_trait_exchange_sig.c b/src/exchange-lib/testing_api_trait_exchange_sig.c
new file mode 100644
index 000000000..00d4243f1
--- /dev/null
+++ b/src/exchange-lib/testing_api_trait_exchange_sig.c
@@ -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 */
diff --git a/src/include/taler_auditor_service.h b/src/include/taler_auditor_service.h
index 6f9fef5af..78f878fed 100644
--- a/src/include/taler_auditor_service.h
+++ b/src/include/taler_auditor_service.h
@@ -221,7 +221,7 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_MerchantPublicKeyP *merchant_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,
struct GNUNET_TIME_Absolute ep_start,
struct GNUNET_TIME_Absolute ep_expire,
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index f40387514..9ccbf9ef1 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -628,6 +628,7 @@ struct TALER_EXCHANGE_DepositHandle;
* @param cls closure
* @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)
+ * @param exchange_sig signature provided by the exchange
* @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,
* be forwarded to the customer)
@@ -636,7 +637,8 @@ typedef void
(*TALER_EXCHANGE_DepositResultCallback) (void *cls,
unsigned int http_status,
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);
diff --git a/src/include/taler_testing_auditor_lib.h b/src/include/taler_testing_auditor_lib.h
index 554fadf5c..2d7e8e14b 100644
--- a/src/include/taler_testing_auditor_lib.h
+++ b/src/include/taler_testing_auditor_lib.h
@@ -33,6 +33,67 @@
#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 ********************* */
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 9ea10f7e7..ffb092ad2 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -1539,6 +1539,64 @@ TALER_TESTING_get_trait_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.
*
* @param cmd command to extract trait from.
@@ -1798,6 +1856,7 @@ TALER_TESTING_get_trait_fresh_coins
unsigned int index,
struct FreshCoin **fresh_coins);
+
/**
* Obtain contract terms from @a cmd.
*
@@ -1805,7 +1864,6 @@ TALER_TESTING_get_trait_fresh_coins
* @param index contract terms index number.
* @param contract_terms[out] where to write the contract
* terms.
- *
* @return #GNUNET_OK on success.
*/
int
@@ -1814,12 +1872,12 @@ TALER_TESTING_get_trait_contract_terms
unsigned int index,
const char **contract_terms);
+
/**
* Offer contract terms.
*
* @param index contract terms index number.
* @param contract_terms contract terms to offer.
- *
* @return the trait.
*/
struct TALER_TESTING_Trait