summaryrefslogtreecommitdiff
path: root/src/exchange-lib/testing_api_cmd_deposit.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-11-17 15:15:51 +0100
committerChristian Grothoff <christian@grothoff.org>2018-11-17 15:15:51 +0100
commit4d058c4eb7283b1a77a877d583daaefa847213ec (patch)
treecded82c1127f7060e359caca09a702c662d56319 /src/exchange-lib/testing_api_cmd_deposit.c
parent17edb09f384689da5923689dfe4b6d071797091c (diff)
downloadexchange-4d058c4eb7283b1a77a877d583daaefa847213ec.tar.gz
exchange-4d058c4eb7283b1a77a877d583daaefa847213ec.tar.bz2
exchange-4d058c4eb7283b1a77a877d583daaefa847213ec.zip
work towards testing auditor deposit-confirmation API
Diffstat (limited to 'src/exchange-lib/testing_api_cmd_deposit.c')
-rw-r--r--src/exchange-lib/testing_api_cmd_deposit.c68
1 files changed, 55 insertions, 13 deletions
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);