gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 01/02: fixed secret share testing


From: gnunet
Subject: [taler-anastasis] 01/02: fixed secret share testing
Date: Tue, 12 May 2020 19:19:56 +0200

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

dennis-neufeld pushed a commit to branch master
in repository anastasis.

commit 84059c04cfe8c0958322a1e488309a9c6b096e75
Author: Dennis Neufeld <address@hidden>
AuthorDate: Tue May 12 17:14:08 2020 +0000

    fixed secret share testing
---
 src/include/anastasis.h             |  41 +++++++--
 src/include/anastasis_testing_lib.h |   2 +
 src/lib/anastasis.c                 | 152 ++++++++++++++++++++++++----------
 src/lib/test_anastasis.c            |  29 +++++++
 src/lib/testing_cmd_secret_share.c  | 160 ++++++++++++++++++++++++++++++++++--
 5 files changed, 325 insertions(+), 59 deletions(-)

diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 248466d..d521836 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -27,6 +27,24 @@
 #include "anastasis_service.h"
 #include <stdbool.h>
 
+
+/**
+ * Details of a past payment
+ */
+struct ANASTASIS_PaymentDetails
+{
+  /**
+   * URL of the provider backend.
+   */
+  const char *provider_url;
+
+  /**
+   * Payment order ID of a past payment
+   */
+  const char *payment_order_id;
+};
+
+
 /*Download api*/
 
 /**
@@ -336,16 +354,19 @@ void
 ANASTASIS_policy_destroy (struct ANASTASIS_Policy *p);
 
 /**
-* Callback for a policy upload process.
-*
-* @param cls closure for callback
-* @param current_etag sends back the etag of the upload (used to prevent 
redundant uploads)
-* @param ec status code of the request
-*/
+ * Function called with the results of a #secret_share().
+ *
+ * @param cls closure
+ * @param @param current_etag sends back the etag of the upload (used to 
prevent redundant uploads)
+ * @param ec status code of the request
+ * @param http_status http status code
+ */
 typedef void
 (*ANASTASIS_ShareResultCallback)(void *cls,
-                                 const struct GNUNET_HashCode current_etags[],
-                                 const enum TALER_ErrorCode ecs[]);
+                                 const struct GNUNET_HashCode *current_etag,
+                                 const enum TALER_ErrorCode ecs,
+                                 unsigned int http_status);
+
 /**
 * Callback for a payment process for uploading a policy
 *
@@ -371,6 +392,8 @@ struct ANASTASIS_SecretShare;
 * @param last_etag NULL on 'first' use, otherwise 'current_etag' from previous 
ShareResultCallback
 * @param policies list of policies which are included in this recovery document
 * @param policies_length amount of policies in the document
+* @param pds contains details of past payments
+* @param pds_len length of pds array
 * @param spc payment callback is opened to pay the upload
 * @param spc_cls closure for the payment callback
 * @param src callback for the upload process
@@ -384,6 +407,8 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                         const struct GNUNET_HashCode *last_etag,
                         const struct ANASTASIS_Policy *policies[],
                         unsigned int policies_len,
+                        const struct ANASTASIS_PaymentDetails *pds[],
+                        unsigned int pds_len,
                         ANASTASIS_SharePaymentCallback spc,
                         void *spc_cls,
                         ANASTASIS_ShareResultCallback src,
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index 0a7dbce..a6e75a0 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -620,6 +620,7 @@ enum ANASTASIS_TESTING_SecretShareOption
  *
  * @param label command label
  * @param anastasis_url base URL of the anastasis serving our requests.
+ * @param prev_secret_share reference to a previous secret share command
  * @param id_data ID data to generate user identifier
  * @param core_secret core secret to backup/recover
  * @param core_secret_size size of core_secret
@@ -631,6 +632,7 @@ enum ANASTASIS_TESTING_SecretShareOption
 struct TALER_TESTING_Command
 ANASTASIS_TESTING_cmd_secret_share (const char *label,
                                     const char *anastasis_url,
+                                    const char *prev_secret_share,
                                     const json_t *id_data,
                                     const void *core_secret,
                                     size_t core_secret_size,
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 855fbc2..73c6a31 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -24,8 +24,6 @@
 #include <taler/taler_json_lib.h>
 #include <gnunet/gnunet_util_lib.h>
 
-#define SIZE_URL 50
-
 /**
  * FIXME: Needed? -> maybe needed in ANASTASIS_secret_share()
  * State for a "salt" CMD.
@@ -1280,6 +1278,11 @@ struct PolicyStoreState
    * upload is based on.
    */
   const char *prev_upload;
