commit 1d5841ec7caa9a28946d7e080d0ed747af144b55
parent 28b573fa28a04e8929356f48f3a40e70d3c25e67
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 12 Jul 2026 22:46:00 +0200
fix reserve history testing
Diffstat:
2 files changed, 39 insertions(+), 21 deletions(-)
diff --git a/src/testing/testing_api_cmd_batch_withdraw.c b/src/testing/testing_api_cmd_batch_withdraw.c
@@ -120,7 +120,6 @@ struct BatchWithdrawState
*/
struct TALER_WithdrawMasterSeedP seed;
-
/**
* Set to the KYC requirement payto hash *if* the exchange replied with a
* request for KYC.
@@ -149,7 +148,6 @@ struct BatchWithdrawState
*/
unsigned int expected_response_code;
-
/**
* Reserve history entry that corresponds to this withdrawal.
* Will be of type #TALER_EXCHANGE_RTT_WITHDRAWAL.
@@ -309,9 +307,7 @@ batch_withdraw_run (void *cls,
struct CoinState *cs = &ws->coins[i];
struct TALER_Amount amount;
-
cs->secret = secrets[i];
-
dpk = TALER_TESTING_find_pk (keys,
&cs->amount,
false); /* no age restriction */
@@ -347,12 +343,13 @@ batch_withdraw_run (void *cls,
&ws->reserve_history.details.withdraw.fee,
&ws->reserve_history.details.withdraw.fee,
&cs->pk->fees.withdraw));
-
+ ws->reserve_history.details.withdraw.age_restricted = (0 != ws->age);
+ ws->reserve_history.details.withdraw.max_age = ws->age;
denoms_pub[i] = *cs->pk;
TALER_denom_pub_copy (&denoms_pub[i].key,
&cs->pk->key);
}
-
+ ws->reserve_history.details.withdraw.num_coins = ws->num_coins;
ws->reserve_history.type = TALER_EXCHANGE_RTT_WITHDRAWAL;
ws->wsh = TALER_EXCHANGE_post_withdraw_create (
@@ -364,7 +361,7 @@ batch_withdraw_run (void *cls,
denoms_pub,
&ws->seed,
0);
- for (unsigned int i = 0; i<ws->num_coins; i++)
+ for (unsigned int i = 0; i < ws->num_coins; i++)
TALER_denom_pub_free (&denoms_pub[i].key);
if (NULL == ws->wsh)
{
@@ -441,7 +438,7 @@ batch_withdraw_traits (void *cls,
struct CoinState *cs = &ws->coins[index];
struct TALER_TESTING_Trait traits[] = {
/* history entry MUST be first due to response code logic below! */
- TALER_TESTING_make_trait_reserve_history (index,
+ TALER_TESTING_make_trait_reserve_history (0, /* only 1 trait, not per coin! */
&ws->reserve_history),
TALER_TESTING_make_trait_coin_priv (index,
&cs->details.coin_priv),
@@ -471,13 +468,13 @@ batch_withdraw_traits (void *cls,
TALER_TESTING_make_trait_age_commitment_proof (
index,
ws->age > 0
- ? &cs->details.age_commitment_proof
- : NULL),
+ ? &cs->details.age_commitment_proof
+ : NULL),
TALER_TESTING_make_trait_h_age_commitment (
index,
ws->age > 0
- ? &cs->details.h_age_commitment
- : NULL),
+ ? &cs->details.h_age_commitment
+ : NULL),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_cmd_reserve_history.c b/src/testing/testing_api_cmd_reserve_history.c
@@ -123,7 +123,10 @@ history_entry_cmp (
switch (h1->type)
{
case TALER_EXCHANGE_RTT_CREDIT:
- if ( (0 ==
+ if ( (GNUNET_OK ==
+ TALER_amount_cmp_currency (&h1->amount,
+ &h2->amount)) &&
+ (0 ==
TALER_amount_cmp (&h1->amount,
&h2->amount)) &&
(0 ==
@@ -137,7 +140,10 @@ history_entry_cmp (
return 0;
return 1;
case TALER_EXCHANGE_RTT_WITHDRAWAL:
- if ( (0 ==
+ if ( (GNUNET_OK ==
+ TALER_amount_cmp_currency (&h1->amount,
+ &h2->amount)) &&
+ (0 ==
TALER_amount_cmp (&h1->amount,
&h2->amount)) &&
(0 ==
@@ -152,7 +158,10 @@ history_entry_cmp (
case TALER_EXCHANGE_RTT_RECOUP:
/* exchange_sig, exchange_pub and timestamp are NOT available
from the original recoup response, hence here NOT check(able/ed) */
- if ( (0 ==
+ if ( (GNUNET_OK ==
+ TALER_amount_cmp_currency (&h1->amount,
+ &h2->amount)) &&
+ (0 ==
TALER_amount_cmp (&h1->amount,
&h2->amount)) &&
(0 ==
@@ -165,7 +174,10 @@ history_entry_cmp (
receiver_account_details, exchange_sig, exchange_pub or wtid or timestamp
so we cannot test for it here. but if the amount matches,
that should be good enough. */
- if ( (0 ==
+ if ( (GNUNET_OK ==
+ TALER_amount_cmp_currency (&h1->amount,
+ &h2->amount)) &&
+ (0 ==
TALER_amount_cmp (&h1->amount,
&h2->amount)) &&
(0 ==
@@ -174,7 +186,10 @@ history_entry_cmp (
return 0;
return 1;
case TALER_EXCHANGE_RTT_MERGE:
- if ( (0 ==
+ if ( (GNUNET_OK ==
+ TALER_amount_cmp_currency (&h1->amount,
+ &h2->amount)) &&
+ (0 ==
TALER_amount_cmp (&h1->amount,
&h2->amount)) &&
(0 ==
@@ -208,7 +223,10 @@ history_entry_cmp (
return 0;
return 1;
case TALER_EXCHANGE_RTT_OPEN:
- if ( (0 ==
+ if ( (GNUNET_OK ==
+ TALER_amount_cmp_currency (&h1->amount,
+ &h2->amount)) &&
+ (0 ==
TALER_amount_cmp (&h1->amount,
&h2->amount)) &&
(GNUNET_TIME_timestamp_cmp (
@@ -230,7 +248,10 @@ history_entry_cmp (
return 0;
return 1;
case TALER_EXCHANGE_RTT_CLOSE:
- if ( (0 ==
+ if ( (GNUNET_OK ==
+ TALER_amount_cmp_currency (&h1->amount,
+ &h2->amount)) &&
+ (0 ==
TALER_amount_cmp (&h1->amount,
&h2->amount)) &&
(GNUNET_TIME_timestamp_cmp (
@@ -331,7 +352,7 @@ analyze_command (void *cls,
return; /* command does nothing for reserves */
}
matched = false;
- for (unsigned int i = 0; i<history_length; i++)
+ for (unsigned int i = 0; i < history_length; i++)
{
if (found[i])
continue; /* already found, skip */
@@ -347,7 +368,7 @@ analyze_command (void *cls,
if (! matched)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Command `%s' no relevant reserve history entry not found\n",
+ "Reserve history entry not found for command `%s'\n",
cmd->label);
ac->failure = true;
return;