improve history error reporting by test
This commit is contained in:
parent
6bf006e636
commit
474f374d2d
@ -334,6 +334,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.
|
* Free history @a h of length @a h_len.
|
||||||
*
|
*
|
||||||
@ -402,13 +439,13 @@ check_result (struct InterpreterState *is,
|
|||||||
"Test says history has at most %u results, but got result #%u to check\n",
|
"Test says history has at most %u results, but got result #%u to check\n",
|
||||||
(unsigned int) total,
|
(unsigned int) total,
|
||||||
off);
|
off);
|
||||||
free_history (h,
|
print_expected (h, total, off);
|
||||||
total);
|
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
if (h[off].direction != dir)
|
if (h[off].direction != dir)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
print_expected (h, total, off);
|
||||||
free_history (h,
|
free_history (h,
|
||||||
total);
|
total);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -422,6 +459,7 @@ check_result (struct InterpreterState *is,
|
|||||||
details->account_details)) )
|
details->account_details)) )
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
print_expected (h, total, off);
|
||||||
free_history (h,
|
free_history (h,
|
||||||
total);
|
total);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
|
Loading…
Reference in New Issue
Block a user