+
+  /**
+   * reference to SecretShare
+   */
+  struct ANASTASIS_SecretShare *ss;
 };
 
 /**
@@ -1326,29 +1329,23 @@ policy_store_cb (void *cls,
   struct PolicyStoreState *pss = cls;
   pss->pso = NULL;
   pss->ec = ec;
-  if (http_status != pss->http_status)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Unexpected response code %u/%d in %s:%u\n",
-                http_status,
-                (int) ec,
-                __FILE__,
-                __LINE__);
-    GNUNET_break (0);
-    return;
-  }
+
   if (NULL != ud)
   {
     switch (ud->us)
     {
     case ANASTASIS_US_SUCCESS:
-      memcpy (&pss->curr_hash,
-              &ud->details.curr_backup_hash,
-              sizeof(struct GNUNET_HashCode));
+      if (0 != GNUNET_memcmp (&pss->curr_hash,
+                              ud->details.curr_backup_hash))
+      {
+        GNUNET_break (0);
+        return;
+      }
       break;
     case ANASTASIS_US_PAYMENT_REQUIRED:
       {
         /* FIXME: Payment required handling */
+
         const char *m;
 
         if (0 != strncmp (ud->details.payment_request,
@@ -1387,8 +1384,15 @@ policy_store_cb (void *cls,
         memset (&pss->curr_hash,
                 0,
                 sizeof (struct GNUNET_HashCode));
+        if (NULL != pss->ss->spc)
+        {
+          pss->ss->spc (pss->ss->spc_cls,
+                        ud->details.payment_request,
+                        ec);
+          pss->ss->spc = NULL;
+        }
       }
-      break;
+      return;
     case ANASTASIS_US_CONFLICTING_POLICY:
       GNUNET_break (0);
       return;
@@ -1404,6 +1408,16 @@ policy_store_cb (void *cls,
       GNUNET_break (0);
       return;
     }
+
+    if (NULL != pss->ss->src)
+    {
+      pss->ss->src (pss->ss->src_cls,
+                    &pss->curr_hash,
+                    ec,
+                    http_status);
+      pss->ss->src = NULL;
+    }
+
   }
 }
 
@@ -1428,10 +1442,15 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
   }
 
   {
-    const char *provider[len];
+    char *provider[len];
 
     for (unsigned int l = 0; l < policies_len; l++)
     {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "At %s:%d policy is %s-%llu b\n", __FILE__, __LINE__,
+                  TALER_B2S (policies[l]),
+                  (unsigned long long) sizeof (struct ANASTASIS_Policy));
+
       for (unsigned int j = 0; j < policies[l]->uuids_length; j++)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1440,26 +1459,35 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
                     (unsigned long long) sizeof (struct ANASTASIS_Truth));
 
         int contains_url = 0;
-        for (unsigned int k = 0; k < len; k++)
+        if (0 < unique_urls_len)
         {
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      "At %s:%d provider url from truth is %s\n", __FILE__,
-                      __LINE__,
-                      policies[l]->truths[j]->url);
-          if (NULL != provider[k])
+          for (unsigned int k = 0; k < unique_urls_len; k++)
           {
-            if (0 ==
-                strcmp (policies[l]->truths[j]->url, provider[k]))
+            GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                        "At %s:%d provider url from truth is %s\n", __FILE__,
+                        __LINE__,
+                        policies[l]->truths[j]->url);
+
+            if (NULL != provider[k])
             {
-              contains_url = 1;
-              break;
+              if (0 ==
+                  strcmp (policies[l]->truths[j]->url, provider[k]))
+              {
+                contains_url = 1;
+                break;
+              }
             }
           }
         }
 
         if (0 == contains_url)
         {
-          provider[unique_urls_len] = policies[l]->truths[j]->url;
+          provider[unique_urls_len] = GNUNET_malloc (sizeof (char)
+                                                     * strlen (
+                                                       policies[l]->truths[j]->
+                                                       url) + 1);
+          // provider[unique_urls_len] = policies[l]->truths[j]->url;
+          strcpy (provider[unique_urls_len], policies[l]->truths[j]->url);
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "At %s:%d unique provider url is %s\n", __FILE__,
                       __LINE__,
@@ -1468,10 +1496,16 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
         }
       }
     }
