diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-05-30 17:51:39 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-05-30 17:51:39 +0200 |
commit | ab4aa4dcfd3477971b3fb0c81a4caffff953c145 (patch) | |
tree | 2b6ce37666cdf30323cf9c108dd6f04349c8a9d0 /src | |
parent | 7b25787a4b8ac0a0b3cbc2174ba3cac9c564346a (diff) |
-add batch withdraw to test suite
Diffstat (limited to 'src')
-rw-r--r-- | src/json/json_helper.c | 11 | ||||
-rw-r--r-- | src/lib/exchange_api_batch_withdraw.c | 3 | ||||
-rw-r--r-- | src/lib/exchange_api_batch_withdraw2.c | 2 | ||||
-rw-r--r-- | src/testing/test_exchange_api.c | 71 |
4 files changed, 82 insertions, 5 deletions
diff --git a/src/json/json_helper.c b/src/json/json_helper.c index 4896fb598..50d4705d5 100644 --- a/src/json/json_helper.c +++ b/src/json/json_helper.c @@ -347,6 +347,7 @@ TALER_JSON_spec_denom_pub (const char *field, .ptr = pk }; + pk->cipher = TALER_DENOMINATION_INVALID; return ret; } @@ -463,6 +464,7 @@ TALER_JSON_spec_denom_sig (const char *field, .ptr = sig }; + sig->cipher = TALER_DENOMINATION_INVALID; return ret; } @@ -582,6 +584,7 @@ TALER_JSON_spec_blinded_denom_sig ( .ptr = sig }; + sig->cipher = TALER_DENOMINATION_INVALID; return ret; } @@ -705,6 +708,7 @@ TALER_JSON_spec_blinded_planchet (const char *field, .ptr = blinded_planchet }; + blinded_planchet->cipher = TALER_DENOMINATION_INVALID; return ret; } @@ -780,9 +784,9 @@ parse_exchange_withdraw_values (void *cls, struct GNUNET_JSON_Specification -TALER_JSON_spec_exchange_withdraw_values (const char *field, - struct TALER_ExchangeWithdrawValues * - ewv) +TALER_JSON_spec_exchange_withdraw_values ( + const char *field, + struct TALER_ExchangeWithdrawValues *ewv) { struct GNUNET_JSON_Specification ret = { .parser = &parse_exchange_withdraw_values, @@ -790,6 +794,7 @@ TALER_JSON_spec_exchange_withdraw_values (const char *field, .ptr = ewv }; + ewv->cipher = TALER_DENOMINATION_INVALID; return ret; } diff --git a/src/lib/exchange_api_batch_withdraw.c b/src/lib/exchange_api_batch_withdraw.c index ce5de3fc2..295695d8f 100644 --- a/src/lib/exchange_api_batch_withdraw.c +++ b/src/lib/exchange_api_batch_withdraw.c @@ -161,6 +161,9 @@ handle_reserve_batch_withdraw_finished ( struct TALER_EXCHANGE_PrivateCoinDetails coins[wh->num_coins]; wh->wh2 = NULL; + memset (coins, + 0, + sizeof (coins)); if (blind_sigs_length != wh->num_coins) { GNUNET_break_op (0); diff --git a/src/lib/exchange_api_batch_withdraw2.c b/src/lib/exchange_api_batch_withdraw2.c index 314bca0c3..52da9b401 100644 --- a/src/lib/exchange_api_batch_withdraw2.c +++ b/src/lib/exchange_api_batch_withdraw2.c @@ -129,7 +129,7 @@ reserve_batch_withdraw_ok (struct TALER_EXCHANGE_BatchWithdraw2Handle *wh, }; if (GNUNET_OK != - GNUNET_JSON_parse (json, + GNUNET_JSON_parse (j, spec, NULL, NULL)) { diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c index 54cc0e7fd..ea929460b 100644 --- a/src/testing/test_exchange_api.c +++ b/src/testing/test_exchange_api.c @@ -1037,7 +1037,7 @@ run (void *cls, * config, then withdraw two coin, partially spend one, and * then have the rest paid back. Check deposit of other coin * fails. Do not use EUR:5 here as the EUR:5 coin was - * revoked and we did not bother to create a new one... */// + * 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", @@ -1128,6 +1128,73 @@ run (void *cls, TALER_TESTING_cmd_end () }; + /** + * Test batch withdrawal plus spending. + */ + struct TALER_TESTING_Command batch_withdraw[] = { + /** + * Move money to the exchange's bank account. + */ + CMD_TRANSFER_TO_EXCHANGE ("create-batch-reserve-1", + "EUR:6.02"), + TALER_TESTING_cmd_reserve_poll ("poll-batch-reserve-1", + "create-batch-reserve-1", + "EUR:6.02", + GNUNET_TIME_UNIT_MINUTES, + MHD_HTTP_OK), + TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-batch-reserve-1", + "EUR:6.02", + bc.user42_payto, + bc.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"), + /** + * 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), + /** + * Check the reserve is depleted. + */ + TALER_TESTING_cmd_status ("status-batch-1", + "create-batch-reserve-1", + "EUR:0", + MHD_HTTP_OK), + /** + * Spend the coins. + */ + TALER_TESTING_cmd_deposit ("deposit-batch-simple-1", + "batch-withdraw-coin-1", + 0, + bc.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":5}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ("deposit-batch-simple-2", + "batch-withdraw-coin-1", + 1, + bc.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), + TALER_TESTING_cmd_end () + }; + + #define RESERVE_OPEN_CLOSE_CHUNK 4 #define RESERVE_OPEN_CLOSE_ITERATIONS 3 @@ -1204,6 +1271,8 @@ run (void *cls, aggregation), TALER_TESTING_cmd_batch ("refund", refund), + TALER_TESTING_cmd_batch ("batch-withdraw", + batch_withdraw), TALER_TESTING_cmd_batch ("recoup", recoup), TALER_TESTING_cmd_batch ("reserve-open-close", |