commit e26d0c1c289ecce245b5652dd1d8931ba8dee70d
parent 63a4bf4d691304daf9586023e24412701d869a6f
Author: Özgür Kesim <oec@codeblau.de>
Date: Wed, 7 May 2025 10:27:15 +0200
[testing] added support for idempotent withdrawal in the CS case
Diffstat:
3 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
@@ -1188,6 +1188,9 @@ TALER_TESTING_cmd_withdraw_reveal_age_proof (
* coin private key in the process (violating the specification,
* which will result in an error when spending the coin!).
*
+ * Note that in case of CS denominations, the blinding seed
+ * will still differ!
+ *
* @param label command label.
* @param reserve_reference command providing us with a reserve to withdraw from
* @param amount how much we withdraw.
@@ -1209,6 +1212,33 @@ TALER_TESTING_cmd_withdraw_amount_reuse_key (
/**
+ * Create a withdraw command, letting the caller specify
+ * the desired amount as string and also reusing an existing
+ * coin private key _and_ blinding seed in the process
+ * (violating the specification, which will result in an error
+ * when spending the coin!).
+ *
+ * @param label command label.
+ * @param reserve_reference command providing us with a reserve to withdraw from
+ * @param amount how much we withdraw.
+ * @param age if > 0, age restriction applies.
+ * @param coin_ref reference to (withdraw/reveal) command of a coin
+ * from which we should reuse the private key
+ * @param expected_response_code which HTTP response code
+ * we expect from the exchange.
+ * @return the withdraw command to be executed by the interpreter.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_withdraw_amount_reuse_all_secrets (
+ const char *label,
+ const char *reserve_reference,
+ const char *amount,
+ uint8_t age,
+ const char *coin_ref,
+ unsigned int expected_response_code);
+
+
+/**
* Create withdraw command, letting the caller specify the
* amount by a denomination key.
*
diff --git a/src/testing/test_exchange_api_age_restriction.c b/src/testing/test_exchange_api_age_restriction.c
@@ -137,9 +137,9 @@ run (void *cls,
13,
MHD_HTTP_OK),
/**
- * Idempotent withdrawal
+ * Idempotent withdrawal.
*/
- TALER_TESTING_cmd_withdraw_amount_reuse_key (
+ TALER_TESTING_cmd_withdraw_amount_reuse_all_secrets (
"withdraw-coin-age-idem-1",
"create-reserve-age",
"EUR:5",
diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c
@@ -68,6 +68,12 @@ struct WithdrawState
const char *reuse_coin_key_ref;
/**
+ * If true and @e reuse_coin_key_ref is not NULL, also reuses
+ * the blinding_seed.
+ */
+ bool reuse_blinding_seed;
+
+ /**
* Our command.
*/
const struct TALER_TESTING_Command *cmd;
@@ -433,6 +439,10 @@ withdraw_run (void *cls,
TALER_TESTING_get_trait_withdraw_seed (cref,
&seed));
ws->seed = *seed;
+
+ if (ws->reuse_blinding_seed)
+ TALER_cs_withdraw_seed_to_blinding_seed (&ws->seed,
+ &ws->blinding_seed);
}
if (NULL == ws->pk)
@@ -652,6 +662,32 @@ TALER_TESTING_cmd_withdraw_amount_reuse_key (
struct TALER_TESTING_Command
+TALER_TESTING_cmd_withdraw_amount_reuse_all_secrets (
+ const char *label,
+ const char *reserve_reference,
+ const char *amount,
+ uint8_t age,
+ const char *coin_ref,
+ unsigned int expected_response_code)
+{
+ struct TALER_TESTING_Command cmd;
+
+ cmd = TALER_TESTING_cmd_withdraw_amount (label,
+ reserve_reference,
+ amount,
+ age,
+ expected_response_code);
+ {
+ struct WithdrawState *ws = cmd.cls;
+
+ ws->reuse_coin_key_ref = coin_ref;
+ ws->reuse_blinding_seed = true;
+ }
+ return cmd;
+}
+
+
+struct TALER_TESTING_Command
TALER_TESTING_cmd_withdraw_denomination (
const char *label,
const char *reserve_reference,