+    for (unsigned int i = 0; i < unique_urls_len; i++)
+    {
+      GNUNET_free (provider[i]);
+    }
   }
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d unique_urls_len is %d\n", __FILE__, __LINE__,
               unique_urls_len);
+
   return unique_urls_len;
 }
 
@@ -1484,6 +1518,8 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
 * @param last_etag NULL on 'first' use, otherwise 'current_etag' from previous 
ShareResultCallback
 * @param policies list of policies which are included in this recovery document
 * @param policies_length amount of policies in the document
+* @param pds contains details of past payments
+* @param pds_len length of pds array
 * @param spc payment callback is opened to pay the upload
 * @param spc_cls closure for the payment callback
 * @param src callback for the upload process
@@ -1497,6 +1533,8 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                         const struct GNUNET_HashCode *last_etag,
                         const struct ANASTASIS_Policy *policies[],
                         unsigned int policies_len,
+                        const struct ANASTASIS_PaymentDetails *pds[],
+                        unsigned int pds_len,
                         ANASTASIS_SharePaymentCallback spc,
                         void *spc_cls,
                         ANASTASIS_ShareResultCallback src,
@@ -1510,8 +1548,8 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
   unsigned int pss_length = ANASTASIS_get_num_urls (policies,
                                                     policies_len);
   struct PolicyStoreState *pss[pss_length];
-  struct GNUNET_HashCode current_etags[pss_length];
-  enum TALER_ErrorCode ecs[pss_length];
+  // struct GNUNET_HashCode current_etags[pss_length];
+  // enum TALER_ErrorCode ecs[pss_length];
   struct ANASTASIS_CRYPTO_EncryptedMasterKeyP
     encrypted_master_keys[policies_len];
   struct ANASTASIS_CRYPTO_PolicyKeyP policy_keys[policies_len];
@@ -1526,12 +1564,21 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
   // json array
   json_t *esc_methods;
 
-  for (unsigned int i = 0; i < pss_length; i++)
+  if (0 == pss_length)
   {
-    pss[i] = GNUNET_new (struct PolicyStoreState);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "At %s:%d pss_length is %d!\n", __FILE__, __LINE__,
+                pss_length);
+    GNUNET_break (0);
+    return;
   }
 
   ss = GNUNET_new (struct ANASTASIS_SecretShare);
+  for (unsigned int i = 0; i < pss_length; i++)
+  {
+    pss[i] = GNUNET_new (struct PolicyStoreState);
+    pss[i]->ss = ss;
+  }
   ss->pss = pss;
   ss->pss_length = pss_length;
   ss->spc = spc;
