From 7085cfef70889a11508cdac4cd887b9959f59218 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 10 Jul 2020 23:09:46 +0200 Subject: test coin_priv re-use with deposit and refresh, update handling of the error code client-side --- src/testing/test_exchange_api.c | 43 ++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'src/testing/test_exchange_api.c') diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c index 410c1a49..75e3d480 100644 --- a/src/testing/test_exchange_api.c +++ b/src/testing/test_exchange_api.c @@ -136,12 +136,12 @@ run (void *cls, * Do another transfer to the same reserve */ TALER_TESTING_cmd_admin_add_incoming_with_ref ("create-reserve-1.2", - "EUR:1", + "EUR:2.01", &bc.exchange_auth, bc.user42_payto, "create-reserve-1"), TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1.2", - "EUR:1", + "EUR:2.01", bc.user42_payto, bc.exchange_payto, "create-reserve-1.2"), @@ -153,6 +153,15 @@ run (void *cls, "create-reserve-1", "EUR:5", MHD_HTTP_OK), + /** + * Withdraw EUR:1 using the SAME private coin key as for the previous coin + * (in violation of the specification, to be detected on spending!). + */ + TALER_TESTING_cmd_withdraw_amount_reuse_key ("withdraw-coin-1x", + "create-reserve-1", + "EUR:1", + "withdraw-coin-1", + MHD_HTTP_OK), /** * Check the reserve is depleted. */ @@ -160,6 +169,13 @@ run (void *cls, "create-reserve-1", "EUR:0", MHD_HTTP_OK), + /* + * Try to overdraw. + */ + TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2", + "create-reserve-1", + "EUR:5", + MHD_HTTP_CONFLICT), TALER_TESTING_cmd_end () }; @@ -178,13 +194,14 @@ run (void *cls, TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay", "deposit-simple", MHD_HTTP_OK), - /* - * Try to overdraw. - */ - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2", - "create-reserve-1", - "EUR:5", - MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_deposit ("deposit-reused-coin-key-failure", + "withdraw-coin-1x", + 0, + bc.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_CONFLICT), /** * Try to double spend using different wire details. */ @@ -225,6 +242,14 @@ run (void *cls, }; struct TALER_TESTING_Command refresh[] = { + /** + * Try to melt the coin that shared the private key with another + * coin (should fail). */ + 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"), -- cgit v1.2.3