diff options
| author | Christian Grothoff <christian@grothoff.org> | 2018-11-17 16:11:47 +0100 | 
|---|---|---|
| committer | Christian Grothoff <christian@grothoff.org> | 2018-11-17 16:11:47 +0100 | 
| commit | cf1ce4786356cba7d3f84a74fab282650f612db9 (patch) | |
| tree | 744790593dd70e5338dd53e4e450364e53158999 | |
| parent | 4d058c4eb7283b1a77a877d583daaefa847213ec (diff) | |
more work towards testing deposit confirmations
| -rw-r--r-- | src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c | 39 | ||||
| -rw-r--r-- | src/exchange-lib/exchange_api_common.c | 25 | ||||
| -rw-r--r-- | src/exchange-lib/testing_api_cmd_deposit.c | 4 | ||||
| -rw-r--r-- | src/exchange-lib/testing_api_cmd_payback.c | 2 | ||||
| -rw-r--r-- | src/exchange-lib/testing_api_cmd_refresh.c | 4 | ||||
| -rw-r--r-- | src/exchange-lib/testing_api_cmd_refund.c | 2 | ||||
| -rw-r--r-- | src/exchange-lib/testing_api_cmd_track.c | 4 | ||||
| -rw-r--r-- | src/exchange-lib/testing_api_trait_coin_priv.c | 2 | ||||
| -rw-r--r-- | src/include/taler_exchange_service.h | 13 | ||||
| -rw-r--r-- | src/include/taler_testing_lib.h | 2 | 
10 files changed, 67 insertions, 30 deletions
| diff --git a/src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c b/src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c index 3509fec5..3ee8b14a 100644 --- a/src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c +++ b/src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c @@ -191,17 +191,15 @@ deposit_confirmation_run (void *cls,    struct GNUNET_TIME_Absolute timestamp;    struct GNUNET_TIME_Absolute refund_deadline;    const struct TALER_Amount *amount_without_fee; -  const struct TALER_CoinSpendPublicKeyP *coin_pub; +  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; +  const struct TALER_CoinSpendPrivateKeyP *coin_priv; +  const struct TALER_EXCHANGE_Keys *keys; +  const struct TALER_EXCHANGE_SigningPublicKey *spk;    dcs->is = is;    this_cmd = &is->commands[is->ip]; // use this_cmd->label for logging! @@ -225,7 +223,11 @@ deposit_confirmation_run (void *cls,  		 TALER_TESTING_get_trait_exchange_sig (deposit_cmd,  						       dcs->coin_index,  						       &exchange_sig)); - +  keys = TALER_EXCHANGE_get_keys (dcs->is->exchange); +  GNUNET_assert (NULL != keys); +  spk = TALER_EXCHANGE_get_exchange_signing_key_info (keys, +						      exchange_pub); +    #if 0      GNUNET_assert (GNUNET_OK ==  		 TALER_TESTING_get_trait_contract_terms (deposit_cmd, @@ -240,16 +242,13 @@ deposit_confirmation_run (void *cls,  						       &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, +						    dcs->coin_index,  						    &coin_priv)); -#endif +  GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, +                                      &coin_pub.eddsa_pub);    dcs->dc = TALER_AUDITOR_deposit_confirmation      (dcs->auditor, @@ -258,15 +257,15 @@ deposit_confirmation_run (void *cls,       timestamp,       refund_deadline,       amount_without_fee, -     coin_pub, +     &coin_pub,       merchant_pub,       exchange_pub,       exchange_sig, -     master_pub, -     ep_start, -     ep_expire, -     ep_end, -     master_sig, +     &keys->master_pub, +     spk->valid_from, +     spk->valid_until, +     spk->valid_legal, +     &spk->master_sig,       &deposit_confirmation_cb,       dcs); diff --git a/src/exchange-lib/exchange_api_common.c b/src/exchange-lib/exchange_api_common.c index de05348f..6b0aa6ff 100644 --- a/src/exchange-lib/exchange_api_common.c +++ b/src/exchange-lib/exchange_api_common.c @@ -325,4 +325,29 @@ TALER_EXCHANGE_verify_coin_history (const char *currency,  } +/** + * Obtain meta data about an exchange (online) signing + * key. + * + * @param keys from where to obtain the meta data + * @param exchange_pub public key to lookup + * @return NULL on error (@a exchange_pub not known) + */ +const struct TALER_EXCHANGE_SigningPublicKey * +TALER_EXCHANGE_get_exchange_signing_key_info (const struct TALER_EXCHANGE_Keys *keys, +					      const struct TALER_ExchangePublicKeyP *exchange_pub) +{ +  for (unsigned int i=0;i<keys->num_sign_keys;i++) +  { +    const struct TALER_EXCHANGE_SigningPublicKey *spk; + +    spk = &keys->sign_keys[i]; +    if (0 == memcmp (exchange_pub, +		     &spk->key, +		     sizeof (struct TALER_ExchangePublicKeyP))) +      return spk; +  } +  return NULL; +} +  /* end of exchange_api_common.c */ diff --git a/src/exchange-lib/testing_api_cmd_deposit.c b/src/exchange-lib/testing_api_cmd_deposit.c index 4f3757f5..59209fcc 100644 --- a/src/exchange-lib/testing_api_cmd_deposit.c +++ b/src/exchange-lib/testing_api_cmd_deposit.c @@ -246,7 +246,7 @@ deposit_run (void *cls,    struct DepositState *ds = cls;    const struct TALER_TESTING_Command *coin_cmd;    struct TALER_TESTING_Command *this_cmd; -  struct TALER_CoinSpendPrivateKeyP *coin_priv; +  const struct TALER_CoinSpendPrivateKeyP *coin_priv;    struct TALER_CoinSpendPublicKeyP coin_pub;    const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;    struct TALER_DenominationSignature *denom_pub_sig; @@ -450,7 +450,7 @@ deposit_traits (void *cls,    struct DepositState *ds = cls;    const struct TALER_TESTING_Command *coin_cmd;    /* Will point to coin cmd internals. */ -  struct TALER_CoinSpendPrivateKeyP *coin_spent_priv; +  const struct TALER_CoinSpendPrivateKeyP *coin_spent_priv;    coin_cmd = TALER_TESTING_interpreter_lookup_command      (ds->is, diff --git a/src/exchange-lib/testing_api_cmd_payback.c b/src/exchange-lib/testing_api_cmd_payback.c index 56026162..43118ef0 100644 --- a/src/exchange-lib/testing_api_cmd_payback.c +++ b/src/exchange-lib/testing_api_cmd_payback.c @@ -224,7 +224,7 @@ payback_run (void *cls,  {    struct PaybackState *ps = cls;    const struct TALER_TESTING_Command *coin_cmd; -  struct TALER_CoinSpendPrivateKeyP *coin_priv; +  const struct TALER_CoinSpendPrivateKeyP *coin_priv;    struct TALER_DenominationBlindingKeyP *blinding_key;    const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;    struct TALER_DenominationSignature *coin_sig; diff --git a/src/exchange-lib/testing_api_cmd_refresh.c b/src/exchange-lib/testing_api_cmd_refresh.c index 982b4d29..93939bf8 100644 --- a/src/exchange-lib/testing_api_cmd_refresh.c +++ b/src/exchange-lib/testing_api_cmd_refresh.c @@ -715,7 +715,7 @@ refresh_link_run (void *cls,      }    } -  struct TALER_CoinSpendPrivateKeyP *coin_priv; +  const struct TALER_CoinSpendPrivateKeyP *coin_priv;    if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv      (coin_cmd, 0, &coin_priv))    { @@ -903,7 +903,7 @@ refresh_melt_run (void *cls,      (num_fresh_coins,       struct TALER_EXCHANGE_DenomPublicKey);    { -    struct TALER_CoinSpendPrivateKeyP *melt_priv; +    const struct TALER_CoinSpendPrivateKeyP *melt_priv;      struct TALER_Amount melt_amount;      struct TALER_Amount fresh_amount;      struct TALER_DenominationSignature *melt_sig; diff --git a/src/exchange-lib/testing_api_cmd_refund.c b/src/exchange-lib/testing_api_cmd_refund.c index 136ee631..de70da27 100644 --- a/src/exchange-lib/testing_api_cmd_refund.c +++ b/src/exchange-lib/testing_api_cmd_refund.c @@ -143,7 +143,7 @@ refund_run (void *cls,              struct TALER_TESTING_Interpreter *is)  {    struct RefundState *rs = cls; -  struct TALER_CoinSpendPrivateKeyP *coin_priv; +  const struct TALER_CoinSpendPrivateKeyP *coin_priv;    struct TALER_CoinSpendPublicKeyP coin;    const char *contract_terms;    struct GNUNET_HashCode h_contract_terms; diff --git a/src/exchange-lib/testing_api_cmd_track.c b/src/exchange-lib/testing_api_cmd_track.c index c7fbf408..201ac3f9 100644 --- a/src/exchange-lib/testing_api_cmd_track.c +++ b/src/exchange-lib/testing_api_cmd_track.c @@ -259,14 +259,14 @@ deposit_wtid_cb   * @param cmd the command to execute.   * @param is the interpreter state.   */ -void +static void  track_transaction_run (void *cls,                         const struct TALER_TESTING_Command *cmd,                         struct TALER_TESTING_Interpreter *is)  {    struct TrackTransactionState *tts = cls;    const struct TALER_TESTING_Command *transaction_cmd; -  struct TALER_CoinSpendPrivateKeyP *coin_priv; +  const struct TALER_CoinSpendPrivateKeyP *coin_priv;    struct TALER_CoinSpendPublicKeyP coin_pub;    const char *contract_terms;    const json_t *wire_details; diff --git a/src/exchange-lib/testing_api_trait_coin_priv.c b/src/exchange-lib/testing_api_trait_coin_priv.c index 5e9193f1..baaa794b 100644 --- a/src/exchange-lib/testing_api_trait_coin_priv.c +++ b/src/exchange-lib/testing_api_trait_coin_priv.c @@ -46,7 +46,7 @@ int  TALER_TESTING_get_trait_coin_priv    (const struct TALER_TESTING_Command *cmd,     unsigned int index, -   struct TALER_CoinSpendPrivateKeyP **coin_priv) +   const struct TALER_CoinSpendPrivateKeyP **coin_priv)  {    return cmd->traits (cmd->cls,                        (void **) coin_priv, diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 9ccbf9ef..351bbcd2 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -484,6 +484,19 @@ TALER_EXCHANGE_get_denomination_key_by_hash (const struct TALER_EXCHANGE_Keys *k                                               const struct GNUNET_HashCode *hc); +/** + * Obtain meta data about an exchange (online) signing + * key. + * + * @param keys from where to obtain the meta data + * @param exchange_pub public key to lookup + * @return NULL on error (@a exchange_pub not known) + */ +const struct TALER_EXCHANGE_SigningPublicKey * +TALER_EXCHANGE_get_exchange_signing_key_info (const struct TALER_EXCHANGE_Keys *keys, +					      const struct TALER_ExchangePublicKeyP *exchange_pub); + +  /* *********************  /wire *********************** */ diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index ffb092ad..7d409435 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -1656,7 +1656,7 @@ int  TALER_TESTING_get_trait_coin_priv    (const struct TALER_TESTING_Command *cmd,     unsigned int index, -   struct TALER_CoinSpendPrivateKeyP **coin_priv); +   const struct TALER_CoinSpendPrivateKeyP **coin_priv);  /**   * Offer blinding key. | 
