gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 256/277: test for auto marking orders as wired after in


From: gnunet
Subject: [taler-merchant] 256/277: test for auto marking orders as wired after inserting sufficient transfers
Date: Sun, 05 Jul 2020 20:52:49 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

commit 2c0797c8f5c236e63b2de86476ac9cdc70c76e22
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
AuthorDate: Fri Jun 26 15:24:06 2020 -0400

    test for auto marking orders as wired after inserting sufficient transfers
---
 src/backenddb/test_merchantdb.c | 144 +++++++++++++++++++++++++++++++---------
 1 file changed, 113 insertions(+), 31 deletions(-)

diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 59699d0..3765088 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -56,15 +56,36 @@ static struct TALER_MERCHANTDB_Plugin *plugin;
                          return 1; \
                          )
 
+
+/**
+ * Container for instance settings along with keys.
+ */
 struct InstanceData
 {
+  /**
+   * The instance settings.
+   */
   struct TALER_MERCHANTDB_InstanceSettings instance;
+
+  /**
+   * The public key for the instance.
+   */
   struct TALER_MerchantPublicKeyP merchant_pub;
+
+  /**
+   * The private key for the instance.
+   */
   struct TALER_MerchantPrivateKeyP merchant_priv;
 };
 
 
 /* Instances */
+/**
+ * Creates data for an instance to use with testing.
+ *
+ * @param instance_id the identifier for this instance.
+ * @param instance the instance data to be filled.
+ */
 static void
 make_instance (char *instance_id,
                struct InstanceData *instance)
@@ -97,6 +118,11 @@ make_instance (char *instance_id,
 }
 
 
+/**
+ * Frees memory allocated when creating an instance for testing.
+ *
+ * @param instance the instance containing the memory to be freed.
+ */
 static void
 free_instance_data (struct InstanceData *instance)
 {
@@ -105,6 +131,11 @@ free_instance_data (struct InstanceData *instance)
 }
 
 
