summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-02-27 22:22:18 +0100
committerChristian Grothoff <christian@grothoff.org>2018-02-27 22:22:18 +0100
commitcfab4194f08af08227d33d768d3e2001434bb6cd (patch)
tree46168872a1e9e85020eb2b104ea9f2aa0c38f7e7
parenta3c72985155a162dce431b33601e330100e325c2 (diff)
downloadexchange-cfab4194f08af08227d33d768d3e2001434bb6cd.tar.gz
exchange-cfab4194f08af08227d33d768d3e2001434bb6cd.tar.bz2
exchange-cfab4194f08af08227d33d768d3e2001434bb6cd.zip
use more 'static' where applicable, use GNUNET_log instead of fprintf
-rw-r--r--src/exchange-lib/testing_api_cmd_check_keys.c18
-rw-r--r--src/exchange-lib/testing_api_cmd_signal.c10
-rw-r--r--src/exchange-lib/testing_api_cmd_status.c23
3 files changed, 26 insertions, 25 deletions
diff --git a/src/exchange-lib/testing_api_cmd_check_keys.c b/src/exchange-lib/testing_api_cmd_check_keys.c
index 8f77a83b4..b14740e40 100644
--- a/src/exchange-lib/testing_api_cmd_check_keys.c
+++ b/src/exchange-lib/testing_api_cmd_check_keys.c
@@ -48,6 +48,7 @@ struct CheckKeysState
};
+
/**
* Run the command.
*
@@ -55,7 +56,7 @@ struct CheckKeysState
* @param cmd the command to execute, a /wire one.
* @param is the interpreter state.
*/
-void
+static void
check_keys_run (void *cls,
const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is)
@@ -92,8 +93,10 @@ check_keys_run (void *cls,
{
/* Did not get the expected number of denomination keys! */
GNUNET_break (0);
- fprintf (stderr, "Got %u keys in step %s\n",
- is->keys->num_denom_keys, cmd->label);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got %u keys in step %s\n",
+ is->keys->num_denom_keys,
+ cmd->label);
TALER_TESTING_interpreter_fail (is);
return;
}
@@ -107,7 +110,7 @@ check_keys_run (void *cls,
* @param cls closure, typically a #struct SignalState.
* @param cmd the command which is being cleaned up.
*/
-void
+static void
check_keys_cleanup (void *cls,
const struct TALER_TESTING_Command *cmd)
{
@@ -116,6 +119,7 @@ check_keys_cleanup (void *cls,
GNUNET_free (cks);
}
+
/**
* Make a "check keys" command.
*
@@ -132,22 +136,16 @@ TALER_TESTING_cmd_check_keys
unsigned int num_denom_keys,
struct TALER_EXCHANGE_Handle *exchange)
{
-
struct CheckKeysState *cks;
struct TALER_TESTING_Command cmd;
cks = GNUNET_new (struct CheckKeysState);
-
cks->generation = generation;
cks->num_denom_keys = num_denom_keys;
cks->exchange = exchange;
-
cmd.cls = cks;
cmd.label = label;
cmd.run = &check_keys_run;
cmd.cleanup = &check_keys_cleanup;
-
return cmd;
-
-
}
diff --git a/src/exchange-lib/testing_api_cmd_signal.c b/src/exchange-lib/testing_api_cmd_signal.c
index 5b0fa1b9d..cf07f05f5 100644
--- a/src/exchange-lib/testing_api_cmd_signal.c
+++ b/src/exchange-lib/testing_api_cmd_signal.c
@@ -16,13 +16,11 @@
License along with TALER; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>
*/
-
/**
* @file exchange-lib/testing_api_cmd_signal.c
* @brief command(s) to send signals to processes.
* @author Marcello Stanisci
*/
-
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
@@ -43,6 +41,7 @@ struct SignalState
};
+
/**
* Run the command.
*
@@ -50,7 +49,7 @@ struct SignalState
* @param cmd the command to execute, a /wire one.
* @param is the interpreter state.
*/
-void
+static void
signal_run (void *cls,
const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is)
@@ -73,7 +72,7 @@ signal_run (void *cls,
* @param cls closure, typically a #struct SignalState.
* @param cmd the command which is being cleaned up.
*/
-void
+static void
signal_cleanup (void *cls,
const struct TALER_TESTING_Command *cmd)
{
@@ -82,6 +81,7 @@ signal_cleanup (void *cls,
GNUNET_free (ss);
}
+
/**
* Send a signal to a process.
*
@@ -99,10 +99,8 @@ TALER_TESTING_cmd_signal (const char *label,
struct TALER_TESTING_Command cmd;
ss = GNUNET_new (struct SignalState);
-
ss->process = process;
ss->signal = signal;
-
cmd.cls = ss;
cmd.label = label;
cmd.run = &signal_run;
diff --git a/src/exchange-lib/testing_api_cmd_status.c b/src/exchange-lib/testing_api_cmd_status.c
index c948277b5..2107b753a 100644
--- a/src/exchange-lib/testing_api_cmd_status.c
+++ b/src/exchange-lib/testing_api_cmd_status.c
@@ -16,13 +16,11 @@
License along with TALER; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>
*/
-
/**
* @file exchange/testing_api_cmd_status.c
* @brief Implement the /reserve/status test command.
* @author Marcello Stanisci
*/
-
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
@@ -35,7 +33,7 @@ struct StatusState
* Label to the command which created the reserve to check,
* needed to resort the reserve key.
*/
- const char *reserve_reference;
+ const char *reserve_reference;
/**
* Handle to a /reserve/status operation.
@@ -63,6 +61,7 @@ struct StatusState
struct TALER_TESTING_Interpreter *is;
};
+
/**
* Check exchange returned expected values.
*
@@ -78,7 +77,7 @@ struct StatusState
* history, 0 on error
* @param history detailed transaction history, NULL on error
*/
-void
+static void
reserve_status_cb
(void *cls,
unsigned int http_status,
@@ -90,7 +89,7 @@ reserve_status_cb
{
struct StatusState *ss = cls;
struct TALER_Amount eb;
-
+
ss->rsh = NULL;
if (ss->expected_response_code != http_status)
{
@@ -123,11 +122,17 @@ reserve_status_cb
* of the array returned by "/reserve/status" and checks if that
* element correspond to itself (= the command exposing the check-
* method).
+ *
+ * IDEA: Maybe realize this via another trait, some kind of
+ * "reserve history update trait" which returns information about
+ * how the command changes the history (provided only by commands
+ * that change reserve balances)?
*/
TALER_TESTING_interpreter_next (ss->is);
}
+
/**
* Run the command.
*
@@ -135,12 +140,11 @@ reserve_status_cb
* @param cmd the command to execute, a /wire one.
* @param i the interpreter state.
*/
-void
+static void
status_run (void *cls,
const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is)
{
-
struct StatusState *ss = cls;
const struct TALER_TESTING_Command *create_reserve;
struct TALER_ReservePrivateKeyP *reserve_priv;
@@ -170,7 +174,7 @@ status_run (void *cls,
return;
}
- GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
+ GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
&reserve_pub.eddsa_pub);
ss->rsh
= TALER_EXCHANGE_reserve_status (ss->exchange,
@@ -179,13 +183,14 @@ status_run (void *cls,
ss);
}
+
/**
* Cleanup the state.
*
* @param cls closure, typically a #struct WireState.
* @param cmd the command which is being cleaned up.
*/
-void
+static void
status_cleanup (void *cls,
const struct TALER_TESTING_Command *cmd)
{