diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-05-10 16:55:08 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-05-10 16:55:14 +0200 |
commit | 474f374d2d9b16d32a451d47092119dfb414c244 (patch) | |
tree | aa64710e53f5921beb155c36dc25362d91ccdb3c | |
parent | 6bf006e6364e0f1ae5d3afa079260f851a321a4c (diff) |
improve history error reporting by test
-rw-r--r-- | src/bank-lib/test_bank_interpreter.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/bank-lib/test_bank_interpreter.c b/src/bank-lib/test_bank_interpreter.c index b1eb477d9..bf797f2cb 100644 --- a/src/bank-lib/test_bank_interpreter.c +++ b/src/bank-lib/test_bank_interpreter.c @@ -335,6 +335,43 @@ build_history (struct InterpreterState *is, /** + * Log which history we expected. + * + * @param h what we expected + * @param h_len number of entries in @a h + * @param off position of the missmatch + */ +static void +print_expected (struct History *h, + uint64_t h_len, + unsigned int off) +{ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Transaction history missmatch at position %u/%llu\n", + off, + (unsigned long long) h_len); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Expected history\n"); + for (uint64_t i=0;i<h_len;i++) + { + char *acc; + + acc = json_dumps (h[i].details.account_details, + JSON_COMPACT); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "H(%llu): %s%s (serial: %llu, subject: %s, to: %s)\n", + (unsigned long long) i, + (TALER_BANK_DIRECTION_CREDIT == h[i].direction) ? "+" : "-", + TALER_amount2s (&h[i].details.amount), + (unsigned long long) h[i].serial_id, + h[i].details.wire_transfer_subject, + acc); + GNUNET_free_non_null (acc); + } +} + + +/** * Free history @a h of length @a h_len. * * @param h history array to free @@ -402,13 +439,13 @@ check_result (struct InterpreterState *is, "Test says history has at most %u results, but got result #%u to check\n", (unsigned int) total, off); - free_history (h, - total); + print_expected (h, total, off); return GNUNET_SYSERR; } if (h[off].direction != dir) { GNUNET_break (0); + print_expected (h, total, off); free_history (h, total); return GNUNET_SYSERR; @@ -422,6 +459,7 @@ check_result (struct InterpreterState *is, details->account_details)) ) { GNUNET_break (0); + print_expected (h, total, off); free_history (h, total); return GNUNET_SYSERR; |