[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-sync] branch master updated (399392b -> d92b7d9)
From: |
gnunet |
Subject: |
[taler-sync] branch master updated (399392b -> d92b7d9) |
Date: |
Fri, 29 Nov 2019 21:40:44 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a change to branch master
in repository sync.
from 399392b work on upload command
new f39e8c6 more work on testing logic
new d92b7d9 del
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/include/sync_testing_lib.h | 20 +--
src/lib/test_sync_api.c | 6 +-
.../.local/share/taler/auditors/auditor.out | Bin 42328 -> 0 bytes
src/lib/testing_api_cmd_backup_upload.c | 158 ++++++++++++++++++---
src/lib/testing_api_helpers.c | 6 +-
src/lib/testing_api_trait_account_priv.c | 2 +-
src/lib/testing_api_trait_account_pub.c | 2 +-
src/lib/testing_api_trait_hash.c | 2 +-
8 files changed, 162 insertions(+), 34 deletions(-)
delete mode 100644
src/lib/test_sync_api_home/.local/share/taler/auditors/auditor.out
diff --git a/src/include/sync_testing_lib.h b/src/include/sync_testing_lib.h
index 25594e1..79e7eec 100644
--- a/src/include/sync_testing_lib.h
+++ b/src/include/sync_testing_lib.h
@@ -63,8 +63,8 @@ SYNC_TESTING_get_trait_hash (const struct
TALER_TESTING_Command *cmd,
* @return #GNUNET_OK on success.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_hash (unsigned int index,
- const struct GNUNET_HashCode *h);
+SYNC_TESTING_make_trait_hash (unsigned int index,
+ const struct GNUNET_HashCode *h);
/**
@@ -89,8 +89,8 @@ SYNC_TESTING_get_trait_account_pub (const struct
TALER_TESTING_Command *cmd,
* @return #GNUNET_OK on success.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_account_pub (unsigned int index,
- const struct SYNC_AccountPublicKeyP *h);
+SYNC_TESTING_make_trait_account_pub (unsigned int index,
+ const struct SYNC_AccountPublicKeyP *h);
/**
@@ -116,9 +116,9 @@ SYNC_TESTING_get_trait_account_priv (const struct
TALER_TESTING_Command *cmd,
* @return #GNUNET_OK on success.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_account_priv (unsigned int index,
- const struct
- SYNC_AccountPrivateKeyP *priv);
+SYNC_TESTING_make_trait_account_priv (unsigned int index,
+ const struct
+ SYNC_AccountPrivateKeyP *priv);
/**
@@ -132,8 +132,8 @@ TALER_TESTING_make_trait_account_priv (unsigned int index,
* be started.
*/
struct GNUNET_OS_Process *
-TALER_TESTING_run_sync (const char *config_filename,
- const char *sync_url);
+SYNC_TESTING_run_sync (const char *config_filename,
+ const char *sync_url);
/**
@@ -145,7 +145,7 @@ TALER_TESTING_run_sync (const char *config_filename,
* by the caller.
*/
char *
-TALER_TESTING_prepare_sync (const char *config_filename);
+SYNC_TESTING_prepare_sync (const char *config_filename);
/**
diff --git a/src/lib/test_sync_api.c b/src/lib/test_sync_api.c
index 3403127..9f18d39 100644
--- a/src/lib/test_sync_api.c
+++ b/src/lib/test_sync_api.c
@@ -249,6 +249,7 @@ run (void *cls,
fakebank_url);
}
+
int
main (int argc,
char *const *argv)
@@ -271,7 +272,7 @@ main (int argc,
return 77;
if (NULL ==
- (sync_url = TALER_TESTING_prepare_sync (CONFIG_FILE)))
+ (sync_url = SYNC_TESTING_prepare_sync (CONFIG_FILE)))
return 77;
TALER_TESTING_cleanup_files (CONFIG_FILE);
@@ -293,7 +294,7 @@ main (int argc,
return 1;
if (NULL == (syncd =
- TALER_TESTING_run_sync (CONFIG_FILE, sync_url)))
+ SYNC_TESTING_run_sync (CONFIG_FILE, sync_url)))
return 1;
ret = TALER_TESTING_setup_with_exchange (&run,
@@ -319,4 +320,5 @@ main (int argc,
return 0;
}
+
/* end of test_sync_api.c */
diff --git a/src/lib/test_sync_api_home/.local/share/taler/auditors/auditor.out
b/src/lib/test_sync_api_home/.local/share/taler/auditors/auditor.out
deleted file mode 100644
index a15de52..0000000
Binary files
a/src/lib/test_sync_api_home/.local/share/taler/auditors/auditor.out and
/dev/null differ
diff --git a/src/lib/testing_api_cmd_backup_upload.c
b/src/lib/testing_api_cmd_backup_upload.c
index 6880205..9809942 100644
--- a/src/lib/testing_api_cmd_backup_upload.c
+++ b/src/lib/testing_api_cmd_backup_upload.c
@@ -26,6 +26,7 @@
#include "sync_testing_lib.h"
#include <taler/taler_util.h>
#include <taler/taler_testing_lib.h>
+#include "sync_testing_lib.h"
/**
* State for a "backup upload" CMD.
@@ -136,9 +137,56 @@ backup_upload_cb (void *cls,
TALER_TESTING_interpreter_fail (bus->is);
return;
}
-
- // FIXME: check ud, store result!
-
+ if (NULL != ud)
+ {
+ switch (ud->us)
+ {
+ case SYNC_US_SUCCESS:
+ if (0 != GNUNET_memcmp (&bus->curr_hash,
+ ud->details.curr_backup_hash))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (bus->is);
+ return;
+ }
+ break;
+ case SYNC_US_PAYMENT_REQUIRED:
+ bus->payment_order_id = GNUNET_strdup (ud->details.payment_request);
+ break;
+ case SYNC_US_CONFLICTING_BACKUP:
+ {
+ const struct TALER_TESTING_Command *ref;
+ const struct GNUNET_HashCode *h;
+
+ ref = TALER_TESTING_interpreter_lookup_command
+ (bus->is,
+ bus->prev_upload);
+ GNUNET_assert (NULL != ref);
+ GNUNET_assert (GNUNET_OK ==
+ SYNC_TESTING_get_trait_hash (ref,
+
SYNC_TESTING_TRAIT_HASH_CURRENT,
+ &h));
+ if (0 != GNUNET_memcmp (h,
+ &ud->details.recovered_backup.
+ existing_backup_hash))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (bus->is);
+ return;
+ }
+ }
+ case SYNC_US_HTTP_ERROR:
+ break;
+ case SYNC_US_CLIENT_ERROR:
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (bus->is);
+ return;
+ case SYNC_US_SERVER_ERROR:
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (bus->is);
+ return;
+ }
+ }
TALER_TESTING_interpreter_next (bus->is);
}
@@ -161,7 +209,6 @@ backup_upload_run (void *cls,
if (NULL != bus->prev_upload)
{
const struct TALER_TESTING_Command *ref;
- const struct BackupUploadState *prev;
ref = TALER_TESTING_interpreter_lookup_command
(is,
@@ -172,19 +219,62 @@ backup_upload_run (void *cls,
TALER_TESTING_interpreter_fail (bus->is);
return;
}
- if (ref->run != &backup_upload_run)
{
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (bus->is);
- return;
+ const struct GNUNET_HashCode *h;
+
+ if (GNUNET_OK !=
+ SYNC_TESTING_get_trait_hash (ref,
+ SYNC_TESTING_TRAIT_HASH_CURRENT,
+ &h))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (bus->is);
+ return;
+ }
+ bus->prev_hash = *h;
+ }
+ {
+ const struct SYNC_AccountPrivateKeyP *priv;
+
+ if (GNUNET_OK !=
+ SYNC_TESTING_get_trait_account_priv (ref,
+ 0,
+ &priv))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (bus->is);
+ return;
+ }
+ bus->sync_priv = *priv;
+ }
+ {
+ const struct SYNC_AccountPublicKeyP *pub;
+
+ if (GNUNET_OK !=
+ SYNC_TESTING_get_trait_account_pub (ref,
+ 0,
+ &pub))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (bus->is);
+ return;
+ }
+ bus->sync_pub = *pub;
}
- prev = ref->cls;
- bus->sync_priv = prev->sync_priv;
- bus->sync_pub = prev->sync_pub;
- bus->prev_hash = prev->curr_hash;
if (0 != (SYNC_TESTING_UO_REFERENCE_ORDER_ID & bus->uopt))
{
- bus->payment_order_req = prev->payment_order_id;
+ const char *order_id;
+
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_order_id (ref,
+ 0,
+ &order_id))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (bus->is);
+ return;
+ }
+ bus->payment_order_req = order_id;
if (NULL == bus->payment_order_req)
{
GNUNET_break (0);
@@ -255,6 +345,43 @@ backup_upload_cleanup (void *cls,
}
+/**
+ * Offer internal data to other commands.
+ *
+ * @param cls closure
+ * @param ret[out] result (could be anything)
+ * @param trait name of the trait
+ * @param index index number of the object to extract.
+ * @return #GNUNET_OK on success
+ */
+static int
+backup_upload_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
+{
+ struct BackupUploadState *bus = cls;
+ struct TALER_TESTING_Trait traits[] = {
+ SYNC_TESTING_make_trait_hash (SYNC_TESTING_TRAIT_HASH_CURRENT,
+ &bus->curr_hash),
+ SYNC_TESTING_make_trait_hash (SYNC_TESTING_TRAIT_HASH_PREVIOUS,
+ &bus->prev_hash),
+ SYNC_TESTING_make_trait_account_pub (0,
+ &bus->sync_pub),
+ SYNC_TESTING_make_trait_account_priv (0,
+ &bus->sync_priv),
+ TALER_TESTING_make_trait_order_id (0,
+ bus->payment_order_id),
+ TALER_TESTING_trait_end ()
+ };
+
+ return TALER_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
+}
+
+
/**
* Make the "backup upload" command.
*
@@ -288,14 +415,13 @@ SYNC_TESTING_cmd_backup_upload (const char *label,
bus->sync_url = sync_url;
bus->backup = backup_data;
bus->backup_size = backup_data_size;
- // FIXME: traits!
-
{
struct TALER_TESTING_Command cmd = {
.cls = bus,
.label = label,
.run = &backup_upload_run,
- .cleanup = &backup_upload_cleanup
+ .cleanup = &backup_upload_cleanup,
+ .traits = &backup_upload_traits
};
return cmd;
diff --git a/src/lib/testing_api_helpers.c b/src/lib/testing_api_helpers.c
index a55b038..7b6e6ad 100644
--- a/src/lib/testing_api_helpers.c
+++ b/src/lib/testing_api_helpers.c
@@ -39,8 +39,8 @@
* be started.
*/
struct GNUNET_OS_Process *
-TALER_TESTING_run_sync (const char *config_filename,
- const char *sync_url)
+SYNC_TESTING_run_sync (const char *config_filename,
+ const char *sync_url)
{
struct GNUNET_OS_Process *sync_proc;
unsigned int iter;
@@ -104,7 +104,7 @@ TALER_TESTING_run_sync (const char *config_filename,
* by the caller.
*/
char *
-TALER_TESTING_prepare_sync (const char *config_filename)
+SYNC_TESTING_prepare_sync (const char *config_filename)
{
struct GNUNET_CONFIGURATION_Handle *cfg;
unsigned long long port;
diff --git a/src/lib/testing_api_trait_account_priv.c
b/src/lib/testing_api_trait_account_priv.c
index 213ca34..b8bfb5b 100644
--- a/src/lib/testing_api_trait_account_priv.c
+++ b/src/lib/testing_api_trait_account_priv.c
@@ -57,7 +57,7 @@ SYNC_TESTING_get_trait_account_priv
* @return #GNUNET_OK on success.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_account_priv
+SYNC_TESTING_make_trait_account_priv
(unsigned int index,
const struct SYNC_AccountPrivateKeyP *priv)
{
diff --git a/src/lib/testing_api_trait_account_pub.c
b/src/lib/testing_api_trait_account_pub.c
index f5bbdeb..9fecb18 100644
--- a/src/lib/testing_api_trait_account_pub.c
+++ b/src/lib/testing_api_trait_account_pub.c
@@ -57,7 +57,7 @@ SYNC_TESTING_get_trait_account_pub
* @return #GNUNET_OK on success.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_account_pub
+SYNC_TESTING_make_trait_account_pub
(unsigned int index,
const struct SYNC_AccountPublicKeyP *h)
{
diff --git a/src/lib/testing_api_trait_hash.c b/src/lib/testing_api_trait_hash.c
index 810174d..10b10d8 100644
--- a/src/lib/testing_api_trait_hash.c
+++ b/src/lib/testing_api_trait_hash.c
@@ -57,7 +57,7 @@ SYNC_TESTING_get_trait_hash
* @return #GNUNET_OK on success.
*/
struct TALER_TESTING_Trait
-TALER_TESTING_make_trait_hash
+SYNC_TESTING_make_trait_hash
(unsigned int index,
const struct GNUNET_HashCode *h)
{
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [taler-sync] branch master updated (399392b -> d92b7d9),
gnunet <=