summaryrefslogtreecommitdiff
path: root/src/lib/test_exchange_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-01-12 20:22:18 +0100
committerChristian Grothoff <christian@grothoff.org>2020-01-12 20:22:18 +0100
commit58b78da001e46675205c80818e85d4996f4648f2 (patch)
tree5038e51ec9c333f6a56ba3b0614d4e47ce4a7e45 /src/lib/test_exchange_api.c
parent636c148c0755498738e9e25c943405d55e30c9fc (diff)
downloadexchange-58b78da001e46675205c80818e85d4996f4648f2.tar.gz
exchange-58b78da001e46675205c80818e85d4996f4648f2.tar.bz2
exchange-58b78da001e46675205c80818e85d4996f4648f2.zip
merge revocation tests
Diffstat (limited to 'src/lib/test_exchange_api.c')
-rw-r--r--src/lib/test_exchange_api.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/lib/test_exchange_api.c b/src/lib/test_exchange_api.c
index 24b7c6cba..4f9034141 100644
--- a/src/lib/test_exchange_api.c
+++ b/src/lib/test_exchange_api.c
@@ -836,6 +836,116 @@ run (void *cls,
TALER_TESTING_cmd_end ()
};
+ struct TALER_TESTING_Command revocation[] = {
+ /**
+ * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per
+ * config.
+ */
+ CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1",
+ "EUR:5.01"),
+ /**
+ * Run wire-watch to trigger the reserve creation.
+ */
+ CMD_EXEC_WIREWATCH ("wirewatch-4"),
+ /* Withdraw a 5 EUR coin, at fee of 1 ct */
+ TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
+ "create-reserve-1",
+ "EUR:5",
+ 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
+ ("deposit-partial",
+ "withdraw-coin-1", 0,
+ TALER_TESTING_make_wire_details (42,
+ fakebank_url),
+ "{\"items\":[{\"name\":\"ice cream\",\
+ \"value\":\"EUR:1\"}]}",
+ GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK),
+ /**
+ * Melt SOME of the rest of the coin's value
+ * (EUR:3.17 = 3x EUR:1.03 + 7x EUR:0.13) */
+ TALER_TESTING_cmd_refresh_melt
+ ("refresh-melt-1",
+ "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),
+ /* Make refreshed coin invalid */
+ TALER_TESTING_cmd_revoke ("revoke-1",
+ MHD_HTTP_OK,
+ "refresh-melt-1",
+ CONFIG_FILE),
+ /* Refund coin to original coin */
+ TALER_TESTING_cmd_payback ("payback-1a",
+ MHD_HTTP_OK,
+ "refresh-reveal-1#0",
+ "EUR:1",
+ "refresh-melt-1"),
+ TALER_TESTING_cmd_payback ("payback-1b",
+ MHD_HTTP_OK,
+ "refresh-reveal-1#1",
+ "EUR:1",
+ "refresh-melt-1"),
+ TALER_TESTING_cmd_payback ("payback-1c",
+ MHD_HTTP_OK,
+ "refresh-reveal-1#2",
+ "EUR:1",
+ "refresh-melt-1"),
+ /* Now we have EUR:3.83 EUR back after 3x EUR:1 in paybacks */
+ /* Melt original coin AGAIN, but only create one 0.1 EUR coin;
+ This costs EUR:0.03 in refresh and EUR:01 in withdraw fees,
+ leaving EUR:3.69. */
+ TALER_TESTING_cmd_refresh_melt
+ ("refresh-melt-2",
+ "withdraw-coin-1",
+ MHD_HTTP_OK,
+ "EUR:0.1",
+ NULL),
+ /**
+ * Complete (successful) melt operation, and withdraw the coins
+ */
+ TALER_TESTING_cmd_refresh_reveal
+ ("refresh-reveal-2",
+ "refresh-melt-2", MHD_HTTP_OK),
+ /* Revokes refreshed EUR:0.1 coin */
+ TALER_TESTING_cmd_revoke ("revoke-2",
+ MHD_HTTP_OK,
+ "refresh-reveal-2",
+ CONFIG_FILE),
+ /* Revoke also original coin denomination */
+ TALER_TESTING_cmd_revoke ("revoke-3",
+ MHD_HTTP_OK,
+ "withdraw-coin-1",
+ CONFIG_FILE),
+ /* Refund coin EUR:0.1 to original coin, creating zombie! */
+ TALER_TESTING_cmd_payback ("payback-2",
+ MHD_HTTP_OK,
+ "refresh-reveal-2",
+ "EUR:0.1",
+ "refresh-melt-2"),
+ /* Due to payback, original coin is now at EUR:3.79 */
+ /* Refund original (now zombie) coin to reserve */
+ TALER_TESTING_cmd_payback ("payback-3",
+ MHD_HTTP_OK,
+ "withdraw-coin-1",
+ "EUR:3.79",
+ NULL),
+ /* Check the money is back with the reserve */
+ TALER_TESTING_cmd_status ("payback-reserve-status-1",
+ "create-reserve-1",
+ "EUR:3.79",
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_end ()
+ };
+
#define RESERVE_OPEN_CLOSE_CHUNK 4
#define RESERVE_OPEN_CLOSE_ITERATIONS 3
@@ -867,6 +977,7 @@ run (void *cls,
reserve_open_close[RESERVE_OPEN_CLOSE_ITERATIONS * RESERVE_OPEN_CLOSE_CHUNK]
= TALER_TESTING_cmd_end ();
+
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_batch ("wire",
wire),
@@ -886,6 +997,8 @@ run (void *cls,
payback),
TALER_TESTING_cmd_batch ("reserve-open-close",
reserve_open_close),
+ TALER_TESTING_cmd_batch ("revocation",
+ revocation),
/**
* End the suite. Fixme: better to have a label for this
* too, as it shows as "(null)" on logs.