From 0a047c155ac8f572db0c7184cc491092c724c5c5 Mon Sep 17 00:00:00 2001
From: Florian Dold <florian.dold@gmail.com>
Date: Fri, 27 Mar 2020 16:52:42 +0530
Subject: recoup test: cover recoup of fully spend coin

---
 src/testing/test_exchange_api_revocation.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/src/testing/test_exchange_api_revocation.c b/src/testing/test_exchange_api_revocation.c
index d757daa39..f91d8b548 100644
--- a/src/testing/test_exchange_api_revocation.c
+++ b/src/testing/test_exchange_api_revocation.c
@@ -63,15 +63,15 @@ run (void *cls,
 {
   struct TALER_TESTING_Command revocation[] = {
     /**
-     * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per
+     * Fill reserve with EUR:10.02, as withdraw fee is 1 ct per
      * config.
      */
     TALER_TESTING_cmd_admin_add_incoming ("create-reserve-1",
-                                          "EUR:5.01",
+                                          "EUR:10.02",
                                           &bc.exchange_auth,
                                           bc.user42_payto),
     TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
-                                                 "EUR:5.01",
+                                                 "EUR:10.02",
                                                  bc.user42_payto,
                                                  bc.exchange_payto,
                                                  "create-reserve-1"),
@@ -85,6 +85,11 @@ run (void *cls,
                                        "create-reserve-1",
                                        "EUR:5",
                                        MHD_HTTP_OK),
+    /* Withdraw another 5 EUR coin, at fee of 1 ct */
+    TALER_TESTING_cmd_withdraw_amount ("withdraw-revocation-coin-2",
+                                       "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",
@@ -95,6 +100,15 @@ run (void *cls,
                                GNUNET_TIME_UNIT_ZERO,
                                "EUR:1",
                                MHD_HTTP_OK),
+    /* Deposit another coin in full */
+    TALER_TESTING_cmd_deposit ("deposit-full",
+                               "withdraw-revocation-coin-2",
+                               0,
+                               bc.user42_payto,
+                               "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
+                               GNUNET_TIME_UNIT_ZERO,
+                               "EUR:5",
+                               MHD_HTTP_OK),
     /**
      * Melt SOME of the rest of the coin's value
      * (EUR:3.17 = 3x EUR:1.03 + 7x EUR:0.13) */
@@ -118,6 +132,16 @@ run (void *cls,
                               MHD_HTTP_OK,
                               "refresh-melt-1",
                               CONFIG_FILE),
+    /* Also make fully spent coin invalid (should be same denom) */
+    TALER_TESTING_cmd_revoke ("revoke-2-EUR:5",
+                              MHD_HTTP_OK,
+                              "withdraw-revocation-coin-2",
+                              CONFIG_FILE),
+    /* Refund fully spent coin (which should fail) */
+    TALER_TESTING_cmd_recoup ("recoup-fully-spent",
+                              MHD_HTTP_CONFLICT,
+                              "withdraw-revocation-coin-2",
+                              NULL),
     /* Refund coin to original coin */
     TALER_TESTING_cmd_recoup ("recoup-1a",
                               MHD_HTTP_OK,
-- 
cgit v1.2.3