summaryrefslogtreecommitdiff
path: root/src/bank-lib/fakebank.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-12-10 16:02:03 +0100
committerChristian Grothoff <christian@grothoff.org>2017-12-10 16:02:03 +0100
commit6623afa2a306a6c00f414ddd75aa51fe464cae56 (patch)
tree1bb995ad3b7623531f6573f8550ac7005b23f6be /src/bank-lib/fakebank.c
parentd36de3bdd6b4e5d88b8c44e525c4eeab43b26837 (diff)
downloadexchange-6623afa2a306a6c00f414ddd75aa51fe464cae56.tar.gz
exchange-6623afa2a306a6c00f414ddd75aa51fe464cae56.tar.bz2
exchange-6623afa2a306a6c00f414ddd75aa51fe464cae56.zip
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/fakebank.c')
-rw-r--r--src/bank-lib/fakebank.c60
1 files changed, 40 insertions, 20 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 */