@@ -1540,6 +1587,10 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
   ss->src_cls = src_cls;
   ss->ctx = ctx;
 
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+              "At %s:%d pss_length is %d\n", __FILE__, __LINE__,
+              ss->pss_length);
+
   for (unsigned int i = 0; i < policies_len; i++)
   {
     policy_keys[i] = policies[i]->policy_key;
@@ -1566,11 +1617,15 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
           dec_policies,
           json_pack ("{s:o,"   /* encrypted master key */
                      " s:o,"   /* policy uuids  */
+                     " s:o,"   /* policy salt  */
                      " s:i}",  /* policy uuids length */
                      "master_key",
                      GNUNET_JSON_from_data_auto (
                        &encrypted_master_keys[k]),
                      "uuids",
+                     GNUNET_JSON_from_data_auto (
+                       &policies[k]->salt),
+                     "salt",
                      GNUNET_JSON_from_data (policies[k]->uuids,
                                             policies[k]->
                                             uuids_length
@@ -1669,6 +1724,18 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
         if (NULL != last_etag)
           ss->pss[index_pss]->prev_hash = *last_etag;
         ss->pss[index_pss]->server_salt = policies[k]->truths[l]->salt;
+        if (pds_len > 0)
+        {
+          for (unsigned int m = 0; 0 < pds_len; m++)
+          {
+            if (0 == strcmp (pds[m]->provider_url,
+                             policies[k]->truths[l]->url))
+            {
+              ss->pss[index_pss]->payment_order_id = pds[m]->payment_order_id;
+              break;
+            }
+          }
+        }
         index_pss++;
       }
     }
@@ -1698,6 +1765,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
   recovery_document_size = strlen (recovery_document_str);
   GNUNET_assert (NULL != recovery_document_str);
 
+
   for (unsigned int l = 0; l < ss->pss_length; l++)
   {
     // ss->pss[l]->http_status = MHD_HTTP_NO_CONTENT;
@@ -1718,6 +1786,11 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
     GNUNET_CRYPTO_hash (ss->pss[l]->recovery_data,
                         ss->pss[l]->recovery_data_size,
                         &ss->pss[l]->curr_hash);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d current hash is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (&ss->pss[l]->curr_hash),
+                (unsigned long long) sizeof (struct GNUNET_HashCode));
+
     ss->pss[l]->pso = ANASTASIS_policy_store (ss->ctx,
                                               ss->pss[l]->anastasis_url,
                                               &ss->pss[l]->anastasis_priv,
@@ -1735,19 +1808,12 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                                               ss->pss[l]);
     GNUNET_assert (NULL != ss->pss[l]->pso);
 
-    current_etags[l] = ss->pss[l]->curr_hash;
-    ecs[l] = ss->pss[l]->ec;
+    // current_etags[l] = ss->pss[l]->curr_hash;
+    // ecs[l] = ss->pss[l]->ec;
   }
+
   // FIXME: clean up PSS, UUIDS, TRUTHS etc. !!!
   // SETUP SHARE RESULT CALLBACK
-
-  if (NULL != ss->src)
-  {
-    ss->src (ss->src_cls,
-             current_etags,
-             ecs);
-    ss->src = NULL;
-  }
   return ss;
 }
 
