From 3fa213e41e82a93f8f5c5cd59b599ff78d0acc3a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 15 Jan 2020 11:14:11 +0100 Subject: fix test issues --- src/bank-lib/fakebank.c | 55 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 17 deletions(-) (limited to 'src/bank-lib/fakebank.c') diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c index b99b78816..b12b04378 100644 --- a/src/bank-lib/fakebank.c +++ b/src/bank-lib/fakebank.c @@ -888,9 +888,9 @@ parse_history_common_args (struct MHD_Connection *connection, * @return MHD result code */ static int -handle_credit_history (struct TALER_FAKEBANK_Handle *h, - struct MHD_Connection *connection, - const char *account) +handle_debit_history (struct TALER_FAKEBANK_Handle *h, + struct MHD_Connection *connection, + const char *account) { struct HistoryArgs ha; struct Transaction *pos; @@ -939,7 +939,7 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h, while ( (0 != ha.delta) && (NULL != pos) ) { - if ( (0 == strcasecmp (pos->credit_account, + if ( (0 == strcasecmp (pos->debit_account, account)) && (T_DEBIT == pos->type) ) { @@ -972,6 +972,14 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h, else ha.delta++; } + else + { + fprintf (stderr, + "Skipping transaction %s->%s: only care about %s\n", + pos->debit_account, + pos->credit_account, + account); + } if (ha.delta > 0) pos = pos->prev; else @@ -994,9 +1002,9 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h, * @return MHD result code */ static int -handle_debit_history (struct TALER_FAKEBANK_Handle *h, - struct MHD_Connection *connection, - const char *account) +handle_credit_history (struct TALER_FAKEBANK_Handle *h, + struct MHD_Connection *connection, + const char *account) { struct HistoryArgs ha; struct Transaction *pos; @@ -1009,7 +1017,6 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h, GNUNET_break (0); return MHD_NO; } - if (! ha.have_start) { pos = (0 > ha.delta) @@ -1045,7 +1052,7 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h, while ( (0 != ha.delta) && (NULL != pos) ) { - if ( (0 == strcasecmp (pos->debit_account, + if ( (0 == strcasecmp (pos->credit_account, account)) && (T_CREDIT == pos->type) ) { @@ -1057,14 +1064,20 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h, pos->credit_account); debit_payto = TALER_payto_xtalerbank_make (h->my_baseurl, account); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Returning transaction %s->%s (%s)\n", + debit_payto, + credit_payto, + TALER_B2S (&pos->subject)); trans = json_pack - ("{s:I, s:o, s:o, s:s, s:s, s:s}", + ("{s:I, s:o, s:o, s:s, s:s, s:o}", "row_id", (json_int_t) pos->row_id, "date", GNUNET_JSON_from_time_abs (pos->date), "amount", TALER_JSON_from_amount (&pos->amount), "credit_account", credit_payto, "debit_account", debit_payto, - "reserve_pub", pos->subject /* we "know" it is OK */); + "reserve_pub", GNUNET_JSON_from_data_auto ( + &pos->subject.credit)); GNUNET_free (credit_payto); GNUNET_free (debit_payto); GNUNET_assert (0 == @@ -1075,6 +1088,14 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h, else ha.delta++; } + else + { + fprintf (stderr, + "Skipping transaction %s->%s: only care about %s\n", + pos->debit_account, + pos->credit_account, + account); + } if (ha.delta > 0) pos = pos->prev; else @@ -1148,17 +1169,17 @@ serve (struct TALER_FAKEBANK_Handle *h, (NULL != account) && (0 == strcasecmp (method, MHD_HTTP_METHOD_GET)) ) - return handle_debit_history (h, - connection, - account); + return handle_credit_history (h, + connection, + account); if ( (0 == strcmp (url, "/history/outgoing")) && (NULL != account) && (0 == strcasecmp (method, MHD_HTTP_METHOD_GET)) ) - return handle_credit_history (h, - connection, - account); + return handle_debit_history (h, + connection, + account); /* Unexpected URL path, just close the connection. */ /* we're rather impolite here, but it's a testcase. */ -- cgit v1.2.3