diff options
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/test_auditor_api.c | 2 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_auditor_deposit_confirmation.c | 48 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_batch_deposit.c | 31 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_deposit.c | 15 |
4 files changed, 56 insertions, 40 deletions
diff --git a/src/testing/test_auditor_api.c b/src/testing/test_auditor_api.c index 8c45f732f..ac147d931 100644 --- a/src/testing/test_auditor_api.c +++ b/src/testing/test_auditor_api.c @@ -635,7 +635,7 @@ run (void *cls, MHD_HTTP_OK), TALER_TESTING_cmd_deposit_confirmation ("deposit-confirmation", "massive-deposit-10", - 0, + 1, "EUR:0.99", MHD_HTTP_OK), CMD_RUN_AUDITOR ("massive-auditor"), diff --git a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c index 1e5a63447..9477a5d7e 100644 --- a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c +++ b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c @@ -59,9 +59,9 @@ struct DepositConfirmationState const char *amount_without_fee; /** - * Which coin of the @e deposit_reference should we confirm. + * How many coins were there in the @e deposit_reference? */ - unsigned int coin_index; + unsigned int num_coins; /** * DepositConfirmation handle while operation is running. @@ -201,14 +201,15 @@ deposit_confirmation_run (void *cls, struct GNUNET_TIME_Timestamp refund_deadline = GNUNET_TIME_UNIT_ZERO_TS; struct TALER_Amount amount_without_fee; - struct TALER_CoinSpendPublicKeyP coin_pub; + struct TALER_CoinSpendPublicKeyP coin_pubs[dcs->num_coins]; + const struct TALER_CoinSpendPublicKeyP *coin_pubps[dcs->num_coins]; + const struct TALER_CoinSpendSignatureP *coin_sigps[dcs->num_coins]; const struct TALER_MerchantPrivateKeyP *merchant_priv; struct TALER_MerchantPublicKeyP merchant_pub; const struct TALER_ExchangePublicKeyP *exchange_pub; const struct TALER_ExchangeSignatureP *exchange_sig; const json_t *wire_details; const json_t *contract_terms; - const struct TALER_CoinSpendPrivateKeyP *coin_priv; const struct TALER_EXCHANGE_Keys *keys; const struct TALER_EXCHANGE_SigningPublicKey *spk; const char *auditor_url; @@ -249,19 +250,19 @@ deposit_confirmation_run (void *cls, GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_exchange_pub (deposit_cmd, - dcs->coin_index, + 0, &exchange_pub)); GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_exchange_sig (deposit_cmd, - dcs->coin_index, + 0, &exchange_sig)); GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_timestamp (deposit_cmd, - dcs->coin_index, + 0, &exchange_timestamp)); GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_wire_deadline (deposit_cmd, - dcs->coin_index, + 0, &wire_deadline)); GNUNET_assert (NULL != exchange_timestamp); keys = TALER_TESTING_get_keys (is); @@ -283,12 +284,23 @@ deposit_confirmation_run (void *cls, GNUNET_assert (GNUNET_OK == TALER_JSON_merchant_wire_signature_hash (wire_details, &h_wire)); - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_coin_priv (deposit_cmd, - dcs->coin_index, - &coin_priv)); - GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, - &coin_pub.eddsa_pub); + + for (unsigned int i = 0; i<dcs->num_coins; i++) + { + const struct TALER_CoinSpendPrivateKeyP *coin_priv; + + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_coin_priv (deposit_cmd, + i, + &coin_priv)); + GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, + &coin_pubs[i].eddsa_pub); + coin_pubps[i] = &coin_pubs[i]; + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_coin_sig (deposit_cmd, + i, + &coin_sigps[i])); + } GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_merchant_priv (deposit_cmd, &merchant_priv)); @@ -331,7 +343,9 @@ deposit_confirmation_run (void *cls, *wire_deadline, refund_deadline, &amount_without_fee, - &coin_pub, + dcs->num_coins, + coin_pubps, + coin_sigps, &merchant_pub, exchange_pub, exchange_sig, @@ -385,7 +399,7 @@ deposit_confirmation_cleanup (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_deposit_confirmation (const char *label, const char *deposit_reference, - unsigned int coin_index, + unsigned int num_coins, const char *amount_without_fee, unsigned int expected_response_code) { @@ -393,7 +407,7 @@ TALER_TESTING_cmd_deposit_confirmation (const char *label, dcs = GNUNET_new (struct DepositConfirmationState); dcs->deposit_reference = deposit_reference; - dcs->coin_index = coin_index; + dcs->num_coins = num_coins; dcs->amount_without_fee = amount_without_fee; dcs->expected_response_code = expected_response_code; diff --git a/src/testing/testing_api_cmd_batch_deposit.c b/src/testing/testing_api_cmd_batch_deposit.c index a3c25e355..ef54e6a03 100644 --- a/src/testing/testing_api_cmd_batch_deposit.c +++ b/src/testing/testing_api_cmd_batch_deposit.c @@ -59,6 +59,11 @@ struct Coin struct TALER_Amount deposit_fee; /** + * Our coin signature. + */ + struct TALER_CoinSpendSignatureP coin_sig; + + /** * Reference to any command that is able to provide a coin, * possibly using $LABEL#$INDEX notation. */ @@ -151,10 +156,9 @@ struct BatchDepositState struct GNUNET_SCHEDULER_Task *retry_task; /** - * Array of @e num_coins signatures from the exchange on the - * deposit confirmation. + * Deposit confirmation signature from the exchange. */ - struct TALER_ExchangeSignatureP *exchange_sigs; + struct TALER_ExchangeSignatureP exchange_sig; /** * Reference to previous deposit operation. @@ -205,19 +209,10 @@ batch_deposit_cb (void *cls, } if (MHD_HTTP_OK == dr->hr.http_status) { - if (ds->num_coins != dr->details.ok.num_signatures) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (ds->is); - return; - } ds->deposit_succeeded = GNUNET_YES; ds->exchange_timestamp = dr->details.ok.deposit_timestamp; ds->exchange_pub = *dr->details.ok.exchange_pub; - ds->exchange_sigs = GNUNET_memdup (dr->details.ok.exchange_sigs, - dr->details.ok.num_signatures - * sizeof (struct - TALER_ExchangeSignatureP)); + ds->exchange_sig = *dr->details.ok.exchange_sig; } TALER_TESTING_interpreter_next (ds->is); } @@ -373,6 +368,7 @@ batch_deposit_run (void *cls, ds->refund_deadline, coin_priv, &cdd->coin_sig); + coin->coin_sig = cdd->coin_sig; } GNUNET_assert (NULL == ds->dh); @@ -439,7 +435,6 @@ batch_deposit_cleanup (void *cls, for (unsigned int i = 0; i<ds->num_coins; i++) GNUNET_free (ds->coins[i].coin_reference); GNUNET_free (ds->coins); - GNUNET_free (ds->exchange_sigs); json_decref (ds->wire_details); json_decref (ds->contract_terms); GNUNET_free (ds); @@ -495,10 +490,10 @@ batch_deposit_traits (void *cls, struct TALER_TESTING_Trait traits[] = { /* First two traits are only available if ds->traits is #GNUNET_YES */ - TALER_TESTING_make_trait_exchange_pub (index, + TALER_TESTING_make_trait_exchange_pub (0, &ds->exchange_pub), - TALER_TESTING_make_trait_exchange_sig (index, - &ds->exchange_sigs[index]), + TALER_TESTING_make_trait_exchange_sig (0, + &ds->exchange_sig), /* These traits are always available */ TALER_TESTING_make_trait_wire_details (ds->wire_details), TALER_TESTING_make_trait_contract_terms (ds->contract_terms), @@ -507,6 +502,8 @@ batch_deposit_traits (void *cls, age_commitment_proof), TALER_TESTING_make_trait_coin_priv (index, coin_spent_priv), + TALER_TESTING_make_trait_coin_sig (index, + &coin->coin_sig), TALER_TESTING_make_trait_deposit_amount (index, &coin->amount), TALER_TESTING_make_trait_deposit_fee_amount (index, diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c index 0ee6aa447..61074afa7 100644 --- a/src/testing/testing_api_cmd_deposit.c +++ b/src/testing/testing_api_cmd_deposit.c @@ -69,6 +69,11 @@ struct DepositState unsigned int coin_index; /** + * Our coin signature. + */ + struct TALER_CoinSpendSignatureP coin_sig; + + /** * Wire details of who is depositing -- this would be merchant * wire details in a normal scenario. */ @@ -258,11 +263,10 @@ deposit_cb (void *cls, } if (MHD_HTTP_OK == dr->hr.http_status) { - GNUNET_assert (1 == dr->details.ok.num_signatures); ds->deposit_succeeded = GNUNET_YES; ds->exchange_timestamp = dr->details.ok.deposit_timestamp; ds->exchange_pub = *dr->details.ok.exchange_pub; - ds->exchange_sig = dr->details.ok.exchange_sigs[0]; + ds->exchange_sig = *dr->details.ok.exchange_sig; } TALER_TESTING_interpreter_next (ds->is); } @@ -287,7 +291,6 @@ deposit_run (void *cls, const struct TALER_AgeCommitmentHash *phac; const struct TALER_EXCHANGE_DenomPublicKey *denom_pub; const struct TALER_DenominationSignature *denom_pub_sig; - struct TALER_CoinSpendSignatureP coin_sig; struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_PrivateContractHashP h_contract_terms; enum TALER_ErrorCode ec; @@ -449,14 +452,14 @@ deposit_run (void *cls, &merchant_pub, ds->refund_deadline, coin_priv, - &coin_sig); + &ds->coin_sig); } GNUNET_assert (NULL == ds->dh); { struct TALER_EXCHANGE_CoinDepositDetail cdd = { .amount = ds->amount, .coin_pub = coin_pub, - .coin_sig = coin_sig, + .coin_sig = ds->coin_sig, .denom_sig = *denom_pub_sig, .h_denom_pub = denom_pub->h_key, .h_age_commitment = {{{0}}}, @@ -595,6 +598,8 @@ deposit_traits (void *cls, /* These traits are always available */ TALER_TESTING_make_trait_coin_priv (0, coin_spent_priv), + TALER_TESTING_make_trait_coin_sig (0, + &ds->coin_sig), TALER_TESTING_make_trait_age_commitment_proof (0, age_commitment_proof), TALER_TESTING_make_trait_h_age_commitment (0, |