gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-exchange] branch master updated: add testcase for 's


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: add testcase for 'select_refunds_by_coin'
Date: Wed, 03 Jan 2018 01:11:17 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new d9f16db  add testcase for 'select_refunds_by_coin'
d9f16db is described below

commit d9f16db0efca71d47455ee2efab7eabf4003a0a0
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Jan 3 01:10:23 2018 +0100

    add testcase for 'select_refunds_by_coin'
---
 src/exchangedb/plugin_exchangedb_postgres.c |  2 +-
 src/exchangedb/test_exchangedb.c            | 73 ++++++++++++++++++++++++++++-
 2 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 9c91259..7e1ef54 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -3082,7 +3082,7 @@ get_refunds_cb (void *cls,
                                            &merchant_pub),
       GNUNET_PQ_result_spec_auto_from_type ("merchant_sig",
                                            &merchant_sig),
-      GNUNET_PQ_result_spec_auto_from_type ("h_contract",
+      GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms",
                                            &h_contract),
       GNUNET_PQ_result_spec_uint64 ("rtransaction_id",
                                    &rtransaction_id),
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 5891a08..62ff2a7 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1394,6 +1394,72 @@ wire_missing_cb (void *cls,
 
 
 /**
+ * Callback invoked with information about refunds applicable
+ * to a particular coin.
+ *
+ * @param cls closure with the `struct TALER_EXCHANGEDB_Refund *` we expect to 
get
+ * @param merchant_pub public key of merchant who authorized refund
+ * @param merchant_sig signature of merchant authorizing refund
+ * @param h_contract hash of contract being refunded
+ * @param rtransaction_id refund transaction ID
+ * @param amount_with_fee amount being refunded
+ * @param refund_fee fee the exchange keeps for the refund processing
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
+ */
+static int
+check_refund_cb (void *cls,
+                const struct TALER_MerchantPublicKeyP *merchant_pub,
+                const struct TALER_MerchantSignatureP *merchant_sig,
+                const struct GNUNET_HashCode *h_contract,
+                uint64_t rtransaction_id,
+                const struct TALER_Amount *amount_with_fee,
+                const struct TALER_Amount *refund_fee)
+{
+  const struct TALER_EXCHANGEDB_Refund *refund = cls;
+
+  if (0 != memcmp (merchant_pub,
+                  &refund->merchant_pub,
+                  sizeof (struct TALER_MerchantPublicKeyP)))
+  {
+    GNUNET_break (0);
+    result = 66;
+  }
+  if (0 != memcmp (merchant_sig,
+                  &refund->merchant_sig,
+                  sizeof (struct TALER_MerchantSignatureP)))
+  {
+    GNUNET_break (0);
+    result = 66;
+  }
+  if (0 != memcmp (h_contract,
+                  &refund->h_contract_terms,
+                  sizeof (struct GNUNET_HashCode)))
+  {
+    GNUNET_break (0);
+    result = 66;
+  }
+  if (rtransaction_id != refund->rtransaction_id)
+  {
+    GNUNET_break (0);
+    result = 66;
+  }
+  if (0 != TALER_amount_cmp (amount_with_fee,
+                            &refund->refund_amount))
+  {
+    GNUNET_break (0);
+    result = 66;
+  }
+  if (0 != TALER_amount_cmp (refund_fee,
+                            &refund->refund_fee))
+  {
+    GNUNET_break (0);
+    result = 66;
+  }
+  return GNUNET_OK;
+}
+
+
+/**
  * Main function that will be run by the scheduler.
  *
  * @param cls closure with config
@@ -1897,7 +1963,12 @@ run (void *cls)
           plugin->insert_refund (plugin->cls,
                                  session,
                                  &refund));
-
+  FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+         plugin->select_refunds_by_coin (plugin->cls,
+                                         session,
+                                         &refund.coin.coin_pub,
+                                         &check_refund_cb,
+                                         &refund));
 
   /* test payback / revocation */
   RND_BLK (&master_sig);

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]