diff options
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing_api_cmd_coin_history.c | 24 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_purse_create_deposit.c | 80 |
2 files changed, 79 insertions, 25 deletions
diff --git a/src/testing/testing_api_cmd_coin_history.c b/src/testing/testing_api_cmd_coin_history.c index 811e43702..a1345f67f 100644 --- a/src/testing/testing_api_cmd_coin_history.c +++ b/src/testing/testing_api_cmd_coin_history.c @@ -120,7 +120,12 @@ history_entry_cmp ( return 1; if (0 != TALER_amount_cmp (&h1->amount, &h2->amount)) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Amount mismatch (%s)\n", + TALER_amount2s (&h1->amount)); return 1; + } switch (h1->type) { case TALER_EXCHANGE_CTT_NONE: @@ -178,10 +183,21 @@ history_entry_cmp ( /* coin_sig is not initialized */ if (0 != GNUNET_memcmp (&h1->details.purse_deposit.purse_pub, &h2->details.purse_deposit.purse_pub)) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Purse public key mismatch\n"); return 1; + } if (0 != strcmp (h1->details.purse_deposit.exchange_base_url, h2->details.purse_deposit.exchange_base_url)) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Exchange base URL mismatch (%s/%s)\n", + h1->details.purse_deposit.exchange_base_url, + h2->details.purse_deposit.exchange_base_url); + GNUNET_break (0); return 1; + } return 0; case TALER_EXCHANGE_CTT_PURSE_REFUND: /* NOTE: not supported yet (trait not returned) */ @@ -259,12 +275,18 @@ analyze_command (void *cls, TALER_TESTING_get_trait_coin_pub (cmd, j, &rp)) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Command `%s#%u' has no public key for a coin\n", + cmd->label, + j); break; /* command does nothing for coins */ + } if (0 != GNUNET_memcmp (rp, coin_pub)) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Command `%s#%u' is about another coin\n", cmd->label, j); diff --git a/src/testing/testing_api_cmd_purse_create_deposit.c b/src/testing/testing_api_cmd_purse_create_deposit.c index cf9929465..4740f9801 100644 --- a/src/testing/testing_api_cmd_purse_create_deposit.c +++ b/src/testing/testing_api_cmd_purse_create_deposit.c @@ -44,10 +44,20 @@ struct Coin unsigned int coin_index; /** + * Public key of the deposited coin. + */ + struct TALER_CoinSpendPublicKeyP coin_pub; + + /** * Amount to deposit (with fee). */ struct TALER_Amount deposit_with_fee; + /** + * Entry in the coin's history generated by this operation. + */ + struct TALER_EXCHANGE_CoinHistoryEntry che; + }; @@ -193,9 +203,15 @@ deposit_run (void *cls, (void) cmd; ds->is = is; + GNUNET_CRYPTO_eddsa_key_create (&ds->purse_priv.eddsa_priv); + GNUNET_CRYPTO_eddsa_key_create (&ds->merge_priv.eddsa_priv); + GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv); + GNUNET_CRYPTO_eddsa_key_get_public (&ds->purse_priv.eddsa_priv, + &ds->purse_pub.eddsa_pub); + for (unsigned int i = 0; i<ds->num_coin_references; i++) { - const struct Coin *cr = &ds->coin_references[i]; + struct Coin *cr = &ds->coin_references[i]; struct TALER_EXCHANGE_PurseDeposit *pd = &deposits[i]; const struct TALER_TESTING_Command *coin_cmd; const struct TALER_CoinSpendPrivateKeyP *coin_priv; @@ -239,14 +255,20 @@ deposit_run (void *cls, pd->coin_priv = *coin_priv; pd->amount = cr->deposit_with_fee; pd->h_denom_pub = denom_pub->h_key; + GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, + &cr->coin_pub.eddsa_pub); + cr->che.type = TALER_EXCHANGE_CTT_PURSE_DEPOSIT; + cr->che.amount = cr->deposit_with_fee; + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->purse_priv.eddsa_priv, + &cr->che.details.purse_deposit.purse_pub.eddsa_pub); + cr->che.details.purse_deposit.exchange_base_url + = TALER_TESTING_get_exchange_url (is); + TALER_age_commitment_hash ( + &age_commitment_proof->commitment, + &cr->che.details.purse_deposit.phac); } - GNUNET_CRYPTO_eddsa_key_create (&ds->purse_priv.eddsa_priv); - GNUNET_CRYPTO_eddsa_key_create (&ds->merge_priv.eddsa_priv); - GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv); - GNUNET_CRYPTO_eddsa_key_get_public (&ds->purse_priv.eddsa_priv, - &ds->purse_pub.eddsa_pub); - ds->purse_expiration = GNUNET_TIME_absolute_to_timestamp ( GNUNET_TIME_relative_to_absolute (ds->rel_expiration)); @@ -323,23 +345,33 @@ deposit_traits (void *cls, unsigned int index) { struct PurseCreateDepositState *ds = cls; - struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_merge_priv (&ds->merge_priv), - TALER_TESTING_make_trait_contract_priv (&ds->contract_priv), - TALER_TESTING_make_trait_purse_priv (&ds->purse_priv), - TALER_TESTING_make_trait_purse_pub (&ds->purse_pub), - TALER_TESTING_make_trait_contract_terms (ds->contract_terms), - TALER_TESTING_make_trait_deposit_amount (0, - &ds->target_amount), - TALER_TESTING_make_trait_timestamp (index, - &ds->purse_expiration), - TALER_TESTING_trait_end () - }; - - return TALER_TESTING_get_trait (traits, - ret, - trait, - index); + if (index >= ds->num_coin_references) + return GNUNET_NO; + + { + const struct Coin *co = &ds->coin_references[index]; + struct TALER_TESTING_Trait traits[] = { + TALER_TESTING_make_trait_merge_priv (&ds->merge_priv), + TALER_TESTING_make_trait_contract_priv (&ds->contract_priv), + TALER_TESTING_make_trait_coin_history (index, + &co->che), + TALER_TESTING_make_trait_coin_pub (index, + &co->coin_pub), + TALER_TESTING_make_trait_purse_priv (&ds->purse_priv), + TALER_TESTING_make_trait_purse_pub (&ds->purse_pub), + TALER_TESTING_make_trait_contract_terms (ds->contract_terms), + TALER_TESTING_make_trait_deposit_amount (0, + &ds->target_amount), + TALER_TESTING_make_trait_timestamp (index, + &ds->purse_expiration), + TALER_TESTING_trait_end () + }; + + return TALER_TESTING_get_trait (traits, + ret, + trait, + index); + } } |