diff options
Diffstat (limited to 'src/testing/testing_api_cmd_batch_withdraw.c')
-rw-r--r-- | src/testing/testing_api_cmd_batch_withdraw.c | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/src/testing/testing_api_cmd_batch_withdraw.c b/src/testing/testing_api_cmd_batch_withdraw.c index a106b8150..98bbb7e26 100644 --- a/src/testing/testing_api_cmd_batch_withdraw.c +++ b/src/testing/testing_api_cmd_batch_withdraw.c @@ -173,6 +173,11 @@ struct BatchWithdrawState * Same for all coins in the batch. */ uint8_t age; + + /** + * Force a conflict: + */ + bool force_conflict; }; @@ -195,9 +200,10 @@ reserve_batch_withdraw_cb (void *cls, ws->wsh = NULL; if (ws->expected_response_code != wr->hr.http_status) { - TALER_TESTING_unexpected_status (is, - wr->hr.http_status, - ws->expected_response_code); + TALER_TESTING_unexpected_status_with_body (is, + wr->hr.http_status, + ws->expected_response_code, + wr->hr.reply); return; } switch (wr->hr.http_status) @@ -265,6 +271,8 @@ batch_withdraw_run (void *cls, const struct TALER_TESTING_Command *create_reserve; const struct TALER_EXCHANGE_DenomPublicKey *dpk; struct TALER_EXCHANGE_WithdrawCoinInput wcis[ws->num_coins]; + struct TALER_PlanchetMasterSecretP conflict_ps = {0}; + struct TALER_AgeMask mask = {0}; (void) cmd; ws->is = is; @@ -297,12 +305,37 @@ batch_withdraw_run (void *cls, = TALER_reserve_make_payto (ws->exchange_url, &ws->reserve_pub); + if (0 < ws->age) + mask = TALER_extensions_get_age_restriction_mask (); + + if (ws->force_conflict) + TALER_planchet_master_setup_random (&conflict_ps); + for (unsigned int i = 0; i<ws->num_coins; i++) { struct CoinState *cs = &ws->coins[i]; struct TALER_EXCHANGE_WithdrawCoinInput *wci = &wcis[i]; - TALER_planchet_master_setup_random (&cs->ps); + if (ws->force_conflict) + cs->ps = conflict_ps; + else + TALER_planchet_master_setup_random (&cs->ps); + + if (0 < ws->age) + { + struct GNUNET_HashCode seed = {0}; + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, + &seed, + sizeof(seed)); + TALER_age_restriction_commit (&mask, + ws->age, + &seed, + &cs->age_commitment_proof); + TALER_age_commitment_hash (&cs->age_commitment_proof.commitment, + &cs->h_age_commitment); + } + + dpk = TALER_TESTING_find_pk (keys, &cs->amount, ws->age > 0); @@ -455,12 +488,14 @@ batch_withdraw_traits (void *cls, struct TALER_TESTING_Command -TALER_TESTING_cmd_batch_withdraw (const char *label, - const char *reserve_reference, - uint8_t age, - unsigned int expected_response_code, - const char *amount, - ...) +TALER_TESTING_cmd_batch_withdraw_with_conflict ( + const char *label, + const char *reserve_reference, + bool conflict, + uint8_t age, + unsigned int expected_response_code, + const char *amount, + ...) { struct BatchWithdrawState *ws; unsigned int cnt; @@ -470,6 +505,7 @@ TALER_TESTING_cmd_batch_withdraw (const char *label, ws->age = age; ws->reserve_reference = reserve_reference; ws->expected_response_code = expected_response_code; + ws->force_conflict = conflict; cnt = 1; va_start (ap, @@ -487,23 +523,6 @@ TALER_TESTING_cmd_batch_withdraw (const char *label, { struct CoinState *cs = &ws->coins[i]; - if (0 < age) - { - struct GNUNET_HashCode seed; - struct TALER_AgeMask mask; - - mask = TALER_extensions_get_age_restriction_mask (); - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, - &seed, - sizeof(seed)); - TALER_age_restriction_commit (&mask, - age, - &seed, - &cs->age_commitment_proof); - TALER_age_commitment_hash (&cs->age_commitment_proof.commitment, - &cs->h_age_commitment); - } - if (GNUNET_OK != TALER_string_to_amount (amount, &cs->amount)) |