commit b06c4429d1ea419086b33e149b56dbf32ada3cf2
parent 7f8aa4ae77ba01de45ea323ea4c89065577cac1b
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 18 Feb 2024 15:51:10 +0100
-get rid of legacy trait style code
Diffstat:
7 files changed, 37 insertions(+), 346 deletions(-)
diff --git a/src/include/sync_testing_lib.h b/src/include/sync_testing_lib.h
@@ -29,97 +29,6 @@
#include <taler/taler_testing_lib.h>
#include <microhttpd.h>
-/**
- * Index used in #SYNC_TESTING_get_trait_hash() for the current hash.
- */
-#define SYNC_TESTING_TRAIT_HASH_CURRENT 0
-
-/**
- * Index used in #SYNC_TESTING_get_trait_hash() for the previous hash.
- */
-#define SYNC_TESTING_TRAIT_HASH_PREVIOUS 1
-
-
-/**
- * Obtain a hash from @a cmd.
- *
- * @param cmd command to extract the number from.
- * @param index the number's index number, #SYNC_TESTING_TRAIT_HASH_CURRENT or
- * #SYNC_TESTING_TRAIT_HASH_PREVIOUS
- * @param h[out] set to the hash coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-SYNC_TESTING_get_trait_hash (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct GNUNET_HashCode **h);
-
-
-/**
- * Offer a hash.
- *
- * @param index the number's index number.
- * @param h the hash to offer.
- * @return #GNUNET_OK on success.
- */
-struct TALER_TESTING_Trait
-SYNC_TESTING_make_trait_hash (unsigned int index,
- const struct GNUNET_HashCode *h);
-
-
-/**
- * Obtain an account public key from @a cmd.
- *
- * @param cmd command to extract the public key from.
- * @param index usually 0
- * @param pub[out] set to the account public key used in @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-SYNC_TESTING_get_trait_account_pub (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct SYNC_AccountPublicKeyP **pub);
-
-
-/**
- * Offer an account public key.
- *
- * @param index usually zero
- * @param h the account_pub to offer.
- * @return #GNUNET_OK on success.
- */
-struct TALER_TESTING_Trait
-SYNC_TESTING_make_trait_account_pub (unsigned int index,
- const struct SYNC_AccountPublicKeyP *h);
-
-
-/**
- * Obtain an account private key from @a cmd.
- *
- * @param cmd command to extract the number from.
- * @param index must be 0
- * @param priv[out] set to the account private key used in @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-SYNC_TESTING_get_trait_account_priv (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct
- SYNC_AccountPrivateKeyP **priv);
-
-
-/**
- * Offer an account private key.
- *
- * @param index usually zero
- * @param priv the account_priv to offer.
- * @return #GNUNET_OK on success.
- */
-struct TALER_TESTING_Trait
-SYNC_TESTING_make_trait_account_priv (unsigned int index,
- const struct
- SYNC_AccountPrivateKeyP *priv);
-
/**
* Start the sync backend process. Assume the port
@@ -234,4 +143,20 @@ SYNC_TESTING_cmd_backup_upload (const char *label,
const void *backup_data,
size_t backup_data_size);
+/**
+ * Call @a op on all simple traits.
+ *
+ * @param op macro to call
+ */
+#define SYNC_TESTING_SIMPLE_TRAITS(op) \
+ op (account_pub, const struct SYNC_AccountPublicKeyP) \
+ op (account_priv, const struct SYNC_AccountPrivateKeyP) \
+ op (prev_hash, const struct GNUNET_HashCode) \
+ op (curr_hash, const struct GNUNET_HashCode)
+
+
+/* FIXME: eventually switch to libgnunettesting with the SYNC_ prefix for
+ the symbols instead of TALER_TESTING_! */
+SYNC_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT)
+
#endif
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
@@ -16,9 +16,7 @@ libsynctesting_la_SOURCES = \
testing_api_cmd_backup_download.c \
testing_api_cmd_backup_upload.c \
testing_api_helpers.c \
- testing_api_trait_account_pub.c \
- testing_api_trait_account_priv.c \
- testing_api_trait_hash.c
+ testing_api_traits.c
libsynctesting_la_LIBADD = \
$(top_builddir)/src/lib/libsync.la \
-ltalermerchant \
diff --git a/src/testing/testing_api_cmd_backup_download.c b/src/testing/testing_api_cmd_backup_download.c
@@ -149,27 +149,24 @@ backup_download_run (void *cls,
return;
}
if (GNUNET_OK !=
- SYNC_TESTING_get_trait_hash (upload_cmd,
- SYNC_TESTING_TRAIT_HASH_CURRENT,
- &bds->upload_hash))
+ TALER_TESTING_get_trait_curr_hash (upload_cmd,
+ &bds->upload_hash))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (bds->is);
return;
}
if (GNUNET_OK !=
- SYNC_TESTING_get_trait_hash (upload_cmd,
- SYNC_TESTING_TRAIT_HASH_PREVIOUS,
- &bds->prev_upload_hash))
+ TALER_TESTING_get_trait_prev_hash (upload_cmd,
+ &bds->prev_upload_hash))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (bds->is);
return;
}
if (GNUNET_OK !=
- SYNC_TESTING_get_trait_account_pub (upload_cmd,
- 0,
- &sync_pub))
+ TALER_TESTING_get_trait_account_pub (upload_cmd,
+ &sync_pub))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (bds->is);
diff --git a/src/testing/testing_api_cmd_backup_upload.c b/src/testing/testing_api_cmd_backup_upload.c
@@ -189,9 +189,8 @@ backup_upload_cb (void *cls,
bus->last_upload);
GNUNET_assert (NULL != ref);
GNUNET_assert (GNUNET_OK ==
- SYNC_TESTING_get_trait_hash (ref,
- SYNC_TESTING_TRAIT_HASH_CURRENT,
- &h));
+ TALER_TESTING_get_trait_curr_hash (ref,
+ &h));
if (0 != GNUNET_memcmp (h,
&ud->details.recovered_backup.
existing_backup_hash))
@@ -248,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;
}
@@ -259,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);
@@ -273,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);
@@ -386,24 +382,18 @@ 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_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_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 ()
};
diff --git a/src/testing/testing_api_trait_account_priv.c b/src/testing/testing_api_trait_account_priv.c
@@ -1,73 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- TALER is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Privlic License for more details.
-
- You should have received a copy of the GNU General Privlic
- License along with TALER; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file lib/testing_api_trait_account_priv.c
- * @brief traits to offer a account_priv
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "sync_service.h"
-#include "sync_testing_lib.h"
-
-#define SYNC_TESTING_TRAIT_ACCOUNT_PRIV "sync-account_priv"
-
-
-/**
- * Obtain an account private key from @a cmd.
- *
- * @param cmd command to extract the private key from.
- * @param index the private key's index number.
- * @param n[out] set to the private key coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-SYNC_TESTING_get_trait_account_priv
- (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct SYNC_AccountPrivateKeyP **priv)
-{
- return cmd->traits (cmd->cls,
- (const void **) priv,
- SYNC_TESTING_TRAIT_ACCOUNT_PRIV,
- index);
-}
-
-
-/**
- * Offer an account private key.
- *
- * @param index usually zero
- * @param priv the account_priv to offer.
- * @return #GNUNET_OK on success.
- */
-struct TALER_TESTING_Trait
-SYNC_TESTING_make_trait_account_priv
- (unsigned int index,
- const struct SYNC_AccountPrivateKeyP *priv)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = SYNC_TESTING_TRAIT_ACCOUNT_PRIV,
- .ptr = (const void *) priv
- };
- return ret;
-}
-
-
-/* end of testing_api_trait_account_priv.c */
diff --git a/src/testing/testing_api_trait_account_pub.c b/src/testing/testing_api_trait_account_pub.c
@@ -1,73 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- TALER is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with TALER; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file lib/testing_api_trait_account_pub.c
- * @brief traits to offer a account_pub
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "sync_service.h"
-#include "sync_testing_lib.h"
-
-#define SYNC_TESTING_TRAIT_ACCOUNT_PUB "sync-account_pub"
-
-
-/**
- * Obtain an account public key from @a cmd.
- *
- * @param cmd command to extract the public key from.
- * @param index the public key's index number.
- * @param n[out] set to the public key coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-SYNC_TESTING_get_trait_account_pub
- (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct SYNC_AccountPublicKeyP **pub)
-{
- return cmd->traits (cmd->cls,
- (const void **) pub,
- SYNC_TESTING_TRAIT_ACCOUNT_PUB,
- index);
-}
-
-
-/**
- * Offer an account public key.
- *
- * @param index usually zero
- * @param h the account_pub to offer.
- * @return #GNUNET_OK on success.
- */
-struct TALER_TESTING_Trait
-SYNC_TESTING_make_trait_account_pub
- (unsigned int index,
- const struct SYNC_AccountPublicKeyP *h)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = SYNC_TESTING_TRAIT_ACCOUNT_PUB,
- .ptr = (const void *) h
- };
- return ret;
-}
-
-
-/* end of testing_api_trait_account_pub.c */
diff --git a/src/testing/testing_api_trait_hash.c b/src/testing/testing_api_trait_hash.c
@@ -1,73 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- TALER is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with TALER; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file lib/testing_api_trait_hash.c
- * @brief traits to offer a hash
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "sync_service.h"
-#include "sync_testing_lib.h"
-
-#define SYNC_TESTING_TRAIT_HASH "sync-hash"
-
-
-/**
- * Obtain a hash from @a cmd.
- *
- * @param cmd command to extract the number from.
- * @param index the number's index number.
- * @param n[out] set to the number coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-SYNC_TESTING_get_trait_hash
- (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct GNUNET_HashCode **h)
-{
- return cmd->traits (cmd->cls,
- (const void **) h,
- SYNC_TESTING_TRAIT_HASH,
- index);
-}
-
-
-/**
- * Offer a hash.
- *
- * @param index the number's index number.
- * @param h the hash to offer.
- * @return #GNUNET_OK on success.
- */
-struct TALER_TESTING_Trait
-SYNC_TESTING_make_trait_hash
- (unsigned int index,
- const struct GNUNET_HashCode *h)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = SYNC_TESTING_TRAIT_HASH,
- .ptr = (const void *) h
- };
- return ret;
-}
-
-
-/* end of testing_api_trait_hash.c */