diff --git a/src/lib/test_anastasis.c b/src/lib/test_anastasis.c
index 58c1a08..80a9f07 100644
--- a/src/lib/test_anastasis.c
+++ b/src/lib/test_anastasis.c
@@ -244,6 +244,7 @@ run (void *cls,
 
     ANASTASIS_TESTING_cmd_secret_share ("secret-share-1",
                                         anastasis_url,
+                                        NULL,
                                         ANASTASIS_TESTING_make_id_data_example 
(
                                           "MaxMuster123456789"),
                                         "core secret",
@@ -252,6 +253,34 @@ run (void *cls,
                                         ANASTASIS_TESTING_SSO_NONE,
                                         "policy-create-1",
                                         NULL),
+
+    /* what would we have to pay? */
+    TALER_TESTING_cmd_proposal_lookup ("fetch-proposal",
+                                       merchant_url,
+                                       MHD_HTTP_OK,
+                                       "secret-share-1",
+                                       NULL),
+    /* make the payment */
+    TALER_TESTING_cmd_pay ("pay-account",
+                           merchant_url,
+                           MHD_HTTP_OK,
+                           "fetch-proposal",
+                           "withdraw-coin-1",
+                           "EUR:5",
+                           "EUR:4.99", /* must match ANNUAL_FEE in config! */
+                           "EUR:0.01"),
+
+    ANASTASIS_TESTING_cmd_secret_share ("secret-share-2",
+                                        anastasis_url,
+                                        "secret-share-1",
+                                        ANASTASIS_TESTING_make_id_data_example 
(
+                                          "MaxMuster123456789"),
+                                        "core secret",
+                                        strlen ("core secret"),
+                                        MHD_HTTP_NO_CONTENT,
+                                        ANASTASIS_TESTING_SSO_NONE,
+                                        "policy-create-1",
+                                        NULL),
     /**
     ANASTASIS_TESTING_cmd_recover_secret ("recover-secret-1",
                                           anastasis_url,
diff --git a/src/lib/testing_cmd_secret_share.c 
b/src/lib/testing_cmd_secret_share.c
index ee099f4..d9cd8dc 100644
--- a/src/lib/testing_cmd_secret_share.c
+++ b/src/lib/testing_cmd_secret_share.c
@@ -83,9 +83,9 @@ struct SecretShareState
   struct ANASTASIS_SecretShare *sso;
 
   /**
-   * Reference to upload command we expect to lookup.
+   * Reference to previous secret share command we expect to lookup.
    */
-  const char *upload_reference;
+  const char *prev_secret_share;
 
   /**
    * Options for how we are supposed to do the upload.
@@ -101,6 +101,16 @@ struct SecretShareState
    * closure for the result callback
    */
   void *src_cls;
+
+  /**
+   * Payment order ID we got back, if any. Otherwise NULL.
+   */
+  const char *payment_order_id;
+
+  /**
+   * Details of a past payment
+   */
+  struct ANASTASIS_PaymentDetails *pd;
 };
 
 
@@ -116,8 +126,60 @@ secret_share_payment_cb (void *cls,
                          const char *taler_pay_url,
                          enum TALER_ErrorCode ec)
 {
+  const char *m;
   struct SecretShareState *sss = cls;
   sss->sso = NULL;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "At %s:%d we are in SPC\n",
+              __FILE__, __LINE__);
+  if (sss->http_status != MHD_HTTP_PAYMENT_REQUIRED)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unexpected response code %u/%d to command %s in %s:%u\n",
+                sss->http_status,
+                (int) ec,
+                sss->is->commands[sss->is->ip].label,
+                __FILE__,
+                __LINE__);
+    TALER_TESTING_interpreter_fail (sss->is);
+    return;
+  }
+
+  if (0 != strncmp (taler_pay_url,
+                    "taler://pay/http",
+                    strlen ("taler://pay/http")))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Did not find `%s' in `%s'\n",
+                "/-/-/",
+                taler_pay_url);
+    GNUNET_break (0);
+    return;
+  }
+  m = strstr (taler_pay_url, "/-/-/");
+  if (NULL == m)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Did not find `%s' in `%s'\n",
+                "/-/-/",
+                taler_pay_url);
+    /* NOTE: The above is a simplifying assumption for the
+        test-logic, hitting this code merely means that
+        the assumptions for the test (i.e. no instance) are
+        not satisfied, it is not inherently the case that
+        the above token must appear in the payment request!
+
+        So if you hit this, you might just want to modify
+        the code here to handle this better! */return;
+  }
+  sss->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "At %s:%d Order ID from Anastasis service is %s\n",
+              __FILE__, __LINE__,
+              sss->payment_order_id);
+
+  TALER_TESTING_interpreter_next (sss->is);
 }
 
 
