summaryrefslogtreecommitdiff
path: root/src/bank-lib/test_bank_interpreter.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-05-03 06:15:09 +0200
committerChristian Grothoff <christian@grothoff.org>2016-05-03 06:15:09 +0200
commitf2b7e362690c23ffa0c17688ed58163240217d80 (patch)
tree1fe58d48ff6313ca25a0a465ac8e991c41be547e /src/bank-lib/test_bank_interpreter.c
parenteabbafc4dfdee936135451aa70000b53d0337430 (diff)
downloadexchange-f2b7e362690c23ffa0c17688ed58163240217d80.tar.gz
exchange-f2b7e362690c23ffa0c17688ed58163240217d80.tar.bz2
exchange-f2b7e362690c23ffa0c17688ed58163240217d80.zip
finish tests for #4437
Diffstat (limited to 'src/bank-lib/test_bank_interpreter.c')
-rw-r--r--src/bank-lib/test_bank_interpreter.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/bank-lib/test_bank_interpreter.c b/src/bank-lib/test_bank_interpreter.c
index 7fff8be2..39129a54 100644
--- a/src/bank-lib/test_bank_interpreter.c
+++ b/src/bank-lib/test_bank_interpreter.c
@@ -96,7 +96,6 @@ fail (struct InterpreterState *is)
}
-#if 0
/**
* Find a command by label.
*
@@ -127,7 +126,6 @@ find_command (const struct InterpreterState *is,
label);
return NULL;
}
-#endif
/**
@@ -156,7 +154,7 @@ add_incoming_cb (void *cls,
struct TBI_Command *cmd = &is->commands[is->ip];
cmd->details.admin_add_incoming.aih = NULL;
- if (cmd->expected_response_code != http_status)
+ if (cmd->details.admin_add_incoming.expected_response_code != http_status)
{
GNUNET_break (0);
fprintf (stderr,
@@ -186,6 +184,8 @@ interpreter_run (void *cls)
{
struct InterpreterState *is = cls;
struct TBI_Command *cmd = &is->commands[is->ip];
+ const struct TBI_Command *ref;
+ struct TALER_WireTransferIdentifierRawP wtid;
struct TALER_Amount amount;
const struct GNUNET_SCHEDULER_TaskContext *tc;
@@ -205,7 +205,6 @@ interpreter_run (void *cls)
GNUNET_SCHEDULER_shutdown ();
return;
case TBI_OC_ADMIN_ADD_INCOMING:
-
if (GNUNET_OK !=
TALER_string_to_amount (cmd->details.admin_add_incoming.amount,
&amount))
@@ -236,6 +235,46 @@ interpreter_run (void *cls)
return;
}
return;
+ case TBI_OC_EXPECT_TRANSACTION:
+ ref = find_command (is,
+ cmd->details.expect_transaction.cmd_ref);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (ref->details.admin_add_incoming.amount,
+ &amount));
+ if (GNUNET_OK !=
+ FAKEBANK_check (is->fakebank,
+ &amount,
+ ref->details.admin_add_incoming.debit_account_no,
+ ref->details.admin_add_incoming.credit_account_no,
+ &wtid))
+ {
+ GNUNET_break (0);
+ fail (is);
+ return;
+ }
+ if (0 != memcmp (&wtid,
+ &ref->details.admin_add_incoming.wtid,
+ sizeof (wtid)))
+ {
+ GNUNET_break (0);
+ fail (is);
+ return;
+ }
+ is->ip++;
+ is->task = GNUNET_SCHEDULER_add_now (&interpreter_run,
+ is);
+ return;
+ case TBI_OC_EXPECT_TRANSACTIONS_EMPTY:
+ if (GNUNET_OK != FAKEBANK_check_empty (is->fakebank))
+ {
+ GNUNET_break (0);
+ fail (is);
+ return;
+ }
+ is->ip++;
+ is->task = GNUNET_SCHEDULER_add_now (&interpreter_run,
+ is);
+ return;
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unknown instruction %d at %u (%s)\n",