diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-12-10 16:02:03 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-12-10 16:02:03 +0100 |
commit | 6623afa2a306a6c00f414ddd75aa51fe464cae56 (patch) | |
tree | 1bb995ad3b7623531f6573f8550ac7005b23f6be /src/bank-lib | |
parent | d36de3bdd6b4e5d88b8c44e525c4eeab43b26837 (diff) | |
download | exchange-6623afa2a306a6c00f414ddd75aa51fe464cae56.tar.xz |
add testcase for #5077 (passes), start to reduce use of exchange's admin/add/incoming (#5172, more to come)
Diffstat (limited to 'src/bank-lib')
-rw-r--r-- | src/bank-lib/fakebank.c | 60 | ||||
-rw-r--r-- | src/bank-lib/test_bank_interpreter.c | 42 |
2 files changed, 44 insertions, 58 deletions
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c index 39ba6d7a6..bd1b3b225 100644 --- a/src/bank-lib/fakebank.c +++ b/src/bank-lib/fakebank.c @@ -86,6 +86,13 @@ struct Transaction * Flag set if the transfer was rejected. */ int rejected; + + /** + * Has this transaction been subjected to #TALER_FAKEBANK_check() + * and should thus no longer be counted in + * #TALER_FAKEBANK_check_empty()? + */ + int checked; }; @@ -150,15 +157,12 @@ TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h, (want_credit == t->credit_account) && (0 == TALER_amount_cmp (want_amount, &t->amount)) && + (GNUNET_NO == t->checked) && (0 == strcasecmp (exchange_base_url, t->exchange_base_url)) ) { - GNUNET_CONTAINER_DLL_remove (h->transactions_head, - h->transactions_tail, - t); - *subject = t->subject; - GNUNET_free (t->exchange_base_url); - GNUNET_free (t); + *subject = GNUNET_strdup (t->subject); + t->checked = GNUNET_YES; return GNUNET_OK; } } @@ -168,6 +172,8 @@ TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h, { char *s; + if (GNUNET_YES == t->checked) + continue; s = TALER_amount_to_string (&t->amount); fprintf (stderr, "%llu -> %llu (%s) from %s\n", @@ -262,23 +268,35 @@ TALER_FAKEBANK_check_empty (struct TALER_FAKEBANK_Handle *h) { struct Transaction *t; - if (NULL == h->transactions_head) + t = h->transactions_head; + while (NULL != t) + { + if ( (GNUNET_YES != t->checked) && + (GNUNET_YES != t->rejected) ) + break; + t = t->next; + } + if (NULL == t) return GNUNET_OK; - fprintf (stderr, "Expected empty transaction set, but I have:\n"); - for (t = h->transactions_head; NULL != t; t = t->next) + while (NULL != t) { - char *s; - - s = TALER_amount_to_string (&t->amount); - fprintf (stderr, - "%llu -> %llu (%s) from %s\n", - (unsigned long long) t->debit_account, - (unsigned long long) t->credit_account, - s, - t->exchange_base_url); - GNUNET_free (s); + if ( (GNUNET_YES != t->checked) && + (GNUNET_YES != t->rejected) ) + { + char *s; + + s = TALER_amount_to_string (&t->amount); + fprintf (stderr, + "%llu -> %llu (%s) from %s\n", + (unsigned long long) t->debit_account, + (unsigned long long) t->credit_account, + s, + t->exchange_base_url); + GNUNET_free (s); + } + t = t->next; } return GNUNET_SYSERR; } @@ -748,7 +766,9 @@ handle_history (struct TALER_FAKEBANK_Handle *h, break; if (NULL == pos) { - GNUNET_break (0); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Invalid range specified, transaction %llu not known!\n", + (unsigned long long) start_number); return MHD_NO; } /* range is exclusive, skip the matching entry */ diff --git a/src/bank-lib/test_bank_interpreter.c b/src/bank-lib/test_bank_interpreter.c index 0dfc4c401..ab41ed611 100644 --- a/src/bank-lib/test_bank_interpreter.c +++ b/src/bank-lib/test_bank_interpreter.c @@ -159,35 +159,6 @@ test_cancelled (struct InterpreterState *is, /** - * Test if the /admin/add/incoming transaction at offset @a off - * has been #TBI_OC_EXPECT_TRANSFER treated, and thus been - * forgotten by the fakebank. - * - * @param is interpreter state (where we are right now) - * @param off offset of the command to test for rejection - * @return #GNUNET_YES if the command at @a off was cancelled - */ -static int -test_deleted_by_expected (struct InterpreterState *is, - unsigned int off) -{ - const struct TBI_Command *cmd = &is->commands[off]; - - for (unsigned int i=0;i<is->ip;i++) - { - const struct TBI_Command *c = &is->commands[i]; - - if (TBI_OC_EXPECT_TRANSFER != c->oc) - continue; - if (0 == strcmp (c->details.expect_transfer.cmd_ref, - cmd->label)) - return GNUNET_YES; - } - return GNUNET_NO; -} - - -/** * Item in the transaction history, as reconstructed from the * command history. */ @@ -286,10 +257,6 @@ build_history (struct InterpreterState *is, continue; /* skip until we find the marker */ if (total >= cmd->details.history.num_results * inc) break; /* hit limit specified by command */ - if (GNUNET_YES == - test_deleted_by_expected (is, - off)) - continue; cancelled = test_cancelled (is, off); if ( (GNUNET_YES == cancelled) && @@ -335,11 +302,6 @@ build_history (struct InterpreterState *is, continue; /* skip until we find the marker */ if (total >= cmd->details.history.num_results * inc) break; /* hit limit specified by command */ - if (GNUNET_YES == - test_deleted_by_expected (is, - off)) - continue; - if ( ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) && @@ -787,6 +749,10 @@ interpreter_run (void *cls) case 2: auth.details.basic.username = "Exchange"; break; + case 3: + auth.details.basic.username = "user3"; + auth.details.basic.password = "pass3"; + break; default: GNUNET_break (0); break; |