summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_backup_upload.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_backup_upload.c')
-rw-r--r--src/testing/testing_api_cmd_backup_upload.c185
1 files changed, 83 insertions, 102 deletions
diff --git a/src/testing/testing_api_cmd_backup_upload.c b/src/testing/testing_api_cmd_backup_upload.c
index d2c3851..3de4db8 100644
--- a/src/testing/testing_api_cmd_backup_upload.c
+++ b/src/testing/testing_api_cmd_backup_upload.c
@@ -1,6 +1,6 @@
/*
This file is part of SYNC
- Copyright (C) 2014-2019 Taler Systems SA
+ Copyright (C) 2014-2023 Taler Systems SA
SYNC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -17,7 +17,7 @@
<http://www.gnu.org/licenses/>
*/
/**
- * @file lib/testing_api_cmd_backup_upload.c
+ * @file testing/testing_api_cmd_backup_upload.c
* @brief command to upload data to the sync backend service.
* @author Christian Grothoff
*/
@@ -126,100 +126,90 @@ struct BackupUploadState
* Function called with the results of a #SYNC_upload().
*
* @param cls closure
- * @param ec Taler error code
- * @param http_status HTTP status of the request
* @param ud details about the upload operation
*/
static void
backup_upload_cb (void *cls,
- enum TALER_ErrorCode ec,
- unsigned int http_status,
const struct SYNC_UploadDetails *ud)
{
struct BackupUploadState *bus = cls;
bus->uo = NULL;
- if (http_status != bus->http_status)
+ if (ud->http_status != bus->http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- http_status,
- bus->is->commands[bus->is->ip].label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (bus->is);
+ TALER_TESTING_unexpected_status (bus->is,
+ ud->http_status,
+ bus->http_status);
return;
}
- if (NULL != ud)
+ switch (ud->us)
{
- switch (ud->us)
+ case SYNC_US_SUCCESS:
+ if (0 != GNUNET_memcmp (
+ &bus->curr_hash,
+ ud->details.success.curr_backup_hash))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (bus->is);
+ return;
+ }
+ break;
+ case SYNC_US_PAYMENT_REQUIRED:
{
- case SYNC_US_SUCCESS:
- if (0 != GNUNET_memcmp (&bus->curr_hash,
- ud->details.curr_backup_hash))
+ struct TALER_MERCHANT_PayUriData pd;
+
+ if (GNUNET_OK !=
+ TALER_MERCHANT_parse_pay_uri (
+ ud->details.payment_required.payment_request,
+ &pd))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (bus->is);
return;
}
- break;
- case SYNC_US_PAYMENT_REQUIRED:
- {
- struct TALER_MERCHANT_PayUriData pd;
-
- if (GNUNET_OK !=
- TALER_MERCHANT_parse_pay_uri (ud->details.payment_request,
- &pd))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (bus->is);
- return;
- }
- bus->payment_order_id = GNUNET_strdup (pd.order_id);
- if (NULL != pd.claim_token)
- bus->token = *pd.claim_token;
- TALER_MERCHANT_parse_pay_uri_free (&pd);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Order ID from Sync service is `%s'\n",
- bus->payment_order_id);
- memset (&bus->curr_hash,
- 0,
- sizeof (struct GNUNET_HashCode));
- }
- break;
- case SYNC_US_CONFLICTING_BACKUP:
+ bus->payment_order_id = GNUNET_strdup (pd.order_id);
+ if (NULL != pd.claim_token)
+ bus->token = *pd.claim_token;
+ TALER_MERCHANT_parse_pay_uri_free (&pd);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Order ID from Sync service is `%s'\n",
+ bus->payment_order_id);
+ memset (&bus->curr_hash,
+ 0,
+ sizeof (struct GNUNET_HashCode));
+ }
+ 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->last_upload);
+ GNUNET_assert (NULL != ref);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_curr_hash (ref,
+ &h));
+ if (0 != GNUNET_memcmp (h,
+ &ud->details.recovered_backup.
+ existing_backup_hash))
{
- const struct TALER_TESTING_Command *ref;
- const struct GNUNET_HashCode *h;
-
- ref = TALER_TESTING_interpreter_lookup_command
- (bus->is,
- bus->last_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;
- }
+ 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;
}
+ 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);
}
@@ -257,9 +247,8 @@ backup_upload_run (void *cls,
const struct GNUNET_HashCode *h;
if (GNUNET_OK ==
- SYNC_TESTING_get_trait_hash (ref,
- SYNC_TESTING_TRAIT_HASH_CURRENT,
- &h))
+ TALER_TESTING_get_trait_curr_hash (ref,
+ &h))
{
bus->prev_hash = *h;
}
@@ -268,9 +257,8 @@ backup_upload_run (void *cls,
const struct SYNC_AccountPrivateKeyP *priv;
if (GNUNET_OK !=
- SYNC_TESTING_get_trait_account_priv (ref,
- 0,
- &priv))
+ TALER_TESTING_get_trait_account_priv (ref,
+ &priv))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (bus->is);
@@ -282,9 +270,8 @@ backup_upload_run (void *cls,
const struct SYNC_AccountPublicKeyP *pub;
if (GNUNET_OK !=
- SYNC_TESTING_get_trait_account_pub (ref,
- 0,
- &pub))
+ TALER_TESTING_get_trait_account_pub (ref,
+ &pub))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (bus->is);
@@ -294,7 +281,7 @@ backup_upload_run (void *cls,
}
if (0 != (SYNC_TESTING_UO_REFERENCE_ORDER_ID & bus->uopt))
{
- const char **order_id;
+ const char *order_id;
if (GNUNET_OK !=
TALER_TESTING_get_trait_order_id (ref,
@@ -304,7 +291,7 @@ backup_upload_run (void *cls,
TALER_TESTING_interpreter_fail (bus->is);
return;
}
- bus->payment_order_req = *order_id;
+ bus->payment_order_req = order_id;
if (NULL == bus->payment_order_req)
{
GNUNET_break (0);
@@ -326,7 +313,7 @@ backup_upload_run (void *cls,
GNUNET_CRYPTO_hash (bus->backup,
bus->backup_size,
&bus->curr_hash);
- bus->uo = SYNC_upload (is->ctx,
+ bus->uo = SYNC_upload (TALER_TESTING_interpreter_get_context (is),
bus->sync_url,
&bus->sync_priv,
( ( (NULL != bus->prev_upload) &&
@@ -382,12 +369,12 @@ backup_upload_cleanup (void *cls,
* Offer internal data to other commands.
*
* @param cls closure
- * @param ret[out] result (could be anything)
+ * @param[out] ret 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
+static enum GNUNET_GenericReturnValue
backup_upload_traits (void *cls,
const void **ret,
const char *trait,
@@ -395,25 +382,19 @@ backup_upload_traits (void *cls,
{
struct BackupUploadState *bus = cls;
struct TALER_TESTING_Trait straits[] = {
- 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),
+ TALER_TESTING_make_trait_curr_hash (&bus->curr_hash),
+ TALER_TESTING_make_trait_prev_hash (&bus->prev_hash),
TALER_TESTING_make_trait_claim_token (&bus->token),
- 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 (&bus->payment_order_id),
+ TALER_TESTING_make_trait_account_pub (&bus->sync_pub),
+ TALER_TESTING_make_trait_account_priv (&bus->sync_priv),
+ TALER_TESTING_make_trait_order_id (bus->payment_order_id),
TALER_TESTING_trait_end ()
};
struct TALER_TESTING_Trait ftraits[] = {
TALER_TESTING_make_trait_claim_token (&bus->token),
- 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 (&bus->payment_order_id),
+ TALER_TESTING_make_trait_account_pub (&bus->sync_pub),
+ TALER_TESTING_make_trait_account_priv (&bus->sync_priv),
+ TALER_TESTING_make_trait_order_id (bus->payment_order_id),
TALER_TESTING_trait_end ()
};