diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-01-18 18:29:42 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-01-18 18:29:42 +0100 |
commit | e1fef9bf28a55bb3f5fe6dbf52063c56f340d3c4 (patch) | |
tree | 479949b8f89f445899d36da0c64c6c636be75b25 | |
parent | a1922deaf0368ec4dc86b79f22900cdb261cff48 (diff) | |
download | merchant-e1fef9bf28a55bb3f5fe6dbf52063c56f340d3c4.tar.gz merchant-e1fef9bf28a55bb3f5fe6dbf52063c56f340d3c4.tar.bz2 merchant-e1fef9bf28a55bb3f5fe6dbf52063c56f340d3c4.zip |
make it compile again (test cases still don't compile)
-rw-r--r-- | src/lib/merchant_api_pay.c | 4 | ||||
-rw-r--r-- | src/lib/test_merchant_api.c | 76 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_pay.c | 25 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_pay_abort_refund.c | 6 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_proposal.c | 7 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_proposal_lookup.c | 17 | ||||
-rw-r--r-- | src/merchant-tools/taler-merchant-benchmark.c | 39 |
7 files changed, 78 insertions, 96 deletions
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c index 1332f465..032dffe5 100644 --- a/src/lib/merchant_api_pay.c +++ b/src/lib/merchant_api_pay.c @@ -241,7 +241,9 @@ check_coin_history (const struct TALER_MERCHANT_PaidCoin *pc, if (GNUNET_OK != TALER_EXCHANGE_verify_coin_history - (pc->amount_with_fee.currency, + ( + NULL, /* do not verify fees */ + pc->amount_with_fee.currency, &pc->coin_pub, json, &spent)) diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c index d4720325..67c2059e 100644 --- a/src/lib/test_merchant_api.c +++ b/src/lib/test_merchant_api.c @@ -55,11 +55,9 @@ static const char *pickup_amounts_1[] = {"EUR:5", NULL}; static char *fakebank_url; static struct TALER_WireTransferIdentifierRawP wtid; -static char *payer_url; static char *payer_payto; static struct TALER_BANK_AuthenticationData auth; static char *exchange_payto; -static char *exchange_account_url; static char *merchant_payto; static struct TALER_TESTING_BankConfiguration bc; static struct TALER_TESTING_ExchangeConfiguration ec; @@ -92,17 +90,17 @@ static struct GNUNET_CONTAINER_MultiHashMap *interned_strings; /** * Account number of the exchange at the bank. */ -#define EXCHANGE_ACCOUNT_PATH "/2" +#define EXCHANGE_ACCOUNT_NAME "2" /** * Account number of some user. */ -#define USER_ACCOUNT_PATH "/62" +#define USER_ACCOUNT_NAME "62" /** * Account number used by the merchant */ -#define MERCHANT_ACCOUNT_PATH "/3" +#define MERCHANT_ACCOUNT_NAME "3" /** * User name. Never checked by fakebank. @@ -120,8 +118,12 @@ static struct GNUNET_CONTAINER_MultiHashMap *interned_strings; * * @param label label to use for the command. */ -#define CMD_EXEC_WIREWATCH(label) \ - TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE) +static struct TALER_TESTING_Command +CMD_EXEC_WIREWATCH (char *label) +{ + return TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE); +} + /** * Execute the taler-exchange-aggregator command with @@ -129,8 +131,12 @@ static struct GNUNET_CONTAINER_MultiHashMap *interned_strings; * * @param label label to use for the command. */ -#define CMD_EXEC_AGGREGATOR(label) \ - TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE) +static struct TALER_TESTING_Command +CMD_EXEC_AGGREGATOR (char *label) +{ + return TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE); +} + /** * Run wire transfer of funds from some user's account to the @@ -140,26 +146,15 @@ static struct GNUNET_CONTAINER_MultiHashMap *interned_strings; * @param amount amount to transfer, i.e. "EUR:1" * @param url exchange_url */ -#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ - TALER_TESTING_cmd_transfer (label, amount, \ - payer_url, \ - &auth, \ - exchange_payto, \ - &wtid, \ - EXCHANGE_URL) +static struct TALER_TESTING_Command +CMD_TRANSFER_TO_EXCHANGE (char *label, char *amount) +{ -/** - * Run wire transfer of funds from some user's account to the - * exchange. - * - * @param label label to use for the command. - * @param amount amount to transfer, i.e. "EUR:1" - */ -#define CMD_TRANSFER_TO_EXCHANGE_SUBJECT(label,amount,subject) \ - TALER_TESTING_cmd_fakebank_transfer_with_subject \ - (label, amount, fakebank_url, USER_ACCOUNT_NO, \ - EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \ - subject) + return TALER_TESTING_cmd_admin_add_incoming (label, + amount, + &auth, + customer_payto); +} static const char * @@ -429,7 +424,6 @@ run (void *cls, TALER_TESTING_cmd_transfer ("create-reserve-2", "EUR:1", - payer_url, &auth, exchange_payto, &wtid, @@ -437,7 +431,6 @@ run (void *cls, TALER_TESTING_cmd_admin_add_incoming_with_ref ("create-reserve-2b", "EUR:4.01", - exchange_account_url, &auth, exchange_payto, "create-reserve-2"), @@ -656,7 +649,6 @@ run (void *cls, TALER_TESTING_cmd_admin_add_incoming_with_instance ("create-reserve-tip-1", "EUR:20.04", - exchange_account_url, &auth, payer_payto, "tip", @@ -738,7 +730,6 @@ run (void *cls, TALER_TESTING_cmd_admin_add_incoming_with_instance ("create-reserve-insufficient-funds", "EUR:1.01", - exchange_account_url, &auth, payer_payto, "dtip", @@ -847,7 +838,6 @@ run (void *cls, TALER_TESTING_cmd_transfer ("create-reserve-10", "EUR:10.02", - payer_url, &auth, exchange_payto, &wtid, @@ -1078,22 +1068,10 @@ main (int argc, &bc)) return 77; - GNUNET_assert - (GNUNET_SYSERR != GNUNET_asprintf (&payer_url, - "%s%s", - USER_ACCOUNT_PATH)); - GNUNET_assert - (GNUNET_SYSERR != GNUNET_asprintf (&exchange_account_url, - "%s%s", - fakebank_url, - EXCHANGE_ACCOUNT_PATH)); - - payer_payto = TALER_payto_xtalerbank_make (fakebank_url, - USER_ACCOUNT_PATH); - exchange_payto = TALER_payto_xtalerbank_make (fakebank_url, - EXCHANGE_ACCOUNT_PATH); - merchant_payto = TALER_payto_xtalerbank_make (fakebank_url, - MERCHANT_ACCOUNT_PATH); + payer_payto = ("payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME); + exchange_payto = ("payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME); + merchant_payto = ("payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME); + if (NULL == (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE))) return 77; diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c index cc436905..47143648 100644 --- a/src/lib/testing_api_cmd_pay.c +++ b/src/lib/testing_api_cmd_pay.c @@ -331,7 +331,7 @@ pay_cb (void *cls, struct GNUNET_CRYPTO_EddsaSignature sig; const char *error_name; unsigned int error_line; - const struct GNUNET_CRYPTO_EddsaPublicKey *merchant_pub; + const struct TALER_MerchantPublicKeyP *merchant_pub; ps->po = NULL; if (ps->http_status != http_status) @@ -375,7 +375,7 @@ pay_cb (void *cls, ps->proposal_reference))); if (GNUNET_OK != - TALER_TESTING_get_trait_peer_key_pub (proposal_cmd, + TALER_TESTING_get_trait_merchant_pub (proposal_cmd, 0, &merchant_pub)) TALER_TESTING_FAIL (ps->is); @@ -384,7 +384,7 @@ pay_cb (void *cls, GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_PAYMENT_OK, &mr.purpose, &sig, - merchant_pub)) + &merchant_pub->eddsa_pub)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Merchant signature given in response to /pay" @@ -491,7 +491,7 @@ _pay_run (const char *merchant_url, const char *amount_with_fee, const char *amount_without_fee, const char *refund_fee, - struct TALER_MERCHANT_Pay * (*api_func)(), + struct TALER_MERCHANT_Pay *(*api_func)(), void (*api_cb)(), void *cls) { @@ -708,7 +708,7 @@ pay_traits (void *cls, struct PayState *ps = cls; const char *order_id; const struct TALER_TESTING_Command *proposal_cmd; - struct GNUNET_CRYPTO_EddsaPublicKey *merchant_pub; + const struct TALER_MerchantPublicKeyP *merchant_pub; if (NULL == (proposal_cmd = TALER_TESTING_interpreter_lookup_command @@ -725,10 +725,9 @@ pay_traits (void *cls, return GNUNET_SYSERR; } - if (GNUNET_OK != TALER_TESTING_get_trait_peer_key_pub + if (GNUNET_OK != TALER_TESTING_get_trait_merchant_pub (proposal_cmd, 0, - (const struct GNUNET_CRYPTO_EddsaPublicKey **) &merchant_pub)) { GNUNET_break (0); @@ -747,7 +746,7 @@ pay_traits (void *cls, TALER_TESTING_make_trait_coin_reference (0, ps->coin_reference), TALER_TESTING_make_trait_order_id (0, order_id), - TALER_TESTING_make_trait_peer_key_pub (0, merchant_pub), + TALER_TESTING_make_trait_merchant_pub (0, merchant_pub), TALER_TESTING_trait_end () }; @@ -914,8 +913,8 @@ pay_abort_traits (void *cls, { struct PayAbortState *pas = cls; struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_peer_key_pub - (0, &pas->merchant_pub.eddsa_pub), + TALER_TESTING_make_trait_merchant_pub + (0, &pas->merchant_pub), TALER_TESTING_make_trait_h_contract_terms (0, &pas->h_contract), TALER_TESTING_make_trait_refund_entry @@ -990,7 +989,7 @@ pay_again_cb (void *cls, const char *error_name; unsigned int error_line; const struct TALER_TESTING_Command *pay_cmd; - const struct GNUNET_CRYPTO_EddsaPublicKey *merchant_pub; + const struct TALER_MerchantPublicKeyP *merchant_pub; pas->pao = NULL; if (pas->http_status != http_status) @@ -1030,7 +1029,7 @@ pay_again_cb (void *cls, (TALER_SIGNATURE_MERCHANT_PAYMENT_OK); mr.purpose.size = htonl (sizeof (mr)); - if (GNUNET_OK != TALER_TESTING_get_trait_peer_key_pub + if (GNUNET_OK != TALER_TESTING_get_trait_merchant_pub (pay_cmd, 0, &merchant_pub)) TALER_TESTING_FAIL (pas->is); @@ -1038,7 +1037,7 @@ pay_again_cb (void *cls, (TALER_SIGNATURE_MERCHANT_PAYMENT_OK, &mr.purpose, &sig, - merchant_pub)) + &merchant_pub->eddsa_pub)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Merchant signature given in" diff --git a/src/lib/testing_api_cmd_pay_abort_refund.c b/src/lib/testing_api_cmd_pay_abort_refund.c index 7f44c01d..42bf00bb 100644 --- a/src/lib/testing_api_cmd_pay_abort_refund.c +++ b/src/lib/testing_api_cmd_pay_abort_refund.c @@ -159,7 +159,7 @@ pay_abort_refund_run (void *cls, const struct TALER_MERCHANT_RefundEntry *refund_entry; const unsigned int *num_refunds; const struct TALER_TESTING_Command *abort_cmd; - const struct GNUNET_CRYPTO_EddsaPublicKey *merchant_pub; + const struct TALER_MerchantPublicKeyP *merchant_pub; const struct GNUNET_HashCode *h_contract_terms; pars->is = is; @@ -181,7 +181,7 @@ pay_abort_refund_run (void *cls, &h_contract_terms)) TALER_TESTING_FAIL (is); if (GNUNET_OK != - TALER_TESTING_get_trait_peer_key_pub (abort_cmd, + TALER_TESTING_get_trait_merchant_pub (abort_cmd, 0, &merchant_pub)) TALER_TESTING_FAIL (is); @@ -203,7 +203,7 @@ pay_abort_refund_run (void *cls, h_contract_terms, &refund_entry->coin_pub, refund_entry->rtransaction_id, - (const struct TALER_MerchantPublicKeyP *) merchant_pub, + merchant_pub, &refund_entry->merchant_sig, &abort_refund_cb, pars); diff --git a/src/lib/testing_api_cmd_proposal.c b/src/lib/testing_api_cmd_proposal.c index 7d51d974..087c1c82 100644 --- a/src/lib/testing_api_cmd_proposal.c +++ b/src/lib/testing_api_cmd_proposal.c @@ -117,7 +117,8 @@ proposal_traits (void *cls, { struct ProposalState *ps = cls; #define MAKE_TRAIT_NONCE(ptr) \ - TALER_TESTING_make_trait_peer_key_pub (1, ptr) + TALER_TESTING_make_trait_merchant_pub (1, (struct \ + TALER_MerchantPublicKeyP *) (ptr)) struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_order_id (0, ps->order_id), @@ -126,8 +127,8 @@ proposal_traits (void *cls, TALER_TESTING_make_trait_h_contract_terms (0, &ps->h_contract_terms), TALER_TESTING_make_trait_merchant_sig (0, &ps->merchant_sig), - TALER_TESTING_make_trait_peer_key_pub - (0, &ps->merchant_pub.eddsa_pub), + TALER_TESTING_make_trait_merchant_pub + (0, &ps->merchant_pub), MAKE_TRAIT_NONCE (&ps->nonce), TALER_TESTING_trait_end () }; diff --git a/src/lib/testing_api_cmd_proposal_lookup.c b/src/lib/testing_api_cmd_proposal_lookup.c index c166e3f8..66c88742 100644 --- a/src/lib/testing_api_cmd_proposal_lookup.c +++ b/src/lib/testing_api_cmd_proposal_lookup.c @@ -187,11 +187,11 @@ proposal_lookup_run (void *cls, { struct ProposalLookupState *pls = cls; const char *order_id; - const struct GNUNET_CRYPTO_EddsaPublicKey *nonce; + const struct TALER_MerchantPublicKeyP *nonce; /* Only used if we do NOT use the nonce from traits. */ - struct GNUNET_CRYPTO_EddsaPublicKey dummy_nonce; + struct TALER_MerchantPublicKeyP dummy_nonce; #define GET_TRAIT_NONCE(cmd,ptr) \ - TALER_TESTING_get_trait_peer_key_pub (cmd, 1, ptr) + TALER_TESTING_get_trait_merchant_pub (cmd, 1, ptr) pls->is = is; @@ -215,7 +215,12 @@ proposal_lookup_run (void *cls, if (GNUNET_OK != GET_TRAIT_NONCE (proposal_cmd, &nonce)) + { + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, + &dummy_nonce, + sizeof (dummy_nonce)); nonce = &dummy_nonce; + } if (GNUNET_OK != TALER_TESTING_get_trait_order_id (proposal_cmd, 0, &order_id)) @@ -224,7 +229,7 @@ proposal_lookup_run (void *cls, pls->plo = TALER_MERCHANT_proposal_lookup (is->ctx, pls->merchant_url, order_id, - nonce, + &nonce->eddsa_pub, &proposal_lookup_cb, pls); GNUNET_assert (NULL != pls->plo); @@ -254,8 +259,8 @@ proposal_lookup_traits (void *cls, &pls->contract_terms_hash), TALER_TESTING_make_trait_merchant_sig (0, &pls->merchant_sig), - TALER_TESTING_make_trait_peer_key_pub (0, - &pls->merchant_pub.eddsa_pub), + TALER_TESTING_make_trait_merchant_pub (0, + &pls->merchant_pub), TALER_TESTING_trait_end () }; diff --git a/src/merchant-tools/taler-merchant-benchmark.c b/src/merchant-tools/taler-merchant-benchmark.c index 887faa16..dc7f933d 100644 --- a/src/merchant-tools/taler-merchant-benchmark.c +++ b/src/merchant-tools/taler-merchant-benchmark.c @@ -55,7 +55,6 @@ enum PaymentGeneratorError /* Hard-coded params. Note, the bank is expected to * have the Tor user with account number 3 and password 'x'. */ -#define PAYER_URL "FIXME/3" #define EXCHANGE_ACCOUNT_NO 2 #define USER_LOGIN_NAME "Tor" #define USER_LOGIN_PASS "x" @@ -174,7 +173,8 @@ static char *currency; static struct TALER_BANK_AuthenticationData auth; static char *exchange_payto; -static struct TALER_WireTransferIdentifierRawP wtid; +static char *customer_payto; +static char *merchant_payto; /** * Convenience macros to allocate all the currency-dependant @@ -183,6 +183,7 @@ static struct TALER_WireTransferIdentifierRawP wtid; * where it is called. */ +// FIXME: This should not be a macro! #define ALLOCATE_AMOUNTS(...) \ char *CURRENCY_10_02; \ char *CURRENCY_10; \ @@ -218,6 +219,9 @@ static struct TALER_WireTransferIdentifierRawP wtid; "%s:0.01", \ currency); +// FIXME: this should not be a macro +// FIXME: the inline JSON is outdated +// FIXME: find a better way to produce the contract terms via a helper function #define ALLOCATE_ORDERS(...) \ char *order_worth_5; \ char *order_worth_5_track; \ @@ -326,13 +330,10 @@ run (void *cls, order_worth_5_unaggregated, order_worth_10_2coins); struct TALER_TESTING_Command ordinary_commands[] = { - TALER_TESTING_cmd_transfer ("create-reserve-1", - CURRENCY_10_02, - PAYER_URL, // bank base URL + path to the payer account. - &auth, - exchange_payto, - &wtid, - EXCHANGE_URL), + TALER_TESTING_cmd_admin_add_incoming ("create-reserve-1", + CURRENCY_10_02, + &auth, + customer_payto), TALER_TESTING_cmd_exec_wirewatch ("wirewatch-1", cfg_filename), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1", @@ -393,14 +394,11 @@ run (void *cls, struct TALER_TESTING_Command corner_commands[] = { - TALER_TESTING_cmd_transfer + TALER_TESTING_cmd_admin_add_incoming ("create-reserve-1", CURRENCY_5_01, - PAYER_URL, &auth, - exchange_payto, - &wtid, - EXCHANGE_URL), + customer_payto), TALER_TESTING_cmd_exec_wirewatch ("wirewatch-1", @@ -433,14 +431,11 @@ run (void *cls, FIRST_INSTRUCTION, &unaggregated_number), - TALER_TESTING_cmd_transfer + TALER_TESTING_cmd_admin_add_incoming ("create-reserve-2", CURRENCY_10_02, - PAYER_URL, &auth, - exchange_payto, - &wtid, - EXCHANGE_URL), + customer_payto), TALER_TESTING_cmd_exec_wirewatch ("wirewatch-2", @@ -766,8 +761,10 @@ main (int argc, /** * FIXME: Need to retrieve the bank base URL! */ - exchange_payto = TALER_payto_xtalerbank_make ("FIXME-BANK-HOSTNAME:PORT", - "/2"); + + exchange_payto = "payto://x-taler-bank/localhost/Exchange"; + merchant_payto = "payto://x-taler-bank/localhost/Merchant"; + customer_payto = "payto://x-taler-bank/localhost/Customer"; result = TALER_TESTING_setup_with_exchange (run, |