aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-04-20 09:04:20 +0200
committerChristian Grothoff <christian@grothoff.org>2017-04-20 09:04:20 +0200
commit92d9ec69e6d8e9f7eb0be0d6a7f67444189b319e (patch)
treeeb4c2c115b6d1e6561bb81bd16ccd56b93923269
parent487237381dc81c16878b2e3faaac37777b6dd7bf (diff)
expand testcase to cover new DB API
-rw-r--r--src/exchangedb/plugin_exchangedb_common.c12
-rw-r--r--src/exchangedb/test_exchangedb.c36
2 files changed, 43 insertions, 5 deletions
diff --git a/src/exchangedb/plugin_exchangedb_common.c b/src/exchangedb/plugin_exchangedb_common.c
index b97aa08c2..ba182d425 100644
--- a/src/exchangedb/plugin_exchangedb_common.c
+++ b/src/exchangedb/plugin_exchangedb_common.c
@@ -34,13 +34,13 @@ common_free_reserve_history (void *cls,
struct TALER_EXCHANGEDB_CollectableBlindcoin *cbc;
struct TALER_EXCHANGEDB_Payback *payback;
struct TALER_EXCHANGEDB_ReserveHistory *backref;
-
+ struct TALER_EXCHANGEDB_ClosingTransfer *closing;
+
while (NULL != rh)
{
switch(rh->type)
{
case TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE:
- case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
bt = rh->details.bank;
if (NULL != bt->sender_account_details)
json_decref (bt->sender_account_details);
@@ -60,6 +60,14 @@ common_free_reserve_history (void *cls,
GNUNET_CRYPTO_rsa_public_key_free (payback->coin.denom_pub.rsa_public_key);
GNUNET_free (payback);
break;
+ case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
+ closing = rh->details.closing;
+ if (NULL != closing->receiver_account_details)
+ json_decref (closing->receiver_account_details);
+ if (NULL != closing->transfer_details)
+ json_decref (closing->transfer_details);
+ GNUNET_free (closing);
+ break;
}
backref = rh;
rh = rh->next;
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 330380d31..83949d855 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -295,6 +295,7 @@ static struct TALER_Amount fee_withdraw;
static struct TALER_Amount fee_deposit;
static struct TALER_Amount fee_refresh;
static struct TALER_Amount fee_refund;
+static struct TALER_Amount fee_closing;
static struct TALER_Amount amount_with_fee;
@@ -1611,7 +1612,25 @@ run (void *cls)
&value,
&cbc.h_coin_envelope,
deadline));
-
+ sndr = json_loads ("{ \"account\":\"1\" }", 0, NULL);
+ just = json_loads ("{ \"trans-details\":\"2\" }", 0, NULL);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":0.000010",
+ &fee_closing));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":1.000010",
+ &amount_with_fee));
+ FAILIF (GNUNET_OK !=
+ plugin->insert_reserve_closed (plugin->cls,
+ session,
+ &reserve_pub,
+ GNUNET_TIME_absolute_get (),
+ sndr /* receiver_account */,
+ just /* transfer_details */,
+ &amount_with_fee,
+ &fee_closing));
+ json_decref (just);
+ json_decref (sndr);
result = 7;
rh = plugin->get_reserve_history (plugin->cls,
session,
@@ -1664,11 +1683,22 @@ run (void *cls)
}
break;
case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
- GNUNET_break (0); /* FIXME: #4956 */
+ {
+ struct TALER_EXCHANGEDB_ClosingTransfer *closing
+ = rh_head->details.closing;
+
+ FAILIF (0 != memcmp (&closing->reserve_pub,
+ &reserve_pub,
+ sizeof (reserve_pub)));
+ FAILIF (0 != TALER_amount_cmp (&closing->amount,
+ &amount_with_fee));
+ FAILIF (0 != TALER_amount_cmp (&closing->closing_fee,
+ &fee_closing));
+ }
break;
}
}
- FAILIF (4 != cnt);
+ FAILIF (5 != cnt);
auditor_row_cnt = 0;
FAILIF (GNUNET_OK !=