diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-10-01 20:25:58 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-10-01 20:25:58 +0200 |
commit | 90d8cb0aa5aacf40cedc0fb17e0db3159c496c97 (patch) | |
tree | 74361ad853f23b852507a04cc5808ea13c25958d /src/testing | |
parent | 737edd5130bcb9ca7159ea54194eba4a5b8fbd90 (diff) |
adapt tests to do kycauth wire transfers that are now needed
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/test_exchange_api.c | 1407 | ||||
-rw-r--r-- | src/testing/test_exchange_api_age_restriction.c | 33 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_batch.c | 21 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_batch_deposit.c | 74 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_deposit.c | 68 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_refresh.c | 6 | ||||
-rw-r--r-- | src/testing/testing_api_loop.c | 43 |
7 files changed, 947 insertions, 705 deletions
diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c index 533995b37..f6c9f1b97 100644 --- a/src/testing/test_exchange_api.c +++ b/src/testing/test_exchange_api.c @@ -179,22 +179,40 @@ run (void *cls, /** * Spend the coin. */ - TALER_TESTING_cmd_deposit ("deposit-simple", - "withdraw-coin-1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-1", - "deposit-simple", - MHD_HTTP_OK), - TALER_TESTING_cmd_sleep ("sleep-before-deposit-replay", - 1), - TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-2", - "deposit-simple", - MHD_HTTP_OK), + TALER_TESTING_cmd_set_var ( + "account-priv", + TALER_TESTING_cmd_deposit ( + "deposit-simple-fail-kyc", + "withdraw-coin-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS)), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer", + "EUR:0.01", + &cred.ba, + cred.user42_payto, + "deposit-simple-fail-kyc"), + CMD_EXEC_WIREWATCH ( + "import-kyc-account-withdraw"), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple", + "deposit-simple-fail-kyc", + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple-replay-1", + "deposit-simple", + MHD_HTTP_OK), + TALER_TESTING_cmd_sleep ( + "sleep-before-deposit-replay", + 1), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple-replay-2", + "deposit-simple", + MHD_HTTP_OK), /* This creates a conflict, as we have the same coin public key (reuse!), but different denomination public keys (which is not allowed). However, note that this does NOT work with 'CS', as for a different @@ -202,52 +220,64 @@ run (void *cls, thus will generate a different coin private key as R0/R1 are hashed into the coin priv. So here, we fail to 'reuse' the key due to the cryptographic construction! */ - TALER_TESTING_cmd_deposit ("deposit-reused-coin-key-failure", - "withdraw-coin-1x", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - uses_cs - ? MHD_HTTP_OK - : MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_deposit ( + "deposit-reused-coin-key-failure", + "withdraw-coin-1x", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + uses_cs + ? MHD_HTTP_OK + : MHD_HTTP_CONFLICT), /** * Try to double spend using different wire details. */ - TALER_TESTING_cmd_deposit ("deposit-double-1", - "withdraw-coin-1", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer-2", + "EUR:0.01", + &cred.ba, + cred.user43_payto, + "deposit-simple-fail-kyc"), + CMD_EXEC_WIREWATCH ( + "import-kyc-account-1"), + TALER_TESTING_cmd_deposit ( + "deposit-double-1", + "withdraw-coin-1", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_CONFLICT), /* Try to double spend using a different transaction id. * The test needs the contract terms to differ. This * is currently the case because of the "timestamp" field, * which is set automatically by #TALER_TESTING_cmd_deposit(). * This could theoretically fail if at some point a deposit - * command executes in less than 1 ms. */// - TALER_TESTING_cmd_deposit ("deposit-double-1", - "withdraw-coin-1", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_CONFLICT), + * command executes in less than 1 ms. */ + TALER_TESTING_cmd_deposit ( + "deposit-double-1", + "withdraw-coin-1", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_CONFLICT), /** * Try to double spend with different proposal. */ - TALER_TESTING_cmd_deposit ("deposit-double-2", - "withdraw-coin-1", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_deposit ( + "deposit-double-2", + "withdraw-coin-1", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_CONFLICT), TALER_TESTING_cmd_end () }; @@ -258,19 +288,22 @@ run (void *cls, * with MHD_HTTP_CONFLICT, but for a different reason: here it * is not a denomination conflict, but a double-spending conflict. */ - TALER_TESTING_cmd_melt ("refresh-melt-reused-coin-key-failure", - "withdraw-coin-1x", - MHD_HTTP_CONFLICT, - NULL), + TALER_TESTING_cmd_melt ( + "refresh-melt-reused-coin-key-failure", + "withdraw-coin-1x", + MHD_HTTP_CONFLICT, + NULL), /* Fill reserve with EUR:5, 1ct is for fees. */ - CMD_TRANSFER_TO_EXCHANGE ("refresh-create-reserve-1", - "EUR:5.01"), - TALER_TESTING_cmd_check_bank_admin_transfer ("ck-refresh-create-reserve-1", - "EUR:5.01", - cred.user42_payto, - cred.exchange_payto, - "refresh-create-reserve-1"), + CMD_TRANSFER_TO_EXCHANGE ( + "refresh-create-reserve-1", + "EUR:5.01"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "ck-refresh-create-reserve-1", + "EUR:5.01", + cred.user42_payto, + cred.exchange_payto, + "refresh-create-reserve-1"), /** * Make previous command effective. */ @@ -278,83 +311,93 @@ run (void *cls, /** * Withdraw EUR:5. */ - TALER_TESTING_cmd_withdraw_amount ("refresh-withdraw-coin-1", - "refresh-create-reserve-1", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "refresh-withdraw-coin-1", + "refresh-create-reserve-1", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), /* Try to partially spend (deposit) 1 EUR of the 5 EUR coin * (in full) (merchant would receive EUR:0.99 due to 1 ct * deposit fee) */ - TALER_TESTING_cmd_deposit ("refresh-deposit-partial", - "refresh-withdraw-coin-1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-partial", + "refresh-withdraw-coin-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), /** * Melt the rest of the coin's value * (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */ - TALER_TESTING_cmd_melt_double ("refresh-melt-1", - "refresh-withdraw-coin-1", - MHD_HTTP_OK, - NULL), + TALER_TESTING_cmd_melt_double ( + "refresh-melt-1", + "refresh-withdraw-coin-1", + MHD_HTTP_OK, + NULL), /** * Complete (successful) melt operation, and * withdraw the coins */ - TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-1", - "refresh-melt-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_reveal ( + "refresh-reveal-1", + "refresh-melt-1", + MHD_HTTP_OK), /** * Do it again to check idempotency */ - TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-1-idempotency", - "refresh-melt-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_reveal ( + "refresh-reveal-1-idempotency", + "refresh-melt-1", + MHD_HTTP_OK), /** * Test that /refresh/link works */ - TALER_TESTING_cmd_refresh_link ("refresh-link-1", - "refresh-reveal-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_link ( + "refresh-link-1", + "refresh-reveal-1", + MHD_HTTP_OK), /** * Try to spend a refreshed EUR:1 coin */ - TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1a", - "refresh-reveal-1-idempotency", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-refreshed-1a", + "refresh-reveal-1-idempotency", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), /** * Try to spend a refreshed EUR:0.1 coin */ - TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b", - "refresh-reveal-1", - 3, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:0.1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-refreshed-1b", + "refresh-reveal-1", + 3, + cred.user43_payto, + "{\"items\":[{\"name\":\"cheap ice cream\",\"value\":3}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:0.1", + MHD_HTTP_OK), /* Test running a failing melt operation (same operation * again must fail) */ - TALER_TESTING_cmd_melt ("refresh-melt-failing", - "refresh-withdraw-coin-1", - MHD_HTTP_CONFLICT, - NULL), + TALER_TESTING_cmd_melt ( + "refresh-melt-failing", + "refresh-withdraw-coin-1", + MHD_HTTP_CONFLICT, + NULL), /* Test running a failing melt operation (on a coin that was itself revealed and subsequently deposited) */ - TALER_TESTING_cmd_melt ("refresh-melt-failing-2", - "refresh-reveal-1", - MHD_HTTP_CONFLICT, - NULL), + TALER_TESTING_cmd_melt ( + "refresh-melt-failing-2", + "refresh-reveal-1", + MHD_HTTP_CONFLICT, + NULL), TALER_TESTING_cmd_end () }; @@ -372,13 +415,15 @@ run (void *cls, /** * Move money to the exchange's bank account. */ - CMD_TRANSFER_TO_EXCHANGE ("create-reserve-age", - "EUR:6.01"), - TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-age", - "EUR:6.01", - cred.user42_payto, - cred.exchange_payto, - "create-reserve-age"), + CMD_TRANSFER_TO_EXCHANGE ( + "create-reserve-age", + "EUR:6.01"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check-create-reserve-age", + "EUR:6.01", + cred.user42_payto, + cred.exchange_payto, + "create-reserve-age"), /** * Make a reserve exist, according to the previous * transfer. @@ -387,11 +432,12 @@ run (void *cls, /** * Withdraw EUR:5. */ - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-age-1", - "create-reserve-age", - "EUR:5", - 13, - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-age-1", + "create-reserve-age", + "EUR:5", + 13, + MHD_HTTP_OK), TALER_TESTING_cmd_end () }; @@ -400,25 +446,30 @@ run (void *cls, /** * Spend the coin. */ - TALER_TESTING_cmd_deposit ("deposit-simple-age", - "withdraw-coin-age-1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:4.99", - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-age", - "deposit-simple-age", - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-age-1", - "deposit-simple-age", - MHD_HTTP_OK), - TALER_TESTING_cmd_sleep ("sleep-before-age-deposit-replay", - 1), - TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-age-2", - "deposit-simple-age", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-simple-age", + "withdraw-coin-age-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"unique ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:4.99", + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple-replay-age", + "deposit-simple-age", + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple-replay-age-1", + "deposit-simple-age", + MHD_HTTP_OK), + TALER_TESTING_cmd_sleep ( + "sleep-before-age-deposit-replay", + 1), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple-replay-age-2", + "deposit-simple-age", + MHD_HTTP_OK), TALER_TESTING_cmd_end () }; @@ -427,102 +478,78 @@ run (void *cls, * execution of transactions, the answer should be that * the exchange knows about the deposit, but has no WTID yet. */ - TALER_TESTING_cmd_deposits_get ("deposit-wtid-found", - "deposit-simple", - 0, - MHD_HTTP_ACCEPTED, - NULL), + TALER_TESTING_cmd_deposits_get ( + "deposit-wtid-found", + "deposit-simple", + 0, + MHD_HTTP_ACCEPTED, + NULL), /* Try resolving a deposit's WTID for a failed deposit. * As the deposit failed, the answer should be that the * exchange does NOT know about the deposit. */ - TALER_TESTING_cmd_deposits_get ("deposit-wtid-failing", - "deposit-double-2", - 0, - MHD_HTTP_NOT_FOUND, - NULL), + TALER_TESTING_cmd_deposits_get ( + "deposit-wtid-failing", + "deposit-double-2", + 0, + MHD_HTTP_NOT_FOUND, + NULL), /* Try resolving an undefined (all zeros) WTID; this * should fail as obviously the exchange didn't use that * WTID value for any transaction. */ - TALER_TESTING_cmd_track_transfer_empty ("wire-deposit-failing", - NULL, - MHD_HTTP_NOT_FOUND), - /* Run transfers. Note that _actual_ aggregation will NOT - * happen here, as each deposit operation is run with a - * fresh merchant public key, so the aggregator will treat - * them as "different" merchants and do the wire transfers - * individually. */ + TALER_TESTING_cmd_track_transfer_empty ( + "wire-deposit-failing", + NULL, + MHD_HTTP_NOT_FOUND), + /* Run transfers. */ CMD_EXEC_AGGREGATOR ("run-aggregator"), /** * Check all the transfers took place. */ - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c", - cred.exchange_url, - "EUR:4.98", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c2", - cred.exchange_url, - "EUR:4.97", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c1", - cred.exchange_url, - "EUR:0.98", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c2", - cred.exchange_url, - "EUR:0.98", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c3", - cred.exchange_url, - "EUR:0.98", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c4", - cred.exchange_url, - "EUR:0.98", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c", - cred.exchange_url, - "EUR:0.08", - cred.exchange_payto, - cred.user43_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c2", - cred.exchange_url, - "EUR:0.08", - cred.exchange_payto, - cred.user43_payto), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_transfer-42-aggregate", + cred.exchange_url, + "EUR:13.92", + cred.exchange_payto, + cred.user42_payto), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_transfer-43-aggregate", + cred.exchange_url, + "EUR:0.17", + cred.exchange_payto, + cred.user43_payto), /* In case of CS, one transaction above succeeded that failed for RSA, hence we need to check for an extra transfer here */ uses_cs - ? TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-98c", - cred.exchange_url, - "EUR:0.98", - cred.exchange_payto, - cred.user42_payto) - : TALER_TESTING_cmd_sleep ("dummy", - 0), + ? TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_transfer-98c", + cred.exchange_url, + "EUR:0.98", + cred.exchange_payto, + cred.user42_payto) + : TALER_TESTING_cmd_sleep ( + "dummy", + 0), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), - TALER_TESTING_cmd_deposits_get ("deposit-wtid-ok", - "deposit-simple", - 0, - MHD_HTTP_OK, - "check_bank_transfer-499c"), - TALER_TESTING_cmd_track_transfer ("wire-deposit-success-bank", - "check_bank_transfer-99c1", - MHD_HTTP_OK, - "EUR:0.98", - "EUR:0.01"), - TALER_TESTING_cmd_track_transfer ("wire-deposits-success-wtid", - "deposit-wtid-ok", - MHD_HTTP_OK, - "EUR:4.98", - "EUR:0.01"), + TALER_TESTING_cmd_deposits_get ( + "deposit-wtid-ok", + "deposit-simple", + 0, + MHD_HTTP_OK, + "check_bank_transfer-42-aggregate"), + TALER_TESTING_cmd_track_transfer ( + "wire-deposit-success-bank", + "check_bank_transfer-42-aggregate", + MHD_HTTP_OK, + "EUR:13.92", + "EUR:0.01"), + TALER_TESTING_cmd_track_transfer ( + "wire-deposits-success-wtid", + "check_bank_transfer-43-aggregate", + MHD_HTTP_OK, + "EUR:0.17", + "EUR:0.01"), TALER_TESTING_cmd_end () }; @@ -532,8 +559,9 @@ run (void *cls, */ struct TALER_TESTING_Command unaggregation[] = { TALER_TESTING_cmd_check_bank_empty ("far-future-aggregation-a"), - CMD_TRANSFER_TO_EXCHANGE ("create-reserve-unaggregated", - "EUR:5.01"), + CMD_TRANSFER_TO_EXCHANGE ( + "create-reserve-unaggregated", + "EUR:5.01"), /* "consume" reserve creation transfer. */ TALER_TESTING_cmd_check_bank_admin_transfer ( "check-create-reserve-unaggregated", @@ -542,21 +570,23 @@ run (void *cls, cred.exchange_payto, "create-reserve-unaggregated"), CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"), - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated", - "create-reserve-unaggregated", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("deposit-unaggregated", - "withdraw-coin-unaggregated", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_relative_multiply ( - GNUNET_TIME_UNIT_YEARS, - 3000), - "EUR:5", - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-unaggregated", + "create-reserve-unaggregated", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-unaggregated", + "withdraw-coin-unaggregated", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"different ice cream\",\"value\":1}]}", + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_YEARS, + 3000), + "EUR:5", + MHD_HTTP_OK), CMD_EXEC_AGGREGATOR ("aggregation-attempt"), TALER_TESTING_cmd_check_bank_empty ( @@ -567,8 +597,9 @@ run (void *cls, struct TALER_TESTING_Command refresh_age[] = { /* Fill reserve with EUR:5, 1ct is for fees. */ - CMD_TRANSFER_TO_EXCHANGE ("refresh-create-reserve-age-1", - "EUR:6.01"), + CMD_TRANSFER_TO_EXCHANGE ( + "refresh-create-reserve-age-1", + "EUR:6.01"), TALER_TESTING_cmd_check_bank_admin_transfer ( "ck-refresh-create-reserve-age-1", "EUR:6.01", @@ -582,83 +613,93 @@ run (void *cls, /** * Withdraw EUR:7 with age restriction for age 13. */ - TALER_TESTING_cmd_withdraw_amount ("refresh-withdraw-coin-age-1", - "refresh-create-reserve-age-1", - "EUR:5", - 13, - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "refresh-withdraw-coin-age-1", + "refresh-create-reserve-age-1", + "EUR:5", + 13, + MHD_HTTP_OK), /* Try to partially spend (deposit) 1 EUR of the 5 EUR coin * (in full) (merchant would receive EUR:0.99 due to 1 ct * deposit fee) */ - TALER_TESTING_cmd_deposit ("refresh-deposit-partial-age", - "refresh-withdraw-coin-age-1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-partial-age", + "refresh-withdraw-coin-age-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"special ice cream\",\"value\":\"EUR:1\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), /** * Melt the rest of the coin's value * (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */ - TALER_TESTING_cmd_melt_double ("refresh-melt-age-1", - "refresh-withdraw-coin-age-1", - MHD_HTTP_OK, - NULL), + TALER_TESTING_cmd_melt_double ( + "refresh-melt-age-1", + "refresh-withdraw-coin-age-1", + MHD_HTTP_OK, + NULL), /** * Complete (successful) melt operation, and * withdraw the coins */ - TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-age-1", - "refresh-melt-age-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_reveal ( + "refresh-reveal-age-1", + "refresh-melt-age-1", + MHD_HTTP_OK), /** * Do it again to check idempotency */ - TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-age-1-idempotency", - "refresh-melt-age-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_reveal ( + "refresh-reveal-age-1-idempotency", + "refresh-melt-age-1", + MHD_HTTP_OK), /** * Test that /refresh/link works */ - TALER_TESTING_cmd_refresh_link ("refresh-link-age-1", - "refresh-reveal-age-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_link ( + "refresh-link-age-1", + "refresh-reveal-age-1", + MHD_HTTP_OK), /** * Try to spend a refreshed EUR:1 coin */ - TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1a", - "refresh-reveal-age-1-idempotency", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-refreshed-age-1a", + "refresh-reveal-age-1-idempotency", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"garlic ice cream\",\"value\":3}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), /** * Try to spend a refreshed EUR:0.1 coin */ - TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1b", - "refresh-reveal-age-1", - 3, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:0.1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-refreshed-age-1b", + "refresh-reveal-age-1", + 3, + cred.user43_payto, + "{\"items\":[{\"name\":\"spicy ice cream\",\"value\":3}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:0.1", + MHD_HTTP_OK), /* Test running a failing melt operation (same operation * again must fail) */ - TALER_TESTING_cmd_melt ("refresh-melt-failing-age", - "refresh-withdraw-coin-age-1", - MHD_HTTP_CONFLICT, - NULL), + TALER_TESTING_cmd_melt ( + "refresh-melt-failing-age", + "refresh-withdraw-coin-age-1", + MHD_HTTP_CONFLICT, + NULL), /* Test running a failing melt operation (on a coin that was itself revealed and subsequently deposited) */ - TALER_TESTING_cmd_melt ("refresh-melt-failing-age-2", - "refresh-reveal-age-1", - MHD_HTTP_CONFLICT, - NULL), + TALER_TESTING_cmd_melt ( + "refresh-melt-failing-age-2", + "refresh-reveal-age-1", + MHD_HTTP_CONFLICT, + NULL), TALER_TESTING_cmd_end () }; @@ -677,34 +718,38 @@ run (void *cls, cred.exchange_payto, "create-reserve-aggtest"), CMD_EXEC_WIREWATCH ("wirewatch-aggtest"), - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-aggtest", - "create-reserve-aggtest", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("deposit-aggtest-1", - "withdraw-coin-aggtest", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:2", - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit_with_ref ("deposit-aggtest-2", - "withdraw-coin-aggtest", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"foo bar\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:2", - MHD_HTTP_OK, - "deposit-aggtest-1"), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-aggtest", + "create-reserve-aggtest", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-aggtest-1", + "withdraw-coin-aggtest", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"cinamon ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:2", + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit_with_ref ( + "deposit-aggtest-2", + "withdraw-coin-aggtest", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"foo bar\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:2", + MHD_HTTP_OK, + "deposit-aggtest-1"), CMD_EXEC_AGGREGATOR ("aggregation-aggtest"), - TALER_TESTING_cmd_check_bank_transfer ("check-bank-transfer-aggtest", - cred.exchange_url, - "EUR:3.97", - cred.exchange_payto, - cred.user43_payto), + TALER_TESTING_cmd_check_bank_transfer ( + "check-bank-transfer-aggtest", + cred.exchange_url, + "EUR:3.97", + cred.exchange_payto, + cred.user43_payto), TALER_TESTING_cmd_check_bank_empty ("check-bank-empty-aggtest"), TALER_TESTING_cmd_end () }; @@ -714,35 +759,39 @@ run (void *cls, * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per * config. */ - CMD_TRANSFER_TO_EXCHANGE ("create-reserve-r1", - "EUR:5.01"), - TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-r1", - "EUR:5.01", - cred.user42_payto, - cred.exchange_payto, - "create-reserve-r1"), + CMD_TRANSFER_TO_EXCHANGE ( + "create-reserve-r1", + "EUR:5.01"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check-create-reserve-r1", + "EUR:5.01", + cred.user42_payto, + cred.exchange_payto, + "create-reserve-r1"), /** * Run wire-watch to trigger the reserve creation. */ CMD_EXEC_WIREWATCH ("wirewatch-3"), /* Withdraw a 5 EUR coin, at fee of 1 ct */ - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-r1", - "create-reserve-r1", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-r1", + "create-reserve-r1", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), /** * Spend 5 EUR of the 5 EUR coin (in full) (merchant would * receive EUR:4.99 due to 1 ct deposit fee) */ - TALER_TESTING_cmd_deposit ("deposit-refund-1", - "withdraw-coin-r1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_MINUTES, - "EUR:5", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-refund-1", + "withdraw-coin-r1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"blue ice cream\",\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_MINUTES, + "EUR:5", + MHD_HTTP_OK), /** * Run transfers. Should do nothing as refund deadline blocks it */ @@ -753,47 +802,53 @@ run (void *cls, * fakebank and the second to actually check there are not * other transfers around. */ TALER_TESTING_cmd_check_bank_empty ("check_bank_transfer-pre-refund"), - TALER_TESTING_cmd_refund_with_id ("refund-ok", - MHD_HTTP_OK, - "EUR:3", - "deposit-refund-1", - 3), - TALER_TESTING_cmd_refund_with_id ("refund-ok-double", - MHD_HTTP_OK, - "EUR:3", - "deposit-refund-1", - 3), + TALER_TESTING_cmd_refund_with_id ( + "refund-ok", + MHD_HTTP_OK, + "EUR:3", + "deposit-refund-1", + 3), + TALER_TESTING_cmd_refund_with_id ( + "refund-ok-double", + MHD_HTTP_OK, + "EUR:3", + "deposit-refund-1", + 3), /* Previous /refund(s) had id == 0. */ - TALER_TESTING_cmd_refund_with_id ("refund-conflicting", - MHD_HTTP_CONFLICT, - "EUR:5", - "deposit-refund-1", - 1), - TALER_TESTING_cmd_deposit ("deposit-refund-insufficient-refund", - "withdraw-coin-r1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:4\"}]}", - GNUNET_TIME_UNIT_MINUTES, - "EUR:4", - MHD_HTTP_CONFLICT), - TALER_TESTING_cmd_refund_with_id ("refund-ok-increase", - MHD_HTTP_OK, - "EUR:2", - "deposit-refund-1", - 2), + TALER_TESTING_cmd_refund_with_id ( + "refund-conflicting", + MHD_HTTP_CONFLICT, + "EUR:5", + "deposit-refund-1", + 1), + TALER_TESTING_cmd_deposit ( + "deposit-refund-insufficient-refund", + "withdraw-coin-r1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"fruit ice cream\",\"value\":\"EUR:4\"}]}", + GNUNET_TIME_UNIT_MINUTES, + "EUR:4", + MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_refund_with_id ( + "refund-ok-increase", + MHD_HTTP_OK, + "EUR:2", + "deposit-refund-1", + 2), /** * Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone * due to refund) (merchant would receive EUR:4.98 due to * 1 ct deposit fee) */ - TALER_TESTING_cmd_deposit ("deposit-refund-2", - "withdraw-coin-r1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"more ice cream\",\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:4.99", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-refund-2", + "withdraw-coin-r1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"more ice cream\",\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:4.99", + MHD_HTTP_OK), /** * Run transfers. This will do the transfer as refund deadline * was 0 @@ -802,52 +857,59 @@ run (void *cls, /** * Check that deposit did run. */ - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pre-refund", - cred.exchange_url, - "EUR:4.97", - cred.exchange_payto, - cred.user42_payto), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_transfer-pre-refund", + cred.exchange_url, + "EUR:4.97", + cred.exchange_payto, + cred.user42_payto), /** * Run failing refund, as past deadline & aggregation. */ - TALER_TESTING_cmd_refund ("refund-fail", - MHD_HTTP_GONE, - "EUR:4.99", - "deposit-refund-2"), + TALER_TESTING_cmd_refund ( + "refund-fail", + MHD_HTTP_GONE, + "EUR:4.99", + "deposit-refund-2"), TALER_TESTING_cmd_check_bank_empty ("check-empty-after-refund"), /** * Test refunded coins are never executed, even past * refund deadline */ - CMD_TRANSFER_TO_EXCHANGE ("create-reserve-rb", - "EUR:5.01"), - TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-rb", - "EUR:5.01", - cred.user42_payto, - cred.exchange_payto, - "create-reserve-rb"), + CMD_TRANSFER_TO_EXCHANGE ( + "create-reserve-rb", + "EUR:5.01"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check-create-reserve-rb", + "EUR:5.01", + cred.user42_payto, + cred.exchange_payto, + "create-reserve-rb"), CMD_EXEC_WIREWATCH ("wirewatch-rb"), - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-rb", - "create-reserve-rb", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("deposit-refund-1b", - "withdraw-coin-rb", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-rb", + "create-reserve-rb", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-refund-1b", + "withdraw-coin-rb", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"purple ice cream\",\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_OK), /** * Trigger refund (before aggregator had a chance to execute * deposit, even though refund deadline was zero). */ - TALER_TESTING_cmd_refund ("refund-ok-fast", - MHD_HTTP_OK, - "EUR:5", - "deposit-refund-1b"), + TALER_TESTING_cmd_refund ( + "refund-ok-fast", + MHD_HTTP_OK, + "EUR:5", + "deposit-refund-1b"), /** * Run transfers. This will do the transfer as refund deadline * was 0, except of course because the refund succeeded, the @@ -864,8 +926,9 @@ run (void *cls, * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per * config. */ - CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-1", - "EUR:15.02"), + CMD_TRANSFER_TO_EXCHANGE ( + "recoup-create-reserve-1", + "EUR:15.02"), TALER_TESTING_cmd_check_bank_admin_transfer ( "recoup-create-reserve-1-check", "EUR:15.02", @@ -877,156 +940,185 @@ run (void *cls, */ CMD_EXEC_WIREWATCH ("wirewatch-4"), /* Withdraw a 5 EUR coin, at fee of 1 ct */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-1", - "recoup-create-reserve-1", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-1", + "recoup-create-reserve-1", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), /* Withdraw a 10 EUR coin, at fee of 1 ct */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-1b", - "recoup-create-reserve-1", - "EUR:10", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-1b", + "recoup-create-reserve-1", + "EUR:10", + 0, /* age restriction off */ + MHD_HTTP_OK), /* melt 10 EUR coin to get 5 EUR refreshed coin */ - TALER_TESTING_cmd_melt ("recoup-melt-coin-1b", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:5", - NULL), - TALER_TESTING_cmd_refresh_reveal ("recoup-reveal-coin-1b", - "recoup-melt-coin-1b", - MHD_HTTP_OK), + TALER_TESTING_cmd_melt ( + "recoup-melt-coin-1b", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:5", + NULL), + TALER_TESTING_cmd_refresh_reveal ( + "recoup-reveal-coin-1b", + "recoup-melt-coin-1b", + MHD_HTTP_OK), /* Revoke both 5 EUR coins */ - TALER_TESTING_cmd_revoke ("revoke-0-EUR:5", - MHD_HTTP_OK, - "recoup-withdraw-coin-1", - config_file), + TALER_TESTING_cmd_revoke ( + "revoke-0-EUR:5", + MHD_HTTP_OK, + "recoup-withdraw-coin-1", + config_file), /* Recoup coin to reserve */ - TALER_TESTING_cmd_recoup ("recoup-1", - MHD_HTTP_OK, - "recoup-withdraw-coin-1", - "EUR:5"), + TALER_TESTING_cmd_recoup ( + "recoup-1", + MHD_HTTP_OK, + "recoup-withdraw-coin-1", + "EUR:5"), /* Check the money is back with the reserve */ - TALER_TESTING_cmd_status ("recoup-reserve-status-1", - "recoup-create-reserve-1", - "EUR:5.0", - MHD_HTTP_OK), + TALER_TESTING_cmd_status ( + "recoup-reserve-status-1", + "recoup-create-reserve-1", + "EUR:5.0", + MHD_HTTP_OK), /* Recoup-refresh coin to 10 EUR coin */ - TALER_TESTING_cmd_recoup_refresh ("recoup-1b", - MHD_HTTP_OK, - "recoup-reveal-coin-1b", - "recoup-melt-coin-1b", - "EUR:5"), + TALER_TESTING_cmd_recoup_refresh ( + "recoup-1b", + MHD_HTTP_OK, + "recoup-reveal-coin-1b", + "recoup-melt-coin-1b", + "EUR:5"), /* melt 10 EUR coin *again* to get 1 EUR refreshed coin */ - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1a", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_refresh_reveal ("recoup-reveal-coin-1a", - "recoup-remelt-coin-1a", - MHD_HTTP_OK), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1a", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_refresh_reveal ( + "recoup-reveal-coin-1a", + "recoup-remelt-coin-1a", + MHD_HTTP_OK), /* Try melting for more than the residual value to provoke an error */ - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1b", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1c", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1d", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1e", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1f", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1g", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1h", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1i", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1b-failing", - "recoup-withdraw-coin-1b", - MHD_HTTP_CONFLICT, - "EUR:1", - NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1b", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1c", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1d", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1e", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1f", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1g", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1h", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1i", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1b-failing", + "recoup-withdraw-coin-1b", + MHD_HTTP_CONFLICT, + "EUR:1", + NULL), /* Re-withdraw from this reserve */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2", - "recoup-create-reserve-1", - "EUR:1", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-2", + "recoup-create-reserve-1", + "EUR:1", + 0, /* age restriction off */ + MHD_HTTP_OK), /** * This withdrawal will test the logic to create a "recoup" * element to insert into the reserve's history. */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2-over", - "recoup-create-reserve-1", - "EUR:10", - 0, /* age restriction off */ - MHD_HTTP_CONFLICT), - TALER_TESTING_cmd_status ("recoup-reserve-status-2", - "recoup-create-reserve-1", - "EUR:3.99", - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-2-over", + "recoup-create-reserve-1", + "EUR:10", + 0, /* age restriction off */ + MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_status ( + "recoup-reserve-status-2", + "recoup-create-reserve-1", + "EUR:3.99", + MHD_HTTP_OK), /* These commands should close the reserve because * the aggregator is given a config file that overrides * the reserve expiration time (making it now-ish) */ CMD_TRANSFER_TO_EXCHANGE ("short-lived-reserve", "EUR:5.01"), - TALER_TESTING_cmd_check_bank_admin_transfer ("check-short-lived-reserve", - "EUR:5.01", - cred.user42_payto, - cred.exchange_payto, - "short-lived-reserve"), - TALER_TESTING_cmd_exec_wirewatch2 ("short-lived-aggregation", - config_file_expire_reserve_now, - "exchange-account-2"), - TALER_TESTING_cmd_exec_closer ("close-reserves", - config_file_expire_reserve_now, - "EUR:5", - "EUR:0.01", - "short-lived-reserve"), - TALER_TESTING_cmd_exec_transfer ("close-reserves-transfer", - config_file_expire_reserve_now), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check-short-lived-reserve", + "EUR:5.01", + cred.user42_payto, + cred.exchange_payto, + "short-lived-reserve"), + TALER_TESTING_cmd_exec_wirewatch2 ( + "short-lived-aggregation", + config_file_expire_reserve_now, + "exchange-account-2"), + TALER_TESTING_cmd_exec_closer ( + "close-reserves", + config_file_expire_reserve_now, + "EUR:5", + "EUR:0.01", + "short-lived-reserve"), + TALER_TESTING_cmd_exec_transfer ( + "close-reserves-transfer", + config_file_expire_reserve_now), - TALER_TESTING_cmd_status ("short-lived-status", - "short-lived-reserve", - "EUR:0", - MHD_HTTP_OK), - TALER_TESTING_cmd_withdraw_amount ("expired-withdraw", - "short-lived-reserve", - "EUR:1", - 0, /* age restriction off */ - MHD_HTTP_CONFLICT), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_short-lived_reimburse", - cred.exchange_url, - "EUR:5", - cred.exchange_payto, - cred.user42_payto), + TALER_TESTING_cmd_status ( + "short-lived-status", + "short-lived-reserve", + "EUR:0", + MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "expired-withdraw", + "short-lived-reserve", + "EUR:1", + 0, /* age restriction off */ + MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_short-lived_reimburse", + cred.exchange_url, + "EUR:5", + cred.exchange_payto, + cred.user42_payto), /* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per * config, then withdraw two coin, partially spend one, and * then have the rest paid back. Check deposit of other coin @@ -1034,76 +1126,87 @@ run (void *cls, * revoked and we did not bother to create a new one... */ CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-2", "EUR:2.02"), - TALER_TESTING_cmd_check_bank_admin_transfer ("ck-recoup-create-reserve-2", - "EUR:2.02", - cred.user42_payto, - cred.exchange_payto, - "recoup-create-reserve-2"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "ck-recoup-create-reserve-2", + "EUR:2.02", + cred.user42_payto, + cred.exchange_payto, + "recoup-create-reserve-2"), /* Make previous command effective. */ CMD_EXEC_WIREWATCH ("wirewatch-5"), /* Withdraw a 1 EUR coin, at fee of 1 ct */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2a", - "recoup-create-reserve-2", - "EUR:1", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-2a", + "recoup-create-reserve-2", + "EUR:1", + 0, /* age restriction off */ + MHD_HTTP_OK), /* Withdraw a 1 EUR coin, at fee of 1 ct */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2b", - "recoup-create-reserve-2", - "EUR:1", - 0, /* age restriction off */ - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("recoup-deposit-partial", - "recoup-withdraw-coin-2a", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:0.5", - MHD_HTTP_OK), - TALER_TESTING_cmd_revoke ("revoke-1-EUR:1", - MHD_HTTP_OK, - "recoup-withdraw-coin-2a", - config_file), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-2b", + "recoup-create-reserve-2", + "EUR:1", + 0, /* age restriction off */ + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "recoup-deposit-partial", + "recoup-withdraw-coin-2a", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:0.5", + MHD_HTTP_OK), + TALER_TESTING_cmd_revoke ( + "revoke-1-EUR:1", + MHD_HTTP_OK, + "recoup-withdraw-coin-2a", + config_file), /* Check recoup is failing for the coin with the reused coin key (fails either because of denomination conflict (RSA) or double-spending (CS))*/ - TALER_TESTING_cmd_recoup ("recoup-2x", - MHD_HTTP_CONFLICT, - "withdraw-coin-1x", - "EUR:1"), - TALER_TESTING_cmd_recoup ("recoup-2", - MHD_HTTP_OK, - "recoup-withdraw-coin-2a", - "EUR:0.5"), + TALER_TESTING_cmd_recoup ( + "recoup-2x", + MHD_HTTP_CONFLICT, + "withdraw-coin-1x", + "EUR:1"), + TALER_TESTING_cmd_recoup ( + "recoup-2", + MHD_HTTP_OK, + "recoup-withdraw-coin-2a", + "EUR:0.5"), /* Idempotency of recoup (withdrawal variant) */ - TALER_TESTING_cmd_recoup ("recoup-2b", - MHD_HTTP_OK, - "recoup-withdraw-coin-2a", - "EUR:0.5"), - TALER_TESTING_cmd_deposit ("recoup-deposit-revoked", - "recoup-withdraw-coin-2b", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_GONE), + TALER_TESTING_cmd_recoup ( + "recoup-2b", + MHD_HTTP_OK, + "recoup-withdraw-coin-2a", + "EUR:0.5"), + TALER_TESTING_cmd_deposit ( + "recoup-deposit-revoked", + "recoup-withdraw-coin-2b", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"gnu ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_GONE), /* Test deposit fails after recoup, with proof in recoup */ /* Note that, the exchange will never return the coin's transaction * history with recoup data, as we get a 410 on the DK! */ - TALER_TESTING_cmd_deposit ("recoup-deposit-partial-after-recoup", - "recoup-withdraw-coin-2a", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:0.5", - MHD_HTTP_GONE), + TALER_TESTING_cmd_deposit ( + "recoup-deposit-partial-after-recoup", + "recoup-withdraw-coin-2a", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:0.5", + MHD_HTTP_GONE), /* Test that revoked coins cannot be withdrawn */ - CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-3", - "EUR:1.01"), + CMD_TRANSFER_TO_EXCHANGE ( + "recoup-create-reserve-3", + "EUR:1.01"), TALER_TESTING_cmd_check_bank_admin_transfer ( "check-recoup-create-reserve-3", "EUR:1.01", @@ -1111,11 +1214,12 @@ run (void *cls, cred.exchange_payto, "recoup-create-reserve-3"), CMD_EXEC_WIREWATCH ("wirewatch-6"), - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-3-revoked", - "recoup-create-reserve-3", - "EUR:1", - 0, /* age restriction off */ - MHD_HTTP_GONE), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-3-revoked", + "recoup-create-reserve-3", + "EUR:1", + 0, /* age restriction off */ + MHD_HTTP_GONE), /* check that we are empty before the rejection test */ TALER_TESTING_cmd_check_bank_empty ("check-empty-again"), @@ -1129,64 +1233,73 @@ run (void *cls, /** * Move money to the exchange's bank account. */ - CMD_TRANSFER_TO_EXCHANGE ("create-batch-reserve-1", - "EUR:6.03"), - TALER_TESTING_cmd_reserve_poll ("poll-batch-reserve-1", - "create-batch-reserve-1", - "EUR:6.03", - GNUNET_TIME_UNIT_MINUTES, - MHD_HTTP_OK), - TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-batch-reserve-1", - "EUR:6.03", - cred.user42_payto, - cred.exchange_payto, - "create-batch-reserve-1"), + CMD_TRANSFER_TO_EXCHANGE ( + "create-batch-reserve-1", + "EUR:6.03"), + TALER_TESTING_cmd_reserve_poll ( + "poll-batch-reserve-1", + "create-batch-reserve-1", + "EUR:6.03", + GNUNET_TIME_UNIT_MINUTES, + MHD_HTTP_OK), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check-create-batch-reserve-1", + "EUR:6.03", + cred.user42_payto, + cred.exchange_payto, + "create-batch-reserve-1"), /* * Make a reserve exist, according to the previous * transfer. */ CMD_EXEC_WIREWATCH ("wirewatch-batch-1"), - TALER_TESTING_cmd_reserve_poll_finish ("finish-poll-batch-reserve-1", - GNUNET_TIME_UNIT_SECONDS, - "poll-batch-reserve-1"), + TALER_TESTING_cmd_reserve_poll_finish ( + "finish-poll-batch-reserve-1", + GNUNET_TIME_UNIT_SECONDS, + "poll-batch-reserve-1"), /** * Withdraw EUR:5 AND EUR:1. */ - TALER_TESTING_cmd_batch_withdraw ("batch-withdraw-coin-1", - "create-batch-reserve-1", - 0, /* age restriction off */ - MHD_HTTP_OK, - "EUR:5", - "EUR:1", - NULL), + TALER_TESTING_cmd_batch_withdraw ( + "batch-withdraw-coin-1", + "create-batch-reserve-1", + 0, /* age restriction off */ + MHD_HTTP_OK, + "EUR:5", + "EUR:1", + NULL), /** * Check the reserve is (almost) depleted. */ - TALER_TESTING_cmd_status ("status-batch-1", - "create-batch-reserve-1", - "EUR:0.01", - MHD_HTTP_OK), - TALER_TESTING_cmd_reserve_history ("history-batch-1", - "create-batch-reserve-1", - "EUR:0.01", - MHD_HTTP_OK), + TALER_TESTING_cmd_status ( + "status-batch-1", + "create-batch-reserve-1", + "EUR:0.01", + MHD_HTTP_OK), + TALER_TESTING_cmd_reserve_history ( + "history-batch-1", + "create-batch-reserve-1", + "EUR:0.01", + MHD_HTTP_OK), /** * Spend the coins. */ - TALER_TESTING_cmd_batch_deposit ("batch-deposit-1", - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":5}]}", - GNUNET_TIME_UNIT_ZERO, - MHD_HTTP_OK, - "batch-withdraw-coin-1#0", - "EUR:5", - "batch-withdraw-coin-1#1", - "EUR:1", - NULL), - TALER_TESTING_cmd_coin_history ("coin-history-batch-1", - "batch-withdraw-coin-1#0", - "EUR:0.0", - MHD_HTTP_OK), + TALER_TESTING_cmd_batch_deposit ( + "batch-deposit-1", + cred.user42_payto, + "{\"items\":[{\"name\":\"final ice cream\",\"value\":5}]}", + GNUNET_TIME_UNIT_ZERO, + MHD_HTTP_OK, + "batch-withdraw-coin-1#0", + "EUR:5", + "batch-withdraw-coin-1#1", + "EUR:1", + NULL), + TALER_TESTING_cmd_coin_history ( + "coin-history-batch-1", + "batch-withdraw-coin-1#0", + "EUR:0.0", + MHD_HTTP_OK), TALER_TESTING_cmd_end () }; diff --git a/src/testing/test_exchange_api_age_restriction.c b/src/testing/test_exchange_api_age_restriction.c index 38e536d52..75c3a41f8 100644 --- a/src/testing/test_exchange_api_age_restriction.c +++ b/src/testing/test_exchange_api_age_restriction.c @@ -144,12 +144,37 @@ run (void *cls, /** * Spend the coin. */ + TALER_TESTING_cmd_set_var ( + "account-priv", + TALER_TESTING_cmd_deposit ( + "deposit-simple-age-fail-kyc", + "withdraw-coin-age-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:4.99", + MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS)), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer", + "EUR:0.01", + &cred.ba, + cred.user42_payto, + "deposit-simple-age-fail-kyc"), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer", + "EUR:0.01", + &cred.ba, + cred.user43_payto, + "deposit-simple-age-fail-kyc"), + CMD_EXEC_WIREWATCH ( + "import-kyc-account-withdraw"), TALER_TESTING_cmd_deposit ( "deposit-simple-age", "withdraw-coin-age-1", 0, cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + "{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}", GNUNET_TIME_UNIT_ZERO, "EUR:4.99", MHD_HTTP_OK), @@ -194,7 +219,7 @@ run (void *cls, "refresh-withdraw-coin-age-1", 0, cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", + "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:3\"}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), @@ -236,7 +261,7 @@ run (void *cls, "refresh-reveal-age-1-idempotency", 0, cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", + "{\"items\":[{\"name\":\"ice cream\",\"value\":4}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), @@ -248,7 +273,7 @@ run (void *cls, "refresh-reveal-age-1", 3, cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", + "{\"items\":[{\"name\":\"ice cream\",\"value\":5}]}", GNUNET_TIME_UNIT_ZERO, "EUR:0.1", MHD_HTTP_OK), diff --git a/src/testing/testing_api_cmd_batch.c b/src/testing/testing_api_cmd_batch.c index 5bb7b974e..395d92563 100644 --- a/src/testing/testing_api_cmd_batch.c +++ b/src/testing/testing_api_cmd_batch.c @@ -62,27 +62,30 @@ batch_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct BatchState *bs = cls; + struct TALER_TESTING_Command *bcmd = &bs->batch[bs->batch_ip]; bs->cmd = cmd; - if (NULL != bs->batch[bs->batch_ip].label) + if (NULL != bcmd->label) TALER_LOG_INFO ("Running batched command: %s\n", - bs->batch[bs->batch_ip].label); + bcmd->label); /* hit end command, leap to next top-level command. */ - if (NULL == bs->batch[bs->batch_ip].label) + if (NULL == bcmd->label) { TALER_LOG_INFO ("Exiting from batch: %s\n", cmd->label); TALER_TESTING_interpreter_next (is); return; } - bs->batch[bs->batch_ip].start_time - = bs->batch[bs->batch_ip].last_req_time + bcmd->start_time + = bcmd->last_req_time = GNUNET_TIME_absolute_get (); - bs->batch[bs->batch_ip].num_tries = 1; - bs->batch[bs->batch_ip].run (bs->batch[bs->batch_ip].cls, - &bs->batch[bs->batch_ip], - is); + bcmd->num_tries++; + TALER_TESTING_update_variables_ (is, + bcmd); + bcmd->run (bcmd->cls, + bcmd, + is); } diff --git a/src/testing/testing_api_cmd_batch_deposit.c b/src/testing/testing_api_cmd_batch_deposit.c index 27a2a1165..199404e1c 100644 --- a/src/testing/testing_api_cmd_batch_deposit.c +++ b/src/testing/testing_api_cmd_batch_deposit.c @@ -133,7 +133,13 @@ struct BatchDepositState * Set (by the interpreter) to a fresh private key. This * key will be used to sign the deposit request. */ - struct TALER_MerchantPrivateKeyP merchant_priv; + union TALER_AccountPrivateKeyP account_priv; + + /** + * Set (by the interpreter) to the public key + * corresponding to @e account_priv. + */ + union TALER_AccountPublicKeyP account_pub; /** * Deposit handle while operation is running. @@ -264,7 +270,6 @@ batch_deposit_run (void *cls, { struct BatchDepositState *ds = cls; const struct TALER_DenominationSignature *denom_pub_sig; - struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_PrivateContractHashP h_contract_terms; enum TALER_ErrorCode ec; struct TALER_WireSaltP wire_salt; @@ -304,6 +309,13 @@ batch_deposit_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } +#if DUMP_CONTRACT + fprintf (stderr, + "Using contract:\n"); + json_dumpf (ds->contract_terms, + stderr, + JSON_INDENT (2)); +#endif if (GNUNET_OK != TALER_JSON_contract_hash (ds->contract_terms, &h_contract_terms)) @@ -332,9 +344,38 @@ batch_deposit_run (void *cls, ds->refund_deadline = ds->wallet_timestamp; ds->wire_deadline = GNUNET_TIME_timestamp_get (); } - GNUNET_CRYPTO_eddsa_key_get_public (&ds->merchant_priv.eddsa_priv, - &merchant_pub.eddsa_pub); + { + const struct TALER_TESTING_Command *acc_var; + if (NULL != (acc_var + = TALER_TESTING_interpreter_get_command ( + is, + "account-priv"))) + { + const union TALER_AccountPrivateKeyP *account_priv; + + if ( (GNUNET_OK != + TALER_TESTING_get_trait_account_priv (acc_var, + &account_priv)) ) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + ds->account_priv = *account_priv; + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->account_priv.merchant_priv.eddsa_priv, + &ds->account_pub.merchant_pub.eddsa_pub); + } + else + { + GNUNET_CRYPTO_eddsa_key_create ( + &ds->account_priv.merchant_priv.eddsa_priv); + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->account_priv.merchant_priv.eddsa_priv, + &ds->account_pub.merchant_pub.eddsa_pub); + } + } for (unsigned int i = 0; i<ds->num_coins; i++) { struct Coin *coin = &ds->coins[i]; @@ -395,7 +436,7 @@ batch_deposit_run (void *cls, NULL, /* hash of extensions */ &coin->denom_pub->h_key, ds->wallet_timestamp, - &merchant_pub, + &ds->account_pub.merchant_pub, ds->refund_deadline, coin_priv, &cdd->coin_sig); @@ -407,7 +448,7 @@ batch_deposit_run (void *cls, coin->che.details.deposit.no_h_policy = true; coin->che.details.deposit.no_wallet_data_hash = true; coin->che.details.deposit.wallet_timestamp = ds->wallet_timestamp; - coin->che.details.deposit.merchant_pub = merchant_pub; + coin->che.details.deposit.merchant_pub = ds->account_pub.merchant_pub; coin->che.details.deposit.refund_deadline = ds->refund_deadline; coin->che.details.deposit.sig = cdd->coin_sig; coin->che.details.deposit.no_hac = GNUNET_is_zero (&cdd->h_age_commitment); @@ -424,7 +465,7 @@ batch_deposit_run (void *cls, .h_contract_terms = h_contract_terms, .policy_details = NULL /* FIXME #7270-OEC */, .wallet_timestamp = ds->wallet_timestamp, - .merchant_pub = merchant_pub, + .merchant_pub = ds->account_pub.merchant_pub, .refund_deadline = ds->refund_deadline }; @@ -546,7 +587,10 @@ batch_deposit_traits (void *cls, /* These traits are always available */ TALER_TESTING_make_trait_wire_details (ds->wire_details), TALER_TESTING_make_trait_contract_terms (ds->contract_terms), - TALER_TESTING_make_trait_merchant_priv (&ds->merchant_priv), + TALER_TESTING_make_trait_merchant_priv (&ds->account_priv.merchant_priv), + TALER_TESTING_make_trait_merchant_pub (&ds->account_pub.merchant_pub), + TALER_TESTING_make_trait_account_priv (&ds->account_priv), + TALER_TESTING_make_trait_account_pub (&ds->account_pub), TALER_TESTING_make_trait_age_commitment_proof (index, age_commitment_proof), TALER_TESTING_make_trait_coin_history (index, @@ -585,12 +629,13 @@ batch_deposit_traits (void *cls, struct TALER_TESTING_Command -TALER_TESTING_cmd_batch_deposit (const char *label, - const char *target_account_payto, - const char *contract_terms, - struct GNUNET_TIME_Relative refund_deadline, - unsigned int expected_response_code, - ...) +TALER_TESTING_cmd_batch_deposit ( + const char *label, + const char *target_account_payto, + const char *contract_terms, + struct GNUNET_TIME_Relative refund_deadline, + unsigned int expected_response_code, + ...) { struct BatchDepositState *ds; va_list ap; @@ -637,7 +682,6 @@ TALER_TESTING_cmd_batch_deposit (const char *label, ds->contract_terms = json_loads (contract_terms, JSON_REJECT_DUPLICATES, NULL); - GNUNET_CRYPTO_eddsa_key_create (&ds->merchant_priv.eddsa_priv); if (NULL == ds->contract_terms) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c index 2467488ea..f45fce133 100644 --- a/src/testing/testing_api_cmd_deposit.c +++ b/src/testing/testing_api_cmd_deposit.c @@ -98,7 +98,13 @@ struct DepositState * Set (by the interpreter) to a fresh private key. This * key will be used to sign the deposit request. */ - struct TALER_MerchantPrivateKeyP merchant_priv; + union TALER_AccountPrivateKeyP account_priv; + + /** + * Set (by the interpreter) to the public key + * corresponding to @e account_priv. + */ + union TALER_AccountPublicKeyP account_pub; /** * Deposit handle while operation is running. @@ -297,11 +303,11 @@ deposit_run (void *cls, { struct DepositState *ds = cls; const struct TALER_TESTING_Command *coin_cmd; + const struct TALER_TESTING_Command *acc_var; const struct TALER_CoinSpendPrivateKeyP *coin_priv; struct TALER_CoinSpendPublicKeyP coin_pub; const struct TALER_AgeCommitmentHash *phac; const struct TALER_DenominationSignature *denom_pub_sig; - struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_PrivateContractHashP h_contract_terms; enum TALER_ErrorCode ec; struct TALER_WireSaltP wire_salt; @@ -363,7 +369,8 @@ deposit_run (void *cls, ds->refund_deadline = ods->refund_deadline; ds->wire_deadline = ods->wire_deadline; ds->amount = ods->amount; - ds->merchant_priv = ods->merchant_priv; + ds->account_priv = ods->account_priv; + ds->account_pub = ods->account_pub; ds->command_initialized = true; } else if (NULL != ds->merchant_priv_reference) @@ -389,7 +396,38 @@ deposit_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - ds->merchant_priv = *merchant_priv; + ds->account_priv.merchant_priv = *merchant_priv; + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->account_priv.merchant_priv.eddsa_priv, + &ds->account_pub.merchant_pub.eddsa_pub); + } + else if (NULL != (acc_var + = TALER_TESTING_interpreter_get_command ( + is, + "account-priv"))) + { + const union TALER_AccountPrivateKeyP *account_priv; + + if ( (GNUNET_OK != + TALER_TESTING_get_trait_account_priv (acc_var, + &account_priv)) ) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + ds->account_priv = *account_priv; + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->account_priv.merchant_priv.eddsa_priv, + &ds->account_pub.merchant_pub.eddsa_pub); + } + else + { + GNUNET_CRYPTO_eddsa_key_create ( + &ds->account_priv.merchant_priv.eddsa_priv); + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->account_priv.merchant_priv.eddsa_priv, + &ds->account_pub.merchant_pub.eddsa_pub); } GNUNET_assert (NULL != ds->wire_details); if (GNUNET_OK != @@ -413,7 +451,13 @@ deposit_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - +#if DUMP_CONTRACT + fprintf (stderr, + "Using contract:\n"); + json_dumpf (ds->contract_terms, + stderr, + JSON_INDENT (2)); +#endif if ( (GNUNET_OK != TALER_TESTING_get_trait_coin_priv (coin_cmd, ds->coin_index, @@ -443,8 +487,6 @@ deposit_run (void *cls, GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, &coin_pub.eddsa_pub); - GNUNET_CRYPTO_eddsa_key_get_public (&ds->merchant_priv.eddsa_priv, - &merchant_pub.eddsa_pub); { struct TALER_MerchantWireHashP h_wire; @@ -460,7 +502,7 @@ deposit_run (void *cls, NULL, /* hash of extensions */ &ds->denom_pub->h_key, ds->wallet_timestamp, - &merchant_pub, + &ds->account_pub.merchant_pub, ds->refund_deadline, coin_priv, &ds->coin_sig); @@ -471,7 +513,7 @@ deposit_run (void *cls, ds->che.details.deposit.no_h_policy = true; ds->che.details.deposit.no_wallet_data_hash = true; ds->che.details.deposit.wallet_timestamp = ds->wallet_timestamp; - ds->che.details.deposit.merchant_pub = merchant_pub; + ds->che.details.deposit.merchant_pub = ds->account_pub.merchant_pub; ds->che.details.deposit.refund_deadline = ds->refund_deadline; ds->che.details.deposit.sig = ds->coin_sig; ds->che.details.deposit.no_hac = true; @@ -493,7 +535,7 @@ deposit_run (void *cls, .wire_salt = wire_salt, .h_contract_terms = h_contract_terms, .wallet_timestamp = ds->wallet_timestamp, - .merchant_pub = merchant_pub, + .merchant_pub = ds->account_pub.merchant_pub, .refund_deadline = ds->refund_deadline }; @@ -639,7 +681,10 @@ deposit_traits (void *cls, h_age_commitment), TALER_TESTING_make_trait_wire_details (ds->wire_details), TALER_TESTING_make_trait_contract_terms (ds->contract_terms), - TALER_TESTING_make_trait_merchant_priv (&ds->merchant_priv), + TALER_TESTING_make_trait_merchant_priv (&ds->account_priv.merchant_priv), + TALER_TESTING_make_trait_merchant_pub (&ds->account_pub.merchant_pub), + TALER_TESTING_make_trait_account_priv (&ds->account_priv), + TALER_TESTING_make_trait_account_pub (&ds->account_pub), TALER_TESTING_make_trait_deposit_amount (0, &ds->amount), TALER_TESTING_make_trait_deposit_fee_amount (0, @@ -684,7 +729,6 @@ TALER_TESTING_cmd_deposit ( ds->contract_terms = json_loads (contract_terms, JSON_REJECT_DUPLICATES, NULL); - GNUNET_CRYPTO_eddsa_key_create (&ds->merchant_priv.eddsa_priv); if (NULL == ds->contract_terms) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/testing/testing_api_cmd_refresh.c b/src/testing/testing_api_cmd_refresh.c index 9d58422c7..5c45e3a33 100644 --- a/src/testing/testing_api_cmd_refresh.c +++ b/src/testing/testing_api_cmd_refresh.c @@ -1021,12 +1021,12 @@ melt_run (void *cls, const struct TALER_TESTING_Command *cmd, struct TALER_TESTING_Interpreter *is) { - struct RefreshMeltState *rms = cls; - unsigned int num_fresh_coins; - const char *default_melt_fresh_amounts[] = { + static const char *default_melt_fresh_amounts[] = { "EUR:1", "EUR:1", "EUR:1", "EUR:0.1", NULL }; + struct RefreshMeltState *rms = cls; + unsigned int num_fresh_coins; const char **melt_fresh_amounts; rms->cmd = cmd; diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index 00126b3e7..89c966f26 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c @@ -156,7 +156,7 @@ TALER_TESTING_interpreter_get_command (struct TALER_TESTING_Interpreter *is, cmd = GNUNET_CONTAINER_multihashmap_get (is->vars, &h_name); if (NULL == cmd) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Command not found by name: %s\n", name); return cmd; @@ -264,6 +264,30 @@ TALER_TESTING_interpreter_get_current_label ( } +void +TALER_TESTING_update_variables_ ( + struct TALER_TESTING_Interpreter *is, + struct TALER_TESTING_Command *cmd) +{ + struct GNUNET_HashCode h_name; + + if (NULL == cmd->name) + return; + GNUNET_CRYPTO_hash (cmd->name, + strlen (cmd->name), + &h_name); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Storing command %s under variable `%s'\n", + cmd->label, + cmd->name); + (void) GNUNET_CONTAINER_multihashmap_put ( + is->vars, + &h_name, + cmd, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); +} + + static void interpreter_run (void *cls) { @@ -288,20 +312,9 @@ interpreter_run (void *cls) = GNUNET_TIME_absolute_get (); if (0 == cmd->num_tries) cmd->start_time = cmd->last_req_time; - cmd->num_tries = 1; - if (NULL != cmd->name) - { - struct GNUNET_HashCode h_name; - - GNUNET_CRYPTO_hash (cmd->name, - strlen (cmd->name), - &h_name); - (void) GNUNET_CONTAINER_multihashmap_put ( - is->vars, - &h_name, - cmd, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); - } + cmd->num_tries++; + TALER_TESTING_update_variables_ (is, + cmd); cmd->run (cmd->cls, cmd, is); |