@@ -125,16 +187,51 @@ secret_share_payment_cb (void *cls,
  * Function called with the results of a #secret_share().
  *
  * @param cls closure
- * @param @param current_etags sends back the etag of the upload (used to 
prevent redundant uploads)
- * @param ecs status code of the request
+ * @param @param current_etag sends back the etag of the upload (used to 
prevent redundant uploads)
+ * @param ec status code of the request
+ * @param http_status http status code
  */
 static void
 secret_share_result_cb (void *cls,
-                        const struct GNUNET_HashCode *current_etags,
-                        const enum TALER_ErrorCode *ecs)
+                        const struct GNUNET_HashCode *current_etag,
+                        const enum TALER_ErrorCode ec,
+                        unsigned int http_status)
 {
   struct SecretShareState *sss = cls;
   sss->sso = NULL;
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "At %s:%d we are in SRC\n",
+              __FILE__, __LINE__);
+  if (NULL != sss)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d etag is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (&current_etag),
+                (unsigned long long) sizeof (struct GNUNET_HashCode));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d error code is %d\n", __FILE__, __LINE__,
+                ec);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d http status is %u\n", __FILE__, __LINE__,
+                http_status);
+
+    if (http_status != sss->http_status)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Unexpected response code %u/%d to command %s in %s:%u\n",
+                  http_status,
+                  (int) ec,
+                  sss->is->commands[sss->is->ip].label,
+                  __FILE__,
+                  __LINE__);
+      TALER_TESTING_interpreter_fail (sss->is);
+      return;
+    }
+    TALER_TESTING_interpreter_next (sss->is);
+    return;
+  }
+  TALER_TESTING_interpreter_fail (sss->is);
+  return;
 }
 
 /**
@@ -151,6 +248,8 @@ secret_share_run (void *cls,
 {
   struct SecretShareState *sss = cls;
   const struct ANASTASIS_Policy *policies[sss->cmd_label_array_length];
+  unsigned int pds_len = 1;
+  const struct ANASTASIS_PaymentDetails *pds[pds_len];
 
   GNUNET_assert (sss->cmd_label_array_length > 0);
   GNUNET_assert (NULL != sss->cmd_label_array);
@@ -194,15 +293,55 @@ secret_share_run (void *cls,
     }
   }
 
+  if (NULL != sss->prev_secret_share)
+  {
+    const struct TALER_TESTING_Command *ref;
+
+    ref = TALER_TESTING_interpreter_lookup_command
+            (is,
+            sss->prev_secret_share);
+    if (NULL == ref)
+    {
+      GNUNET_break (0);
+      TALER_TESTING_interpreter_fail (sss->is);
+      return;
+    }
+    const char *order_id;
+    if (GNUNET_OK !=
+        TALER_TESTING_get_trait_order_id (ref,
+                                          0,
+                                          &order_id))
+    {
+      GNUNET_break (0);
+      TALER_TESTING_interpreter_fail (sss->is);
+      return;
+    }
+    sss->payment_order_id = order_id;
+
+    if (NULL == sss->payment_order_id)
+    {
+      GNUNET_break (0);
+      TALER_TESTING_interpreter_fail (sss->is);
+      return;
+    }
+  }
+
+  sss->pd = GNUNET_new (struct ANASTASIS_PaymentDetails);
+  sss->pd->payment_order_id = sss->payment_order_id;
+  sss->pd->provider_url = sss->anastasis_url;
+  pds[0] = sss->pd;
+
   sss->sso = ANASTASIS_secret_share (is->ctx,
                                      sss->id_data,
                                      NULL,
                                      policies,
                                      sss->cmd_label_array_length,
+                                     pds,
+                                     pds_len,
                                      &secret_share_payment_cb,
-                                     sss->spc_cls,
+                                     sss,
                                      &secret_share_result_cb,
-                                     sss->src_cls,
+                                     sss,
                                      sss->core_secret,
                                      sss->core_secret_size);
 
@@ -252,6 +391,8 @@ secret_share_traits (void *cls,
   struct TALER_TESTING_Trait traits[] = {
     ANASTASIS_TESTING_make_trait_core_secret (0,
                                               sss->core_secret),
+    TALER_TESTING_make_trait_order_id (0,
+                                       sss->payment_order_id),
     TALER_TESTING_trait_end ()
   };
 
@@ -267,6 +408,7 @@ secret_share_traits (void *cls,
  *
  * @param label command label
  * @param anastasis_url base URL of the anastasis serving our requests.
+ * @param prev_secret_share reference to a previous secret share command
  * @param id_data ID data to generate user identifier
  * @param core_secret core secret to backup/recover
  * @param core_secret_size size of core_secret
@@ -278,6 +420,7 @@ secret_share_traits (void *cls,
 struct TALER_TESTING_Command
 ANASTASIS_TESTING_cmd_secret_share (const char *label,
                                     const char *anastasis_url,
+                                    const char *prev_secret_share,
                                     const json_t *id_data,
                                     const void *core_secret,
                                     size_t core_secret_size,
@@ -297,6 +440,7 @@ ANASTASIS_TESTING_cmd_secret_share (const char *label,
   sss->id_data = id_data;
   sss->core_secret = core_secret;
   sss->core_secret_size = core_secret_size;
+  sss->prev_secret_share = prev_secret_share;
 
   va_start (ap, sso);
   const char *policy_create_cmd;

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



reply via email to

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