diff options
Diffstat (limited to 'src/bank-lib')
-rw-r--r-- | src/bank-lib/bank_api_admin.c | 9 | ||||
-rw-r--r-- | src/bank-lib/bank_api_common.c | 2 | ||||
-rw-r--r-- | src/bank-lib/bank_api_history.c | 18 | ||||
-rw-r--r-- | src/bank-lib/bank_api_parse.c | 5 | ||||
-rw-r--r-- | src/bank-lib/bank_api_reject.c | 4 | ||||
-rw-r--r-- | src/bank-lib/fakebank.c | 57 | ||||
-rw-r--r-- | src/bank-lib/fakebank.h | 15 | ||||
-rw-r--r-- | src/bank-lib/fakebank_history.c | 55 | ||||
-rw-r--r-- | src/bank-lib/taler-bank-transfer.c | 76 | ||||
-rw-r--r-- | src/bank-lib/taler-fakebank-run.c | 8 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api.c | 38 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api_new.c | 80 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api_twisted.c | 10 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api_with_fakebank.c | 8 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api_with_fakebank_new.c | 80 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api_with_fakebank_twisted.c | 8 | ||||
-rw-r--r-- | src/bank-lib/test_bank_interpreter.c | 77 | ||||
-rw-r--r-- | src/bank-lib/test_bank_interpreter.h | 9 | ||||
-rw-r--r-- | src/bank-lib/testing_api_cmd_history.c | 162 | ||||
-rw-r--r-- | src/bank-lib/testing_api_cmd_reject.c | 10 | ||||
-rw-r--r-- | src/bank-lib/testing_api_helpers.c | 78 |
21 files changed, 416 insertions, 393 deletions
diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c index 4a66d3293..72b1d773e 100644 --- a/src/bank-lib/bank_api_admin.c +++ b/src/bank-lib/bank_api_admin.c @@ -94,7 +94,7 @@ handle_admin_add_incoming_finished (void *cls, &row_id), GNUNET_JSON_spec_absolute_time ("timestamp", ×tamp), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -217,8 +217,8 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx, GNUNET_assert (NULL != (aai->post_ctx.headers = curl_slist_append - (aai->post_ctx.headers, - "Content-Type: application/json"))); + (aai->post_ctx.headers, + "Content-Type: application/json"))); eh = curl_easy_init (); @@ -248,7 +248,8 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx, * @param aai the admin add incoming request handle */ void -TALER_BANK_admin_add_incoming_cancel (struct TALER_BANK_AdminAddIncomingHandle *aai) +TALER_BANK_admin_add_incoming_cancel (struct + TALER_BANK_AdminAddIncomingHandle *aai) { if (NULL != aai->job) { diff --git a/src/bank-lib/bank_api_common.c b/src/bank-lib/bank_api_common.c index ad1160073..50769dae2 100644 --- a/src/bank-lib/bank_api_common.c +++ b/src/bank-lib/bank_api_common.c @@ -130,7 +130,7 @@ TALER_BANK_parse_ec_ (const json_t *json) struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_uint32 ("ec", &ec), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != diff --git a/src/bank-lib/bank_api_history.c b/src/bank-lib/bank_api_history.c index 36e5724d0..6bc53cd50 100644 --- a/src/bank-lib/bank_api_history.c +++ b/src/bank-lib/bank_api_history.c @@ -88,7 +88,7 @@ parse_account_history (struct TALER_BANK_HistoryHandle *hh, GNUNET_break_op (0); return GNUNET_SYSERR; } - for (unsigned int i=0;i<json_array_size (history_array);i++) + for (unsigned int i = 0; i<json_array_size (history_array); i++) { struct TALER_BANK_TransferDetails td; const char *sign; @@ -108,7 +108,7 @@ parse_account_history (struct TALER_BANK_HistoryHandle *hh, (const char **) &td.wire_transfer_subject), GNUNET_JSON_spec_uint64 ("counterpart", &other_account), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; json_t *transaction = json_array_get (history_array, i); @@ -147,7 +147,7 @@ parse_account_history (struct TALER_BANK_HistoryHandle *hh, bank_hostname += 3; GNUNET_asprintf (&td.account_url, - ('/' == bank_hostname[strlen(bank_hostname)-1]) + ('/' == bank_hostname[strlen (bank_hostname) - 1]) ? "payto://x-taler-bank/%s%llu" : "payto://x-taler-bank/%s/%llu", bank_hostname, @@ -456,12 +456,12 @@ TALER_BANK_history (struct GNUNET_CURL_Context *ctx, if (UINT64_MAX == start_row) GNUNET_asprintf (&url, - "/history?auth=basic&account_number=%llu&delta=%lld&direction=%s&cancelled=%s&ordering=%s", - (unsigned long long) account_number, - (long long) num_results, - conv_direction (direction), - conv_cancel (direction), - (GNUNET_YES == ascending) ? "ascending" : "descending"); + "/history?auth=basic&account_number=%llu&delta=%lld&direction=%s&cancelled=%s&ordering=%s", + (unsigned long long) account_number, + (long long) num_results, + conv_direction (direction), + conv_cancel (direction), + (GNUNET_YES == ascending) ? "ascending" : "descending"); else GNUNET_asprintf (&url, "/history?auth=basic&account_number=%llu&delta=%lld&direction=%s&cancelled=%s&ordering=%s&start=%llu", diff --git a/src/bank-lib/bank_api_parse.c b/src/bank-lib/bank_api_parse.c index 6de9e5e1c..582e2a7dd 100644 --- a/src/bank-lib/bank_api_parse.c +++ b/src/bank-lib/bank_api_parse.c @@ -36,7 +36,8 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, struct TALER_BANK_AuthenticationData *auth) { - const struct { + const struct + { const char *m; enum TALER_BANK_AuthenticationMethod e; } methods[] = { @@ -57,7 +58,7 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, "TALER_BANK_AUTH_METHOD"); return GNUNET_SYSERR; } - for (unsigned int i=0; NULL != methods[i].m;i++) + for (unsigned int i = 0; NULL != methods[i].m; i++) { if (0 == strcasecmp (method, methods[i].m)) diff --git a/src/bank-lib/bank_api_reject.c b/src/bank-lib/bank_api_reject.c index cfedec4cf..3f181bc31 100644 --- a/src/bank-lib/bank_api_reject.c +++ b/src/bank-lib/bank_api_reject.c @@ -194,8 +194,8 @@ TALER_BANK_reject (struct GNUNET_CURL_Context *ctx, } eh = curl_easy_init (); GNUNET_assert (NULL != (rh->json_enc = - json_dumps (reject_obj, - JSON_COMPACT))); + json_dumps (reject_obj, + JSON_COMPACT))); json_decref (reject_obj); GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c index b6aee7f41..19c088d8b 100644 --- a/src/bank-lib/fakebank.c +++ b/src/bank-lib/fakebank.c @@ -30,7 +30,7 @@ /** * Maximum POST request size (for /admin/add/incoming) */ -#define REQUEST_BUFFER_MAX (4*1024) +#define REQUEST_BUFFER_MAX (4 * 1024) /** @@ -318,7 +318,7 @@ create_bank_error (struct MHD_Connection *connection, "ec", (json_int_t) ec); json_str = json_dumps (json, - JSON_INDENT(2)); + JSON_INDENT (2)); json_decref (json); if (NULL == json_str) { @@ -471,7 +471,7 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h, "timestamp", "/Date(0)/"); /*dummy tmp */ json_str = json_dumps (json, - JSON_INDENT(2)); + JSON_INDENT (2)); json_decref (json); if (NULL == json_str) { @@ -574,10 +574,10 @@ handle_reject (struct TALER_FAKEBANK_Handle *h, if (GNUNET_OK != found) return create_bank_error - (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_BANK_REJECT_TRANSACTION_NOT_FOUND, - "transaction unknown"); + (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_BANK_REJECT_TRANSACTION_NOT_FOUND, + "transaction unknown"); /* finally build regular response */ resp = MHD_create_response_from_buffer (0, NULL, @@ -608,9 +608,9 @@ handle_home_page (struct TALER_FAKEBANK_Handle *h, #define HELLOMSG "Hello, Fakebank!" resp = MHD_create_response_from_buffer - (strlen (HELLOMSG), - HELLOMSG, - MHD_RESPMEM_MUST_COPY); + (strlen (HELLOMSG), + HELLOMSG, + MHD_RESPMEM_MUST_COPY); ret = MHD_queue_response (connection, MHD_HTTP_OK, @@ -654,11 +654,11 @@ handle_history (struct TALER_FAKEBANK_Handle *h, MHD_GET_ARGUMENT_KIND, "delta"); if ( ((NULL != start) && (1 != sscanf (start, - "%llu", - &hri.start))) || - (NULL == delta) || (1 != sscanf (delta, - "%lld", - &hri.count)) ) + "%llu", + &hri.start))) || + (NULL == delta) || (1 != sscanf (delta, + "%lld", + &hri.count)) ) { GNUNET_break (0); return MHD_NO; @@ -667,7 +667,7 @@ handle_history (struct TALER_FAKEBANK_Handle *h, if (NULL == start) pos = 0 > hri.count ? - h->transactions_tail : h->transactions_head; + h->transactions_tail : h->transactions_head; else if (NULL != h->transactions_head) { @@ -728,7 +728,7 @@ handle_history_range (struct TALER_FAKEBANK_Handle *h, struct Transaction *pos; if (GNUNET_OK != TFH_parse_history_common_args (connection, - &ha)) + &ha)) { GNUNET_break (0); return MHD_NO; @@ -743,9 +743,9 @@ handle_history_range (struct TALER_FAKEBANK_Handle *h, if ( (NULL == start) || (1 != sscanf (start, "%llu", &start_stamp)) || - (NULL == end) || (1 != sscanf (end, - "%lld", - &end_stamp)) ) + (NULL == end) || (1 != sscanf (end, + "%lld", + &end_stamp)) ) { GNUNET_break (0); return MHD_NO; @@ -875,7 +875,7 @@ schedule_httpd (struct TALER_FAKEBANK_Handle *h) struct GNUNET_TIME_Relative tv; haveto = MHD_get_timeout (h->mhd_bank, - &timeout); + &timeout); if (MHD_YES == haveto) tv.rel_value_us = (uint64_t) timeout * 1000LL; else @@ -884,9 +884,9 @@ schedule_httpd (struct TALER_FAKEBANK_Handle *h) GNUNET_SCHEDULER_cancel (h->mhd_task); h->mhd_task = GNUNET_SCHEDULER_add_read_net (tv, - h->mhd_rfd, - &run_mhd, - h); + h->mhd_rfd, + &run_mhd, + h); } #else /** @@ -981,17 +981,18 @@ TALER_FAKEBANK_start (uint16_t port) h = GNUNET_new (struct TALER_FAKEBANK_Handle); h->mhd_bank = MHD_start_daemon (MHD_USE_DEBUG #if EPOLL_SUPPORT - | MHD_USE_EPOLL_INTERNAL_THREAD + | MHD_USE_EPOLL_INTERNAL_THREAD #else | MHD_USE_INTERNAL_POLLING_THREAD #endif - | MHD_USE_DUAL_STACK, + | MHD_USE_DUAL_STACK, port, NULL, NULL, &handle_mhd_request, h, MHD_OPTION_NOTIFY_COMPLETED, &handle_mhd_completion_callback, h, - MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 1024, + MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned + int) 1024, MHD_OPTION_END); if (NULL == h->mhd_bank) { @@ -1000,7 +1001,7 @@ TALER_FAKEBANK_start (uint16_t port) } #if EPOLL_SUPPORT h->mhd_fd = MHD_get_daemon_info (h->mhd_bank, - MHD_DAEMON_INFO_EPOLL_FD)->epoll_fd; + MHD_DAEMON_INFO_EPOLL_FD)->epoll_fd; h->mhd_rfd = GNUNET_NETWORK_socket_box_native (h->mhd_fd); #endif schedule_httpd (h); diff --git a/src/bank-lib/fakebank.h b/src/bank-lib/fakebank.h index ff8ea7165..321bc1336 100644 --- a/src/bank-lib/fakebank.h +++ b/src/bank-lib/fakebank.h @@ -198,27 +198,24 @@ struct HistoryArgs * @param pos current position. * @return GNUNET_YES if the iteration shuold go on. */ -typedef int (*CheckAdvance) - (const struct HistoryArgs *ha, - const struct Transaction *pos); +typedef int (*CheckAdvance)(const struct HistoryArgs *ha, + const struct Transaction *pos); /** * Type for a function that steps over the next element * in the list of all transactions, after the current @a pos * _got_ included in the result. */ -typedef struct Transaction * (*Step) - (const struct HistoryArgs *ha, - const struct Transaction *pos); +typedef struct Transaction * (*Step)(const struct HistoryArgs *ha, + const struct Transaction *pos); /* * Type for a function that steps over the next element * in the list of all transactions, after the current @a pos * did _not_ get included in the result. */ -typedef struct Transaction * (*Skip) - (const struct HistoryArgs *ha, - const struct Transaction *pos); +typedef struct Transaction * (*Skip)(const struct HistoryArgs *ha, + const struct Transaction *pos); /** * Actual history response builder. diff --git a/src/bank-lib/fakebank_history.c b/src/bank-lib/fakebank_history.c index 4cd0dc4cd..b1770bb85 100644 --- a/src/bank-lib/fakebank_history.c +++ b/src/bank-lib/fakebank_history.c @@ -110,7 +110,7 @@ TFH_handle_history_range_advance (const struct HistoryArgs *ha, const struct HistoryRangeDates *hrd = ha->range; if ( (NULL != pos) && - (pos->date.abs_value_us <= hrd->end.abs_value_us) ) + (pos->date.abs_value_us <= hrd->end.abs_value_us) ) return GNUNET_YES; return GNUNET_NO; @@ -196,16 +196,16 @@ TFH_build_history_response (struct MHD_Connection *connection, ? (pos->rejected ? "cancel-" : "-") : (pos->rejected ? "cancel+" : "+"); trans = json_pack - ("{s:I, s:o, s:o, s:s, s:I, s:s}", - "row_id", (json_int_t) pos->row_id, - "date", GNUNET_JSON_from_time_abs (pos->date), - "amount", TALER_JSON_from_amount (&pos->amount), - "sign", sign, - "counterpart", (json_int_t) - ( (ha->account_number == pos->debit_account) - ? pos->credit_account - : pos->debit_account), - "wt_subject", subject); + ("{s:I, s:o, s:o, s:s, s:I, s:s}", + "row_id", (json_int_t) pos->row_id, + "date", GNUNET_JSON_from_time_abs (pos->date), + "amount", TALER_JSON_from_amount (&pos->amount), + "sign", sign, + "counterpart", (json_int_t) + ( (ha->account_number == pos->debit_account) + ? pos->credit_account + : pos->debit_account), + "wt_subject", subject); GNUNET_assert (NULL != trans); GNUNET_free (subject); @@ -244,9 +244,9 @@ TFH_build_history_response (struct MHD_Connection *connection, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Returning empty transaction history\n"); resp = MHD_create_response_from_buffer - (0, - "", - MHD_RESPMEM_PERSISTENT); + (0, + "", + MHD_RESPMEM_PERSISTENT); ret = MHD_queue_response (connection, MHD_HTTP_NO_CONTENT, resp); @@ -270,7 +270,7 @@ TFH_build_history_response (struct MHD_Connection *connection, size_t json_len; json_str = json_dumps (jresponse, - JSON_INDENT(2)); + JSON_INDENT (2)); json_decref (jresponse); if (NULL == json_str) { @@ -339,9 +339,9 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, MHD_GET_ARGUMENT_KIND, "ordering"); account_number = MHD_lookup_connection_value - (connection, - MHD_GET_ARGUMENT_KIND, - "account_number"); + (connection, + MHD_GET_ARGUMENT_KIND, + "account_number"); /* Fail if one of the above failed. */ if ( (NULL == direction) || @@ -356,11 +356,11 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, "CREDIT")) && (0 != strcasecmp (direction, "DEBIT")) ) || - (1 != sscanf (account_number, - "%llu", - &ha->account_number)) || - ( (NULL == auth) || (0 != strcasecmp (auth, - "basic")) ) ) + (1 != sscanf (account_number, + "%llu", + &ha->account_number)) || + ( (NULL == auth) || (0 != strcasecmp (auth, + "basic")) ) ) { /* Invalid request, given that this is fakebank we impolitely * just kill the connection instead of returning a nice error. @@ -396,8 +396,9 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, "OMIT")) { /* nothing */ - } else if (0 == strcasecmp (cancelled, - "SHOW")) + } + else if (0 == strcasecmp (cancelled, + "SHOW")) { ha->direction |= TALER_BANK_DIRECTION_CANCEL; } @@ -410,8 +411,8 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, } if ((NULL != ordering) - && 0 == strcmp ("ascending", - ordering)) + && (0 == strcmp ("ascending", + ordering))) ha->ascending = GNUNET_YES; else ha->ascending = GNUNET_NO; diff --git a/src/bank-lib/taler-bank-transfer.c b/src/bank-lib/taler-bank-transfer.c index 2729b7ee9..6297d6502 100644 --- a/src/bank-lib/taler-bank-transfer.c +++ b/src/bank-lib/taler-bank-transfer.c @@ -203,48 +203,48 @@ main (int argc, char *const *argv) { const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_mandatory - (TALER_getopt_get_amount ('a', - "amount", - "VALUE", - "value to transfer", - &amount)), + (TALER_getopt_get_amount ('a', + "amount", + "VALUE", + "value to transfer", + &amount)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('b', - "bank", - "URL", - "base URL of the bank", - &bank_url)), + (GNUNET_GETOPT_option_string ('b', + "bank", + "URL", + "base URL of the bank", + &bank_url)), GNUNET_GETOPT_option_help ("Deposit funds into a Taler reserve"), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_ulong ('C', - "credit", - "ACCOUNT", - "number of the bank account to credit", - &credit_account_no)), + (GNUNET_GETOPT_option_ulong ('C', + "credit", + "ACCOUNT", + "number of the bank account to credit", + &credit_account_no)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_ulong ('D', - "debit", - "ACCOUNT", - "number of the bank account to debit", - &debit_account_no)), + (GNUNET_GETOPT_option_ulong ('D', + "debit", + "ACCOUNT", + "number of the bank account to debit", + &debit_account_no)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('s', - "subject", - "STRING", - "specifies the wire transfer subject", - &subject)), + (GNUNET_GETOPT_option_string ('s', + "subject", + "STRING", + "specifies the wire transfer subject", + &subject)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('u', - "user", - "USERNAME", - "username to use for authentication", - &username)), + (GNUNET_GETOPT_option_string ('u', + "user", + "USERNAME", + "username to use for authentication", + &username)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('p', - "pass", - "PASSPHRASE", - "passphrase to use for authentication", - &password)), + (GNUNET_GETOPT_option_string ('p', + "pass", + "PASSPHRASE", + "passphrase to use for authentication", + &password)), GNUNET_GETOPT_OPTION_END }; @@ -256,9 +256,9 @@ main (int argc, char *const *argv) if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-bank-transfer", - "Execute bank transfer", - options, - &run, NULL)) + "Execute bank transfer", + options, + &run, NULL)) return 1; return global_ret; } diff --git a/src/bank-lib/taler-fakebank-run.c b/src/bank-lib/taler-fakebank-run.c index 599ca85d6..51d054bca 100644 --- a/src/bank-lib/taler-fakebank-run.c +++ b/src/bank-lib/taler-fakebank-run.c @@ -65,13 +65,13 @@ main (int argc, const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - + if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-fakebank-run", - "Runs the fakebank", - options, - &run, + "Runs the fakebank", + options, + &run, NULL)) return 1; diff --git a/src/bank-lib/test_bank_api.c b/src/bank-lib/test_bank_api.c index b1b943771..043234560 100644 --- a/src/bank-lib/test_bank_api.c +++ b/src/bank-lib/test_bank_api.c @@ -41,8 +41,7 @@ static void run (void *cls) { int *resultp = cls; - static struct TBI_Command commands[] = - { + static struct TBI_Command commands[] = { /* Ask complete history of 'Exchange' user (number 2) */ { .oc = TBI_OC_HISTORY, .label = "history-0", @@ -113,7 +112,8 @@ run (void *cls) { .oc = TBI_OC_HISTORY, .label = "history-r3", .details.history.account_number = 2, - .details.history.direction = TALER_BANK_DIRECTION_BOTH | TALER_BANK_DIRECTION_CANCEL, + .details.history.direction = TALER_BANK_DIRECTION_BOTH + | TALER_BANK_DIRECTION_CANCEL, .details.history.start_row_ref = NULL, .details.history.num_results = 5 }, { .oc = TBI_OC_END } @@ -133,7 +133,7 @@ run (void *cls) */ int main (int argc, - char * const *argv) + char *const *argv) { struct GNUNET_OS_Process *bankd; unsigned int cnt; @@ -143,11 +143,11 @@ main (int argc, if (GNUNET_OK != GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - 8081)) + 8081)) { fprintf (stderr, "Required port %u not available, skipping.\n", - 8081); + 8081); return 77; } GNUNET_log_setup ("test-bank-api", @@ -157,13 +157,14 @@ main (int argc, if (NULL == (dbconn = getenv ("TALER_EXCHANGEDB_POSTGRES_CONFIG"))) dbconn = defaultdb; char *purgedb_cmd; - GNUNET_asprintf (&purgedb_cmd, "taler-bank-manage -c bank.conf --with-db=%s django flush --no-input", + GNUNET_asprintf (&purgedb_cmd, + "taler-bank-manage -c bank.conf --with-db=%s django flush --no-input", dbconn); if (0 != system (purgedb_cmd)) { - fprintf (stderr, - "Could not purge database\n"); - return 77; + fprintf (stderr, + "Could not purge database\n"); + return 77; } bankd = GNUNET_OS_start_process (GNUNET_NO, @@ -188,14 +189,15 @@ main (int argc, "Waiting for taler-bank-manage to be ready\n"); cnt = 0; do - { - fprintf (stderr, "."); - sleep (1); - cnt++; - if (cnt > 30) - break; - } - while (0 != system ("wget -q -t 1 -T 1 http://127.0.0.1:8080/ -o /dev/null -O /dev/null")); + { + fprintf (stderr, "."); + sleep (1); + cnt++; + if (cnt > 30) + break; + } + while (0 != system ( + "wget -q -t 1 -T 1 http://127.0.0.1:8080/ -o /dev/null -O /dev/null")); fprintf (stderr, "\n"); diff --git a/src/bank-lib/test_bank_api_new.c b/src/bank-lib/test_bank_api_new.c index 4a89c1931..17acac9bc 100644 --- a/src/bank-lib/test_bank_api_new.c +++ b/src/bank-lib/test_bank_api_new.c @@ -49,8 +49,8 @@ #define ADDSECS(base, secs) \ GNUNET_TIME_absolute_add \ (base, \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ - secs)) + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ + secs)) /** * Subtract seconds. * @@ -61,8 +61,8 @@ #define SUBSECS(base, secs) \ GNUNET_TIME_absolute_subtract \ (base, \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ - secs)) + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ + secs)) /** * Bank process. */ @@ -96,35 +96,35 @@ run (void *cls, 5), TALER_TESTING_cmd_bank_history_range_with_dates ("history-0-range", - bank_url, - EXCHANGE_ACCOUNT_NUMBER, - TALER_BANK_DIRECTION_BOTH, - GNUNET_NO, - SUBSECS (now, - 5), - ADDSECS (now, - 5)), + bank_url, + EXCHANGE_ACCOUNT_NUMBER, + TALER_BANK_DIRECTION_BOTH, + GNUNET_NO, + SUBSECS (now, + 5), + ADDSECS (now, + 5)), TALER_TESTING_cmd_fakebank_transfer_with_subject ("deposit-1", - "KUDOS:5.01", - bank_url, - BANK_ACCOUNT_NUMBER, - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.password, - "subject 1", - "http://exchange.com/"), + "KUDOS:5.01", + bank_url, + BANK_ACCOUNT_NUMBER, + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 1", + "http://exchange.com/"), /* bank gives to exchange */ TALER_TESTING_cmd_fakebank_transfer_with_subject ("deposit-2", - "KUDOS:5.01", - bank_url, - BANK_ACCOUNT_NUMBER, - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.password, - "subject 2", - "http://exchange.com/"), + "KUDOS:5.01", + bank_url, + BANK_ACCOUNT_NUMBER, + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 2", + "http://exchange.com/"), TALER_TESTING_cmd_bank_history ("history-1c", bank_url, EXCHANGE_ACCOUNT_NUMBER, @@ -158,14 +158,14 @@ run (void *cls, */ TALER_TESTING_cmd_bank_history_range_with_dates ("history-2-range", - bank_url, - EXCHANGE_ACCOUNT_NUMBER, - TALER_BANK_DIRECTION_BOTH, - GNUNET_NO, - SUBSECS (now, - 50), - ADDSECS (now, - 5)), + bank_url, + EXCHANGE_ACCOUNT_NUMBER, + TALER_BANK_DIRECTION_BOTH, + GNUNET_NO, + SUBSECS (now, + 50), + ADDSECS (now, + 5)), TALER_TESTING_cmd_bank_reject ("reject-1", bank_url, "deposit-1"), @@ -182,8 +182,8 @@ run (void *cls, /* Pacifies "make check" */ int -main(int argc, - char * const *argv) +main (int argc, + char *const *argv) { unsigned int ret; /* These environment variables get in the way... */ @@ -192,11 +192,11 @@ main(int argc, GNUNET_log_setup ("test-bank-api-new", "DEBUG", NULL); if (NULL == - (bank_url = TALER_TESTING_prepare_bank (CONFIG_FILE))) + (bank_url = TALER_TESTING_prepare_bank (CONFIG_FILE))) return 77; if (NULL == (bankd = - TALER_TESTING_run_bank (CONFIG_FILE, bank_url))) + TALER_TESTING_run_bank (CONFIG_FILE, bank_url))) return 77; ret = TALER_TESTING_setup (&run, diff --git a/src/bank-lib/test_bank_api_twisted.c b/src/bank-lib/test_bank_api_twisted.c index 3bb149fda..a8f60c5eb 100644 --- a/src/bank-lib/test_bank_api_twisted.c +++ b/src/bank-lib/test_bank_api_twisted.c @@ -115,7 +115,7 @@ purge_process (struct GNUNET_OS_Process *process) int main (int argc, - char * const *argv) + char *const *argv) { unsigned int ret; /* These environment variables get in the way... */ @@ -127,19 +127,19 @@ main (int argc, NULL); if (NULL == (bank_url = TALER_TESTING_prepare_bank - (CONFIG_FILE))) + (CONFIG_FILE))) return 77; if (NULL == (bankd = TALER_TESTING_run_bank - (CONFIG_FILE, - bank_url))) + (CONFIG_FILE, + bank_url))) { GNUNET_free (bank_url); return 77; } if (NULL == (twister_url = TALER_TESTING_prepare_twister - (CONFIG_FILE))) + (CONFIG_FILE))) { purge_process (bankd); GNUNET_free (bank_url); diff --git a/src/bank-lib/test_bank_api_with_fakebank.c b/src/bank-lib/test_bank_api_with_fakebank.c index 5c940d789..331968120 100644 --- a/src/bank-lib/test_bank_api_with_fakebank.c +++ b/src/bank-lib/test_bank_api_with_fakebank.c @@ -37,8 +37,7 @@ static void run (void *cls) { int *resultp = cls; - static struct TBI_Command commands[] = - { + static struct TBI_Command commands[] = { { .oc = TBI_OC_HISTORY, .label = "history-0", .details.history.account_number = 1, @@ -134,7 +133,8 @@ run (void *cls) { .oc = TBI_OC_HISTORY, .label = "history-r1c", .details.history.account_number = 1, - .details.history.direction = TALER_BANK_DIRECTION_BOTH | TALER_BANK_DIRECTION_CANCEL, + .details.history.direction = TALER_BANK_DIRECTION_BOTH + | TALER_BANK_DIRECTION_CANCEL, .details.history.start_row_ref = NULL, .details.history.num_results = 5 }, { .oc = TBI_OC_EXPECT_TRANSFER, @@ -160,7 +160,7 @@ run (void *cls) */ int main (int argc, - char * const *argv) + char *const *argv) { int result; diff --git a/src/bank-lib/test_bank_api_with_fakebank_new.c b/src/bank-lib/test_bank_api_with_fakebank_new.c index 8865cc403..046248ad8 100644 --- a/src/bank-lib/test_bank_api_with_fakebank_new.c +++ b/src/bank-lib/test_bank_api_with_fakebank_new.c @@ -76,14 +76,14 @@ run (void *cls, * the parameters, although it was always set as '200 OK' */ TALER_TESTING_cmd_fakebank_transfer_with_subject ("debit-1", - "KUDOS:5.01", - fakebank_url, - EXCHANGE_ACCOUNT_NUMBER, - BANK_ACCOUNT_NUMBER, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.password, - "subject 1", - "http://exchange.com/"), + "KUDOS:5.01", + fakebank_url, + EXCHANGE_ACCOUNT_NUMBER, + BANK_ACCOUNT_NUMBER, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 1", + "http://exchange.com/"), TALER_TESTING_cmd_bank_history ("history-1c", fakebank_url, @@ -103,25 +103,25 @@ run (void *cls, TALER_TESTING_cmd_fakebank_transfer_with_subject ("debit-2", - "KUDOS:3.21", - fakebank_url, - EXCHANGE_ACCOUNT_NUMBER, // debit account. - USER_ACCOUNT_NUMBER, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.password, - "subject 2", - "http://exchange.org/"), + "KUDOS:3.21", + fakebank_url, + EXCHANGE_ACCOUNT_NUMBER, // debit account. + USER_ACCOUNT_NUMBER, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 2", + "http://exchange.org/"), TALER_TESTING_cmd_fakebank_transfer_with_subject ("credit-2", - "KUDOS:3.22", - fakebank_url, - USER_ACCOUNT_NUMBER, // debit account. - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[USER_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[USER_ACCOUNT_NUMBER -1].details.basic.password, - "credit 2", - "http://exchange.org/"), + "KUDOS:3.22", + fakebank_url, + USER_ACCOUNT_NUMBER, // debit account. + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[USER_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[USER_ACCOUNT_NUMBER - 1].details.basic.password, + "credit 2", + "http://exchange.org/"), TALER_TESTING_cmd_bank_history ("history-2b", fakebank_url, @@ -152,18 +152,18 @@ run (void *cls, TALER_TESTING_cmd_fakebank_transfer_with_subject ("credit-for-reject-1", - "KUDOS:5.01", - fakebank_url, - BANK_ACCOUNT_NUMBER, - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.password, - "subject 3", - "http://exchange.net/"), - - TALER_TESTING_cmd_bank_reject ("reject-1", - fakebank_url, - "credit-for-reject-1"), + "KUDOS:5.01", + fakebank_url, + BANK_ACCOUNT_NUMBER, + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 3", + "http://exchange.net/"), + + TALER_TESTING_cmd_bank_reject ("reject-1", + fakebank_url, + "credit-for-reject-1"), TALER_TESTING_cmd_bank_history ("history-r1", fakebank_url, @@ -176,15 +176,15 @@ run (void *cls, TALER_TESTING_cmd_bank_history ("history-r1c", fakebank_url, BANK_ACCOUNT_NUMBER, - TALER_BANK_DIRECTION_BOTH | - TALER_BANK_DIRECTION_CANCEL, + TALER_BANK_DIRECTION_BOTH + | TALER_BANK_DIRECTION_CANCEL, GNUNET_YES, NULL, 5), TALER_TESTING_cmd_check_bank_transfer_with_ref ("expect-credit-reject-1", - "credit-for-reject-1"), + "credit-for-reject-1"), TALER_TESTING_cmd_check_bank_empty ("expect-empty-2"), @@ -202,7 +202,7 @@ run (void *cls, int main (int argc, - char * const *argv) + char *const *argv) { /* These environment variables get in the way... */ unsetenv ("XDG_DATA_HOME"); diff --git a/src/bank-lib/test_bank_api_with_fakebank_twisted.c b/src/bank-lib/test_bank_api_with_fakebank_twisted.c index 162eb5dfe..8c5b90a1a 100644 --- a/src/bank-lib/test_bank_api_with_fakebank_twisted.c +++ b/src/bank-lib/test_bank_api_with_fakebank_twisted.c @@ -115,7 +115,7 @@ purge_process (struct GNUNET_OS_Process *process) int main (int argc, - char * const *argv) + char *const *argv) { unsigned int ret; @@ -128,12 +128,12 @@ main (int argc, NULL); if (NULL == (fakebank_url = TALER_TESTING_prepare_fakebank - (CONFIG_FILE, - "account-1"))) + (CONFIG_FILE, + "account-1"))) return 77; if (NULL == (twister_url = TALER_TESTING_prepare_twister - (CONFIG_FILE))) + (CONFIG_FILE))) { GNUNET_free (fakebank_url); return 77; diff --git a/src/bank-lib/test_bank_interpreter.c b/src/bank-lib/test_bank_interpreter.c index 9430e84bb..7f30f5050 100644 --- a/src/bank-lib/test_bank_interpreter.c +++ b/src/bank-lib/test_bank_interpreter.c @@ -118,7 +118,7 @@ find_command (const struct InterpreterState *is, "Attempt to lookup command for empty label\n"); return NULL; } - for (unsigned int i=0;TBI_OC_END != (cmd = &is->commands[i])->oc;i++) + for (unsigned int i = 0; TBI_OC_END != (cmd = &is->commands[i])->oc; i++) if ( (NULL != cmd->label) && (0 == strcmp (cmd->label, label)) ) @@ -144,7 +144,7 @@ test_cancelled (struct InterpreterState *is, { const struct TBI_Command *cmd = &is->commands[off]; - for (unsigned int i=0;i<is->ip;i++) + for (unsigned int i = 0; i<is->ip; i++) { const struct TBI_Command *c = &is->commands[i]; @@ -238,7 +238,7 @@ build_history (struct InterpreterState *is, ok = GNUNET_NO; if (NULL == ref) ok = GNUNET_YES; - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TBI_Command *pos = &is->commands[off]; int cancelled; @@ -262,10 +262,12 @@ build_history (struct InterpreterState *is, if ( (GNUNET_YES == cancelled) && (0 == (cmd->details.history.direction & TALER_BANK_DIRECTION_CANCEL)) ) continue; - if ( ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) || - ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && + ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_DEBIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.debit_account_no)) ) total++; /* found matching record */ @@ -283,7 +285,7 @@ build_history (struct InterpreterState *is, ok = GNUNET_NO; if (NULL == ref) ok = GNUNET_YES; - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TBI_Command *pos = &is->commands[off]; int cancelled; @@ -302,10 +304,12 @@ build_history (struct InterpreterState *is, continue; /* skip until we find the marker */ if (total >= cmd->details.history.num_results * inc) break; /* hit limit specified by command */ - if ( ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) && - ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && + ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_DEBIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.debit_account_no)) ) { @@ -319,7 +323,8 @@ build_history (struct InterpreterState *is, (0 == (cmd->details.history.direction & TALER_BANK_DIRECTION_CANCEL)) ) continue; - if ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) { @@ -329,11 +334,12 @@ build_history (struct InterpreterState *is, GNUNET_asprintf (&h[total].details.account_url, "payto://x-taler-bank/%s/%llu", "localhost:8080", - (unsigned long long) pos->details.admin_add_incoming.debit_account_no); + (unsigned long + long) pos->details.admin_add_incoming.debit_account_no); } if ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && - (cmd->details.history.account_number == - pos->details.admin_add_incoming.debit_account_no)) + (cmd->details.history.account_number == + pos->details.admin_add_incoming.debit_account_no)) { h[total].direction = TALER_BANK_DIRECTION_DEBIT; if (GNUNET_YES == cancelled) @@ -341,18 +347,22 @@ build_history (struct InterpreterState *is, GNUNET_asprintf (&h[total].details.account_url, "payto://x-taler-bank/%s/%llu", "localhost:8080", - (unsigned long long) pos->details.admin_add_incoming.credit_account_no); + (unsigned long + long) pos->details.admin_add_incoming.credit_account_no); } - if ( ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) || - ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && + ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_DEBIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.debit_account_no)) ) { GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (pos->details.admin_add_incoming.amount, - &h[total].details.amount)); + TALER_string_to_amount ( + pos->details.admin_add_incoming.amount, + &h[total].details.amount)); /* h[total].execution_date; // unknown here */ h[total].row_id = pos->details.admin_add_incoming.row_id; @@ -386,7 +396,7 @@ print_expected (struct History *h, (unsigned long long) h_len); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expected history:\n"); - for (uint64_t i=0;i<h_len;i++) + for (uint64_t i = 0; i<h_len; i++) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "H(%llu): %s%s (serial: %llu, subject: %s, to: %s)\n", @@ -410,7 +420,7 @@ static void free_history (struct History *h, uint64_t h_len) { - for (uint64_t off = 0;off<h_len;off++) + for (uint64_t off = 0; off<h_len; off++) { GNUNET_free (h[off].details.wire_transfer_subject); GNUNET_free (h[off].details.account_url); @@ -747,11 +757,14 @@ interpreter_run (void *cls) = TALER_BANK_admin_add_incoming (is->ctx, "http://localhost:8080", &auth, - cmd->details.admin_add_incoming.exchange_base_url, + cmd->details.admin_add_incoming. + exchange_base_url, cmd->details.admin_add_incoming.subject, &amount, - cmd->details.admin_add_incoming.debit_account_no, - cmd->details.admin_add_incoming.credit_account_no, + cmd->details.admin_add_incoming. + debit_account_no, + cmd->details.admin_add_incoming. + credit_account_no, &add_incoming_cb, is); if (NULL == cmd->details.admin_add_incoming.aih) @@ -813,8 +826,9 @@ interpreter_run (void *cls) cmd->details.expect_transfer.cmd_ref); GNUNET_assert (NULL != ref); GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (ref->details.admin_add_incoming.amount, - &amount)); + TALER_string_to_amount ( + ref->details.admin_add_incoming.amount, + &amount)); { char *subject; @@ -822,8 +836,10 @@ interpreter_run (void *cls) TALER_FAKEBANK_check (is->fakebank, &amount, ref->details.admin_add_incoming.debit_account_no, - ref->details.admin_add_incoming.credit_account_no, - ref->details.admin_add_incoming.exchange_base_url, + ref->details.admin_add_incoming. + credit_account_no, + ref->details.admin_add_incoming. + exchange_base_url, &subject)) { GNUNET_break (0); @@ -841,7 +857,7 @@ interpreter_run (void *cls) GNUNET_free (subject); } next (is); - return; + return; case TBI_OC_EXPECT_TRANSFERS_EMPTY: if (GNUNET_OK != TALER_FAKEBANK_check_empty (is->fakebank)) { @@ -928,7 +944,7 @@ do_shutdown (void *cls) is->timeout_task = NULL; } - for (unsigned int i=0;TBI_OC_END != (cmd = &is->commands[i])->oc;i++) + for (unsigned int i = 0; TBI_OC_END != (cmd = &is->commands[i])->oc; i++) { switch (cmd->oc) { @@ -942,7 +958,8 @@ do_shutdown (void *cls) "Command %u (%s) did not complete\n", i, cmd->label); - TALER_BANK_admin_add_incoming_cancel (cmd->details.admin_add_incoming.aih); + TALER_BANK_admin_add_incoming_cancel ( + cmd->details.admin_add_incoming.aih); cmd->details.admin_add_incoming.aih = NULL; } break; @@ -1025,7 +1042,7 @@ TBI_run_interpreter (int *resultp, is); is->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 150), + (GNUNET_TIME_UNIT_SECONDS, 150), &do_timeout, is); GNUNET_SCHEDULER_add_shutdown (&do_shutdown, is); } diff --git a/src/bank-lib/test_bank_interpreter.h b/src/bank-lib/test_bank_interpreter.h index ae323055d..1f78ec0bd 100644 --- a/src/bank-lib/test_bank_interpreter.h +++ b/src/bank-lib/test_bank_interpreter.h @@ -136,7 +136,8 @@ struct TBI_Command } admin_add_incoming; - struct { + struct + { /** * For which account do we query the history. @@ -186,7 +187,8 @@ struct TBI_Command * If @e opcode is #TBI_OC_EXPECT_TRANSFER, this * specifies which transfer we expected. */ - struct { + struct + { /** * Label of the command of an /admin/add/incoming @@ -199,7 +201,8 @@ struct TBI_Command /** * Execute /reject operation. */ - struct { + struct + { /** * Reference to the matching transfer that is now to be rejected. diff --git a/src/bank-lib/testing_api_cmd_history.c b/src/bank-lib/testing_api_cmd_history.c index 013bb647d..e69cd7c1a 100644 --- a/src/bank-lib/testing_api_cmd_history.c +++ b/src/bank-lib/testing_api_cmd_history.c @@ -80,7 +80,7 @@ struct HistoryState /** * Set to GNUNET_YES if the callback detects something - * unexpected. + * unexpected. */ int failed; @@ -184,7 +184,7 @@ test_cancelled (struct TALER_TESTING_Interpreter *is, current_cmd = &is->commands[off]; TALER_LOG_INFO ("Is `%s' rejected?\n", current_cmd->label); - for (unsigned int i=0;i<is->ip;i++) + for (unsigned int i = 0; i<is->ip; i++) { const struct TALER_TESTING_Command *c = &is->commands[i]; @@ -195,7 +195,7 @@ test_cancelled (struct TALER_TESTING_Interpreter *is, * reject command to mark them as rejected. So errors * about "reject traits" not found are NOT fatal here */ if (GNUNET_OK != TALER_TESTING_get_trait_rejected - (c, 0, &rejected_reference)) + (c, 0, &rejected_reference)) continue; TALER_LOG_INFO ("Command `%s' was rejected by `%s'.\n", @@ -220,7 +220,7 @@ static void free_history (struct History *h, uint64_t h_len) { - for (uint64_t off = 0;off<h_len;off++) + for (uint64_t off = 0; off<h_len; off++) { GNUNET_free (h[off].details.wire_transfer_subject); GNUNET_free (h[off].details.account_url); @@ -247,14 +247,14 @@ print_expected (struct History *h, (unsigned long long) h_len); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expected history:\n"); - for (uint64_t i=0;i<h_len;i++) + for (uint64_t i = 0; i<h_len; i++) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "H(%llu): %s%s (serial: %llu, subject: %s," " counterpart: %s)\n", (unsigned long long) i, (TALER_BANK_DIRECTION_CREDIT == h[i].direction) ? - "+" : "-", + "+" : "-", TALER_amount2s (&h[i].details.amount), (unsigned long long) h[i].row_id, h[i].details.wire_transfer_subject, @@ -282,14 +282,14 @@ build_history_hit_limit (uint64_t total, { /* "/history-range" case. */ if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - hs->start_date.abs_value_us) + hs->start_date.abs_value_us) { const struct GNUNET_TIME_Absolute *timestamp; GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_absolute_time (pos, - 0, - ×tamp)); + TALER_TESTING_get_trait_absolute_time (pos, + 0, + ×tamp)); GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != hs->end_date.abs_value_us); @@ -345,18 +345,18 @@ build_history (struct TALER_TESTING_Interpreter *is, { TALER_LOG_INFO ("`%s': start row given via reference `%s'\n", - TALER_TESTING_interpreter_get_current_label (is), - hs->start_row_reference); + TALER_TESTING_interpreter_get_current_label (is), + hs->start_row_reference); add_incoming_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->start_row_reference); + (is, hs->start_row_reference); GNUNET_assert (NULL != add_incoming_cmd); GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_uint64 - (add_incoming_cmd, 0, &row_id_start)); + (add_incoming_cmd, 0, &row_id_start)); } GNUNET_assert ((0 != hs->num_results) || /* "/history" */ - (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != /* "/history-range" */ - hs->start_date.abs_value_us)); + (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != /* "/history-range" */ + hs->start_date.abs_value_us)); if (0 == is->ip) { @@ -388,7 +388,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /* This loop counts how many commands _later than "start"_ belong * to the history of the caller. This is stored in the @var total * variable. */ - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TALER_TESTING_Command *pos = &is->commands[off]; int cancelled; @@ -418,7 +418,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /* Seek "/history-range" starting row, _if_ that's the case */ if ((GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - hs->start_date.abs_value_us) && (GNUNET_YES != ok)) + hs->start_date.abs_value_us) && (GNUNET_YES != ok)) { const struct GNUNET_TIME_Absolute *timestamp; @@ -427,8 +427,8 @@ build_history (struct TALER_TESTING_Interpreter *is, ×tamp); TALER_LOG_DEBUG ("Seeking first row, start vs timestamp: %llu vs %llu\n", - (long long unsigned int) hs->start_date.abs_value_us, - (long long unsigned int) timestamp->abs_value_us); + (long long unsigned int) hs->start_date.abs_value_us, + (long long unsigned int) timestamp->abs_value_us); if (hs->start_date.abs_value_us <= timestamp->abs_value_us) { @@ -510,7 +510,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /** * This loop _only_ populates the array of history elements. */ - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TALER_TESTING_Command *pos = &is->commands[off]; int cancelled; @@ -520,7 +520,7 @@ build_history (struct TALER_TESTING_Interpreter *is, const uint64_t *debit_account_no; if (GNUNET_OK != TALER_TESTING_GET_TRAIT_ROW_ID - (pos, &row_id)) + (pos, &row_id)) continue; if (NULL != row_id_start) @@ -531,7 +531,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /** * Warning: this zeroing is superfluous, as * total doesn't get incremented if 'start' - * was given and couldn't be found. + * was given and couldn't be found. */ total = 0; ok = GNUNET_YES; @@ -541,7 +541,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /* Seek "/history-range" starting row, _if_ that's the case */ if ((GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - hs->start_date.abs_value_us) && (GNUNET_YES != ok)) + hs->start_date.abs_value_us) && (GNUNET_YES != ok)) { const struct GNUNET_TIME_Absolute *timestamp; @@ -550,8 +550,8 @@ build_history (struct TALER_TESTING_Interpreter *is, ×tamp); TALER_LOG_DEBUG ("Seeking first row, start vs timestamp (2): %llu vs %llu\n", - (long long unsigned int) hs->start_date.abs_value_us, - (long long unsigned int) timestamp->abs_value_us); + (long long unsigned int) hs->start_date.abs_value_us, + (long long unsigned int) timestamp->abs_value_us); if (hs->start_date.abs_value_us <= timestamp->abs_value_us) { @@ -611,15 +611,15 @@ build_history (struct TALER_TESTING_Interpreter *is, if ( (GNUNET_YES == cancelled) && (0 == (hs->direction & TALER_BANK_DIRECTION_CANCEL)) ) { - TALER_LOG_WARNING ("`%s' was cancelled\n", - TALER_TESTING_interpreter_get_current_label - (is)); - continue; + TALER_LOG_WARNING ("`%s' was cancelled\n", + TALER_TESTING_interpreter_get_current_label + (is)); + continue; } - bank_hostname = strchr (hs->bank_url, ':'); - GNUNET_assert (NULL != bank_hostname); - bank_hostname += 3; + bank_hostname = strchr (hs->bank_url, ':'); + GNUNET_assert (NULL != bank_hostname); + bank_hostname += 3; /* Next two blocks only put the 'direction' and 'banking' * information. */ @@ -634,16 +634,16 @@ build_history (struct TALER_TESTING_Interpreter *is, GNUNET_asprintf (&h[total].details.account_url, - ('/' == bank_hostname[strlen(bank_hostname) -1]) - ? "payto://x-taler-bank/%s%llu" - : "payto://x-taler-bank/%s/%llu", - bank_hostname, - (unsigned long long) *debit_account_no); + ('/' == bank_hostname[strlen (bank_hostname) - 1]) + ? "payto://x-taler-bank/%s%llu" + : "payto://x-taler-bank/%s/%llu", + bank_hostname, + (unsigned long long) *debit_account_no); } /* Asked for debit, and account got the debit. */ if ( (0 != (hs->direction & TALER_BANK_DIRECTION_DEBIT)) && - (hs->account_no == *debit_account_no)) + (hs->account_no == *debit_account_no)) { h[total].direction = TALER_BANK_DIRECTION_DEBIT; if (GNUNET_YES == cancelled) @@ -651,11 +651,11 @@ build_history (struct TALER_TESTING_Interpreter *is, GNUNET_asprintf (&h[total].details.account_url, - ('/' == bank_hostname[strlen(bank_hostname) -1]) - ? "payto://x-taler-bank/%s%llu" - : "payto://x-taler-bank/%s/%llu", - bank_hostname, - (unsigned long long) *credit_account_no); + ('/' == bank_hostname[strlen (bank_hostname) - 1]) + ? "payto://x-taler-bank/%s%llu" + : "payto://x-taler-bank/%s/%llu", + bank_hostname, + (unsigned long long) *credit_account_no); } /* This block _completes_ the information of the current item, @@ -678,7 +678,7 @@ build_history (struct TALER_TESTING_Interpreter *is, (pos, 0, &subject)); GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_url - (pos, 0, &exchange_url)); + (pos, 0, &exchange_url)); h[total].details.amount = *amount; @@ -821,12 +821,12 @@ history_cb (void *cls, total = build_history (is, &h); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Expected history of length %llu, got %llu;" - " HTTP status code: %u, failed: %d\n", - (unsigned long long) total, - (unsigned long long) hs->results_obtained, - http_status, - hs->failed); + "Expected history of length %llu, got %llu;" + " HTTP status code: %u, failed: %d\n", + (unsigned long long) total, + (unsigned long long) hs->results_obtained, + http_status, + hs->failed); print_expected (h, total, UINT_MAX); free_history (h, total); TALER_TESTING_interpreter_fail (is); @@ -835,14 +835,14 @@ history_cb (void *cls, TALER_TESTING_interpreter_next (is); return; } - + if (MHD_HTTP_OK != http_status) { hs->hh = NULL; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unwanted response code from /history[-range]: %u\n", - http_status); + "Unwanted response code from /history[-range]: %u\n", + http_status); TALER_TESTING_interpreter_fail (is); return; } @@ -898,7 +898,7 @@ history_run (void *cls, const struct TALER_TESTING_Command *history_cmd; history_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->start_row_reference); + (is, hs->start_row_reference); if (NULL == history_cmd) TALER_TESTING_FAIL (is); @@ -940,7 +940,7 @@ history_range_run (void *cls, const struct TALER_TESTING_Command *cmd, struct TALER_TESTING_Interpreter *is) { - + struct HistoryState *hs = cls; const struct GNUNET_TIME_Absolute *start_date; const struct GNUNET_TIME_Absolute *end_date; @@ -948,17 +948,17 @@ history_range_run (void *cls, if (NULL != hs->start_row_reference) { - + const struct TALER_TESTING_Command *history_cmd; history_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->start_row_reference); + (is, hs->start_row_reference); if (NULL == history_cmd) TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_absolute_time - (history_cmd, 0, &start_date)) + (history_cmd, 0, &start_date)) TALER_TESTING_FAIL (is); hs->start_date = *start_date; } @@ -976,13 +976,13 @@ history_range_run (void *cls, const struct TALER_TESTING_Command *history_cmd; history_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->end_row_reference); + (is, hs->end_row_reference); if (NULL == history_cmd) TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_absolute_time - (history_cmd, 0, &end_date)) + (history_cmd, 0, &end_date)) TALER_TESTING_FAIL (is); hs->end_date = *end_date; } @@ -1019,7 +1019,7 @@ history_range_run (void *cls, static void history_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct HistoryState *hs = cls; @@ -1046,19 +1046,19 @@ history_cleanup * @param start_row_reference reference to a command that can * offer a row identifier, to be used as the starting row * to accept in the result. - * @param num_result how many rows we want in the result. + * @param num_result how many rows we want in the result. * * @return the command. */ struct TALER_TESTING_Command TALER_TESTING_cmd_bank_history (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - const char *start_row_reference, - long long num_results) + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction direction, + unsigned int ascending, + const char *start_row_reference, + long long num_results) { struct HistoryState *hs; @@ -1105,12 +1105,12 @@ TALER_TESTING_cmd_bank_history struct TALER_TESTING_Command TALER_TESTING_cmd_bank_history_range (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - const char *start_row_reference, - const char *end_row_reference) + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction direction, + unsigned int ascending, + const char *start_row_reference, + const char *end_row_reference) { struct HistoryState *hs; @@ -1155,12 +1155,12 @@ TALER_TESTING_cmd_bank_history_range struct TALER_TESTING_Command TALER_TESTING_cmd_bank_history_range_with_dates (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - struct GNUNET_TIME_Absolute start_date, - struct GNUNET_TIME_Absolute end_date) + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction direction, + unsigned int ascending, + struct GNUNET_TIME_Absolute start_date, + struct GNUNET_TIME_Absolute end_date) { struct HistoryState *hs; diff --git a/src/bank-lib/testing_api_cmd_reject.c b/src/bank-lib/testing_api_cmd_reject.c index 46d67ff21..1f19a379d 100644 --- a/src/bank-lib/testing_api_cmd_reject.c +++ b/src/bank-lib/testing_api_cmd_reject.c @@ -97,7 +97,7 @@ reject_cb (void *cls, static void reject_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct RejectState *rs = cls; @@ -119,8 +119,8 @@ reject_cleanup */ static void reject_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) + const struct TALER_TESTING_Command *cmd, + struct TALER_TESTING_Interpreter *is) { struct RejectState *rs = cls; const struct TALER_TESTING_Command *deposit_cmd; @@ -129,7 +129,7 @@ reject_run (void *cls, extern struct TALER_BANK_AuthenticationData AUTHS[]; deposit_cmd = TALER_TESTING_interpreter_lookup_command - (is, rs->deposit_reference); + (is, rs->deposit_reference); if (NULL == deposit_cmd) TALER_TESTING_FAIL (is); @@ -145,7 +145,7 @@ reject_run (void *cls, (unsigned long long) *credit_account); rs->rh = TALER_BANK_reject (is->ctx, rs->bank_url, - &AUTHS[*credit_account -1], + &AUTHS[*credit_account - 1], *credit_account, *row_id, &reject_cb, diff --git a/src/bank-lib/testing_api_helpers.c b/src/bank-lib/testing_api_helpers.c index f61f66649..db813df2a 100644 --- a/src/bank-lib/testing_api_helpers.c +++ b/src/bank-lib/testing_api_helpers.c @@ -44,7 +44,7 @@ struct TALER_BANK_AuthenticationData AUTHS[] = { /* User credentials */ {.method = TALER_BANK_AUTH_BASIC, .details.basic.username = USER_USERNAME, - .details.basic.password = USER_PASSWORD } + .details.basic.password = USER_PASSWORD } }; /** @@ -115,14 +115,14 @@ TALER_TESTING_run_bank (const char *config_filename, serve_arg = "serve-uwsgi"; bank_proc = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-bank-manage", - "taler-bank-manage", - "-c", config_filename, - "--with-db", database, - serve_arg, NULL); + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-bank-manage", + "taler-bank-manage", + "-c", config_filename, + "--with-db", database, + serve_arg, NULL); if (NULL == bank_proc) BANK_FAIL (); @@ -136,22 +136,22 @@ TALER_TESTING_run_bank (const char *config_filename, "Waiting for `taler-bank-manage' to be ready"); iter = 0; do + { + if (10 == iter) { - if (10 == iter) - { - fprintf ( - stderr, - "Failed to launch `taler-bank-manage' (or `wget')\n"); - GNUNET_OS_process_kill (bank_proc, - SIGTERM); - GNUNET_OS_process_wait (bank_proc); - GNUNET_OS_process_destroy (bank_proc); - BANK_FAIL (); - } - fprintf (stderr, "."); - sleep (1); - iter++; + fprintf ( + stderr, + "Failed to launch `taler-bank-manage' (or `wget')\n"); + GNUNET_OS_process_kill (bank_proc, + SIGTERM); + GNUNET_OS_process_wait (bank_proc); + GNUNET_OS_process_destroy (bank_proc); + BANK_FAIL (); } + fprintf (stderr, "."); + sleep (1); + iter++; + } while (0 != system (wget_cmd)); fprintf (stderr, "\n"); @@ -183,11 +183,11 @@ TALER_TESTING_prepare_bank (const char *config_filename) cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_load - (cfg, config_filename)) + (cfg, config_filename)) BANK_FAIL (); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string - (cfg, "bank", "DATABASE", &database)) + (cfg, "bank", "DATABASE", &database)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "bank", @@ -197,7 +197,7 @@ TALER_TESTING_prepare_bank (const char *config_filename) } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number - (cfg, "bank", "HTTP_PORT", &port)) + (cfg, "bank", "HTTP_PORT", &port)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "bank", @@ -208,27 +208,27 @@ TALER_TESTING_prepare_bank (const char *config_filename) GNUNET_CONFIGURATION_destroy (cfg); if (GNUNET_OK != GNUNET_NETWORK_test_port_free - (IPPROTO_TCP, (uint16_t) port)) + (IPPROTO_TCP, (uint16_t) port)) { fprintf (stderr, "Required port %llu not available, skipping.\n", - port); + port); BANK_FAIL (); } /* DB preparation */ if (NULL == - (dbreset_proc = GNUNET_OS_start_process ( - GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-bank-manage", - "taler-bank-manage", - "-c", "bank.conf", - "--with-db", database, - "django", - "flush", - "--no-input", NULL))) + (dbreset_proc = GNUNET_OS_start_process ( + GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-bank-manage", + "taler-bank-manage", + "-c", "bank.conf", + "--with-db", database, + "django", + "flush", + "--no-input", NULL))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to flush the bank db.\n"); |