+/**
+ * Creates an account with test data for an instance.
+ *
+ * @param account the account to initialize.
+ */
 static void
 make_account (struct TALER_MERCHANTDB_AccountDetails *account)
 {
@@ -118,22 +149,22 @@ make_account (struct TALER_MERCHANTDB_AccountDetails 
*account)
 
 
 /**
- * Instance settings along with corresponding accounts
+ * Instance settings along with corresponding accounts.
  */
 struct InstanceWithAccounts
 {
   /**
-   * Pointer to the instance settings
+   * Pointer to the instance settings.
    */
   const struct TALER_MERCHANTDB_InstanceSettings *instance;
 
   /**
-   * Length of the array of accounts
+   * Length of the array of accounts.
    */
   unsigned int accounts_length;
 
   /**
-   * Pointer to the array of accounts
+   * Pointer to the array of accounts.
    */
   const struct TALER_MERCHANTDB_AccountDetails *accounts;
 
@@ -141,32 +172,39 @@ struct InstanceWithAccounts
 
 
 /**
- * Closure for testing instance lookup
+ * Closure for testing instance lookup.
  */
 struct TestLookupInstances_Closure
 {
   /**
-   * Number of instances to compare to
+   * Number of instances to compare to.
    */
   unsigned int instances_to_cmp_length;
 
   /**
-   * Pointer to array of instances
+   * Pointer to array of instances.
    */
   const struct InstanceWithAccounts *instances_to_cmp;
 
   /**
-   * Pointer to array of number of matches for each instance
+   * Pointer to array of number of matches for each instance.
    */
   unsigned int *results_matching;
 
   /**
-   * Total number of results returned
+   * Total number of results returned.
    */
   unsigned int results_length;
 };
 
 
+/**
+ * Compares two instances for equality.
+ *
+ * @param a the first instance.
+ * @param b the second instance.
+ * @return 0 on equality, 1 otherwise.
+ */
 static int
 check_instances_equal (const struct TALER_MERCHANTDB_InstanceSettings *a,
                        const struct TALER_MERCHANTDB_InstanceSettings *b)
@@ -196,6 +234,13 @@ check_instances_equal (const struct 
TALER_MERCHANTDB_InstanceSettings *a,
 }
 
 
+/**
+ * Compares two accounts for equality.
+ *
+ * @param a the first account.
+ * @param b the second account.
+ * @return 0 on equality, 1 otherwise.
+ */
 static int
 check_accounts_equal (const struct TALER_MERCHANTDB_AccountDetails *a,
                       const struct TALER_MERCHANTDB_AccountDetails *b)
@@ -212,6 +257,16 @@ check_accounts_equal (const struct 
TALER_MERCHANTDB_AccountDetails *a,
 }
 
 
+/**
+ * Called after testing 'lookup_instances'.
+ *
+ * @param cls pointer to 'struct TestLookupInstances_Closure'.
+ * @param merchant_pub public key of the instance
+ * @param merchant_priv private key of the instance, NULL if not available
+ * @param is general instance settings
+ * @param accounts_length length of the @a accounts array
+ * @param accounts list of accounts of the merchant
+*/
 static void
 lookup_instances_cb (void *cls,
                      const struct TALER_MerchantPublicKeyP *merchant_pub,
@@ -256,6 +311,13 @@ lookup_instances_cb (void *cls,
 }
 
 
+/**
+ * Tests @e insert_instance.
+ *
+ * @param instance the instance data to insert.
+ * @param expected_result the result that should be returned from the plugin.
+ * @return 0 on success, 1 on failure.
+ */
 static int
 test_insert_instance (const struct InstanceData *instance,
                       enum GNUNET_DB_QueryStatus expected_result)
@@ -270,6 +332,13 @@ test_insert_instance (const struct InstanceData *instance,
 }
 
 
+/**
+ * Tests @e update_instance.
+ *
+ * @param updated_data the instance data to update the row in the database to.
+ * @param expected_result the result that should be returned from the plugin.
+ * @return 0 on success, 1 on failure.
+ */
 static int
 test_update_instance (const struct InstanceData *updated_data,
                       enum GNUNET_DB_QueryStatus expected_result)
@@ -282,6 +351,15 @@ test_update_instance (const struct InstanceData 
*updated_data,
 }
 
 
+/**
+ * Tests @e lookup_instances.
+ *
+ * @param active_only whether to lookup all instance, or only active ones.
+ * @param instances_length number of instances to compare to in @e instances.
+ * @param instances a list of instances that will be compared with the results
+ *        found.
+ * @return 0 on success, 1 otherwise.
+ */
 static int
 test_lookup_instances (bool active_only,
                        unsigned int instances_length,
@@ -2873,7 +2951,7 @@ run_test_transfers (struct TestTransfers_Closure *cls)
                                                   &wtid,
                                                   &amount,
                                                   cls->account.payto_uri,
-                                                  false),
+                                                  true),
                          "Insert transfer failed\n");
   /* Test that double insert fails */
   TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
@@ -2883,7 +2961,7 @@ run_test_transfers (struct TestTransfers_Closure *cls)
                                                   &wtid,
                                                   &amount,
                                                   cls->account.payto_uri,
-                                                  false),
+                                                  true),
                          "Insert transfer failed\n");
   /* Test transfer details */
   GNUNET_assert (GNUNET_OK ==
@@ -2892,6 +2970,26 @@ run_test_transfers (struct TestTransfers_Closure *cls)
   GNUNET_assert (GNUNET_OK ==
                  TALER_string_to_amount ("EUR:0.49",
                                          &transfer_data.wire_fee));
+  /* Test insert deposit to transfer */
+  {
+    const struct TALER_EXCHANGE_DepositData deposit_data = {
+      .exchange_pub = cls->signkey.exchange_pub,
+      .exchange_sig = cls->deposit.exchange_sig,
+      .wtid = wtid,
+      .execution_time = transfer_data.execution_time,
+      .coin_contribution = transfer_data.total_amount
+    };
+    TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+                           plugin->insert_deposit_to_transfer (plugin->cls,
+                                                               4,
+                                                               &deposit_data),
+                           "Insert deposit to transfer failed\n");
+    TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
+                           plugin->insert_deposit_to_transfer (plugin->cls,
+                                                               4,
+                                                               &deposit_data),
+                           "Insert deposit to transfer failed\n");
+  }
   TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
                          plugin->insert_transfer_details (plugin->cls,
                                                           
cls->instance.instance
@@ -2902,6 +3000,10 @@ run_test_transfers (struct TestTransfers_Closure *cls)
                                                           &wtid,
                                                           &transfer_data),
                          "Insert transfer details failed\n");
+  TEST_RET_ON_FAIL (test_lookup_payment_status (5,
+                                                NULL,
+                                                false,
+                                                true));
   /* Test lookup transfer */
   GNUNET_assert (0 <= TALER_amount_add (&total_with_fee,
                                         &transfer_data.total_amount,
@@ -2925,26 +3027,6 @@ run_test_transfers (struct TestTransfers_Closure *cls)
                                           &transfer_data.wire_fee,
                                           &transfer_data.execution_time,
                                           true));
-  /* Test insert deposit to transfer */
-  {
-    const struct TALER_EXCHANGE_DepositData deposit_data = {
-      .exchange_pub = cls->signkey.exchange_pub,
-      .exchange_sig = cls->deposit.exchange_sig,
-      .wtid = wtid,
-      .execution_time = transfer_data.execution_time,
-      .coin_contribution = transfer_data.total_amount
-    };
-    TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
-                           plugin->insert_deposit_to_transfer (plugin->cls,
-                                                               3,
-                                                               &deposit_data),
-                           "Insert deposit to transfer failed\n");
-    TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
-                           plugin->insert_deposit_to_transfer (plugin->cls,
-                                                               3,
-                                                               &deposit_data),
-                           "Insert deposit to transfer failed\n");
-  }
   /* Test lookup transfer summary */
   TEST_RET_ON_FAIL (test_lookup_transfer_summary (cls->deposit.exchange_url,
                                                   &wtid,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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