finish tests for #4437
This commit is contained in:
parent
eabbafc4df
commit
f2b7e36269
@ -42,7 +42,7 @@ run (void *cls)
|
||||
/* Add EUR:5.01 to account 42 */
|
||||
{ .oc = TBI_OC_ADMIN_ADD_INCOMING,
|
||||
.label = "deposit-1",
|
||||
.expected_response_code = MHD_HTTP_OK,
|
||||
.details.admin_add_incoming.expected_response_code = MHD_HTTP_OK,
|
||||
.details.admin_add_incoming.credit_account_no = 1,
|
||||
.details.admin_add_incoming.debit_account_no = 2,
|
||||
.details.admin_add_incoming.amount = "PUDOS:5.01" },
|
||||
|
@ -39,14 +39,30 @@ run (void *cls)
|
||||
int *resultp = cls;
|
||||
static struct TBI_Command commands[] =
|
||||
{
|
||||
/* Add EUR:5.01 to account 42 */
|
||||
/* Add EUR:5.01 to account 1 */
|
||||
{ .oc = TBI_OC_ADMIN_ADD_INCOMING,
|
||||
.label = "deposit-1",
|
||||
.expected_response_code = MHD_HTTP_OK,
|
||||
.details.admin_add_incoming.expected_response_code = MHD_HTTP_OK,
|
||||
.details.admin_add_incoming.credit_account_no = 1,
|
||||
.details.admin_add_incoming.debit_account_no = 2,
|
||||
.details.admin_add_incoming.amount = "PUDOS:5.01" },
|
||||
|
||||
/* Add EUR:3.21 to account 3 */
|
||||
{ .oc = TBI_OC_ADMIN_ADD_INCOMING,
|
||||
.label = "deposit-2",
|
||||
.details.admin_add_incoming.expected_response_code = MHD_HTTP_OK,
|
||||
.details.admin_add_incoming.credit_account_no = 3,
|
||||
.details.admin_add_incoming.debit_account_no = 2,
|
||||
.details.admin_add_incoming.amount = "PUDOS:3.21" },
|
||||
/* check transactions arrived at fakebank */
|
||||
{ .oc = TBI_OC_EXPECT_TRANSACTION,
|
||||
.label = "expect-2",
|
||||
.details.expect_transaction.cmd_ref = "deposit-2" },
|
||||
{ .oc = TBI_OC_EXPECT_TRANSACTION,
|
||||
.label = "expect-1",
|
||||
.details.expect_transaction.cmd_ref = "deposit-1" },
|
||||
/* check transaction list is now empty */
|
||||
{ .oc = TBI_OC_EXPECT_TRANSACTIONS_EMPTY,
|
||||
.label = "expect-empty" },
|
||||
{ .oc = TBI_OC_END }
|
||||
};
|
||||
|
||||
|
@ -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",
|
||||
|
@ -42,7 +42,17 @@ enum TBI_OpCode
|
||||
/**
|
||||
* Add funds to a reserve by (faking) incoming wire transfer.
|
||||
*/
|
||||
TBI_OC_ADMIN_ADD_INCOMING
|
||||
TBI_OC_ADMIN_ADD_INCOMING,
|
||||
|
||||
/**
|
||||
* Expect that we have received the specified transaction at fakebank.
|
||||
*/
|
||||
TBI_OC_EXPECT_TRANSACTION,
|
||||
|
||||
/**
|
||||
* Expect that we have exhaustively gone over all transactions at fakebank.
|
||||
*/
|
||||
TBI_OC_EXPECT_TRANSACTIONS_EMPTY
|
||||
|
||||
};
|
||||
|
||||
@ -62,11 +72,6 @@ struct TBI_Command
|
||||
*/
|
||||
const char *label;
|
||||
|
||||
/**
|
||||
* Which response code do we expect for this command?
|
||||
*/
|
||||
unsigned int expected_response_code;
|
||||
|
||||
/**
|
||||
* Details about the command.
|
||||
*/
|
||||
@ -100,6 +105,11 @@ struct TBI_Command
|
||||
*/
|
||||
struct TALER_WireTransferIdentifierRawP wtid;
|
||||
|
||||
/**
|
||||
* Which response code do we expect for this command?
|
||||
*/
|
||||
unsigned int expected_response_code;
|
||||
|
||||
/**
|
||||
* Set to the API's handle during the operation.
|
||||
*/
|
||||
@ -107,6 +117,20 @@ struct TBI_Command
|
||||
|
||||
} admin_add_incoming;
|
||||
|
||||
/**
|
||||
* If @e opcode is #TBI_OC_EXPECT_TRANSACTION, this
|
||||
* specifies which transaction we expected.
|
||||
*/
|
||||
struct {
|
||||
|
||||
/**
|
||||
* Label of the command of an /admin/add/incoming
|
||||
* request that we should check was executed.
|
||||
*/
|
||||
const char *cmd_ref;
|
||||
|
||||
} expect_transaction;
|
||||
|
||||
} details;
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user