diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2023-11-09 14:11:38 +0100 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2023-11-09 14:11:38 +0100 |
commit | 5ebc9d465458541f28b3673620a172a4a7fb24c2 (patch) | |
tree | aef697c2918bb20ae8b63d03764f11ed36ee8734 | |
parent | e18e0809b7657688c8301632f3e803686610fa6f (diff) |
-more work on coin history testing
-rw-r--r-- | src/include/taler_exchange_service.h | 9 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_batch_deposit.c | 26 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_coin_history.c | 7 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_deposit.c | 10 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_refresh.c | 26 |
5 files changed, 71 insertions, 7 deletions
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 8f5f4c4d2..d2bf918da 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -3277,11 +3277,16 @@ struct TALER_EXCHANGE_RefreshData */ struct TALER_CoinSpendPrivateKeyP melt_priv; - /* - * age commitment and proof and its hash that went into the original coin, + /** + * age commitment and proof that went into the original coin, * might be NULL. */ const struct TALER_AgeCommitmentProof *melt_age_commitment_proof; + + /** + * Hash of age commitment and proof that went into the original coin, + * might be NULL. + */ const struct TALER_AgeCommitmentHash *melt_h_age_commitment; /** diff --git a/src/testing/testing_api_cmd_batch_deposit.c b/src/testing/testing_api_cmd_batch_deposit.c index ef54e6a03..21d73bf5e 100644 --- a/src/testing/testing_api_cmd_batch_deposit.c +++ b/src/testing/testing_api_cmd_batch_deposit.c @@ -75,6 +75,12 @@ struct Coin const struct TALER_TESTING_Command *coin_cmd; /** + * Expected entry in the coin history created by this + * coin. + */ + struct TALER_EXCHANGE_CoinHistoryEntry che; + + /** * Index of the coin at @e coin_cmd. */ unsigned int coin_idx; @@ -369,6 +375,19 @@ batch_deposit_run (void *cls, coin_priv, &cdd->coin_sig); coin->coin_sig = cdd->coin_sig; + coin->che.type = TALER_EXCHANGE_CTT_DEPOSIT; + coin->che.amount = coin->amount; + coin->che.details.deposit.h_wire = h_wire; + coin->che.details.deposit.h_contract_terms = h_contract_terms; + coin->che.details.deposit.no_h_policy = true; + coin->che.details.deposit.no_wallet_data_hash = true; + coin->che.details.deposit.wallet_timestamp = ds->wallet_timestamp; + coin->che.details.deposit.merchant_pub = merchant_pub; + coin->che.details.deposit.refund_deadline = ds->refund_deadline; + coin->che.details.deposit.sig = cdd->coin_sig; + coin->che.details.deposit.no_hac = GNUNET_is_zero (&cdd->h_age_commitment); + coin->che.details.deposit.hac = cdd->h_age_commitment; + coin->che.details.deposit.deposit_fee = denom_pub->fees.deposit; } GNUNET_assert (NULL == ds->dh); @@ -460,6 +479,7 @@ batch_deposit_traits (void *cls, struct Coin *coin = &ds->coins[index]; /* Will point to coin cmd internals. */ const struct TALER_CoinSpendPrivateKeyP *coin_spent_priv; + struct TALER_CoinSpendPublicKeyP coin_spent_pub; const struct TALER_AgeCommitmentProof *age_commitment_proof; if (index >= ds->num_coins) @@ -486,6 +506,10 @@ batch_deposit_traits (void *cls, TALER_TESTING_interpreter_fail (ds->is); return GNUNET_NO; } + + GNUNET_CRYPTO_eddsa_key_get_public (&coin_spent_priv->eddsa_priv, + &coin_spent_pub.eddsa_pub); + { struct TALER_TESTING_Trait traits[] = { /* First two traits are only available if @@ -500,6 +524,8 @@ batch_deposit_traits (void *cls, TALER_TESTING_make_trait_merchant_priv (&ds->merchant_priv), TALER_TESTING_make_trait_age_commitment_proof (index, age_commitment_proof), + TALER_TESTING_make_trait_coin_pub (index, + &coin_spent_pub), TALER_TESTING_make_trait_coin_priv (index, coin_spent_priv), TALER_TESTING_make_trait_coin_sig (index, diff --git a/src/testing/testing_api_cmd_coin_history.c b/src/testing/testing_api_cmd_coin_history.c index d4b95fb48..38905b353 100644 --- a/src/testing/testing_api_cmd_coin_history.c +++ b/src/testing/testing_api_cmd_coin_history.c @@ -132,9 +132,12 @@ history_entry_cmp ( return 1; return 0; case TALER_EXCHANGE_CTT_MELT: - if (0 != GNUNET_memcmp (&h1->details.melt.sig, - &h2->details.melt.sig)) + if (0 != GNUNET_memcmp (&h1->details.melt.h_age_commitment, + &h2->details.melt.h_age_commitment)) return 1; + /* Note: most other fields are not initialized + in the trait as they are hard to extract from + the API */ return 0; case TALER_EXCHANGE_CTT_REFUND: if (0 != GNUNET_memcmp (&h1->details.refund.sig, diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c index 0b908cc66..41aa1c99a 100644 --- a/src/testing/testing_api_cmd_deposit.c +++ b/src/testing/testing_api_cmd_deposit.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018-2021 Taler Systems SA + Copyright (C) 2018-2023 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 @@ -568,6 +568,7 @@ deposit_traits (void *cls, const struct TALER_TESTING_Command *coin_cmd; /* Will point to coin cmd internals. */ const struct TALER_CoinSpendPrivateKeyP *coin_spent_priv; + struct TALER_CoinSpendPublicKeyP coin_spent_pub; const struct TALER_AgeCommitmentProof *age_commitment_proof; const struct TALER_AgeCommitmentHash *h_age_commitment; @@ -605,10 +606,13 @@ deposit_traits (void *cls, return GNUNET_NO; } + GNUNET_CRYPTO_eddsa_key_get_public (&coin_spent_priv->eddsa_priv, + &coin_spent_pub.eddsa_pub); + { struct TALER_TESTING_Trait traits[] = { /* First two traits are only available if - ds->traits is #GNUNET_YES */ + ds->traits is true */ TALER_TESTING_make_trait_exchange_pub (0, &ds->exchange_pub), TALER_TESTING_make_trait_exchange_sig (0, @@ -618,6 +622,8 @@ deposit_traits (void *cls, &ds->che), TALER_TESTING_make_trait_coin_priv (0, coin_spent_priv), + TALER_TESTING_make_trait_coin_pub (0, + &coin_spent_pub), TALER_TESTING_make_trait_coin_sig (0, &ds->coin_sig), TALER_TESTING_make_trait_age_commitment_proof (0, diff --git a/src/testing/testing_api_cmd_refresh.c b/src/testing/testing_api_cmd_refresh.c index c5e20f2ad..c1555a901 100644 --- a/src/testing/testing_api_cmd_refresh.c +++ b/src/testing/testing_api_cmd_refresh.c @@ -118,6 +118,12 @@ struct RefreshMeltState struct TALER_EXCHANGE_MeltHandle *rmh; /** + * Expected entry in the coin history created by this + * operation. + */ + struct TALER_EXCHANGE_CoinHistoryEntry che; + + /** * Interpreter state. */ struct TALER_TESTING_Interpreter *is; @@ -145,6 +151,11 @@ struct RefreshMeltState const struct TALER_CoinSpendPrivateKeyP *melt_priv; /** + * Public key of the dirty coin being melted. + */ + struct TALER_CoinSpendPublicKeyP melt_pub; + + /** * Task scheduled to try later. */ struct GNUNET_SCHEDULER_Task *retry_task; @@ -1147,6 +1158,8 @@ melt_run (void *cls, } /* end for */ rms->refresh_data.melt_priv = *rms->melt_priv; + GNUNET_CRYPTO_eddsa_key_get_public (&rms->melt_priv->eddsa_priv, + &rms->melt_pub.eddsa_pub); rms->refresh_data.melt_amount = melt_amount; rms->refresh_data.melt_sig = *melt_sig; rms->refresh_data.melt_pk = *melt_denom_pub; @@ -1165,6 +1178,13 @@ melt_run (void *cls, GNUNET_assert ((NULL == age_commitment_proof) || (0 < age_commitment_proof->commitment.num)); + rms->che.type = TALER_EXCHANGE_CTT_MELT; + rms->che.amount = melt_amount; + if (NULL != age_commitment_proof) + rms->che.details.melt.h_age_commitment = *h_age_commitment; + else + rms->che.details.melt.no_hac = true; + rms->rmh = TALER_EXCHANGE_melt ( TALER_TESTING_interpreter_get_context (is), TALER_TESTING_get_exchange_url (is), @@ -1253,8 +1273,12 @@ melt_traits (void *cls, struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_denom_pub (index, &rms->fresh_pks[index]), - TALER_TESTING_make_trait_coin_priv (index, + TALER_TESTING_make_trait_coin_priv (0, rms->melt_priv), + TALER_TESTING_make_trait_coin_pub (0, + &rms->melt_pub), + TALER_TESTING_make_trait_coin_history (0, + &rms->che), TALER_TESTING_make_trait_age_commitment_proof ( index, rms->refresh_data.melt_age_commitment_proof), |