diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-10-30 17:36:57 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-10-30 17:36:57 +0100 |
commit | 2d55647f2aab1feb37d5439049f6824d11cda56c (patch) | |
tree | aef525c04a030b318a97b9d8ae77573ca73a8237 /src/auditordb/test_auditordb.c | |
parent | 38a078d543f53ca4925ea364919306395e7e4597 (diff) |
add support for reserve open/close operations to auditor, begin to split off purse auditing logic
Diffstat (limited to 'src/auditordb/test_auditordb.c')
-rw-r--r-- | src/auditordb/test_auditordb.c | 823 |
1 files changed, 409 insertions, 414 deletions
diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c index 1e5ca7553..d39d08b91 100644 --- a/src/auditordb/test_auditordb.c +++ b/src/auditordb/test_auditordb.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2016 Taler Systems SA + Copyright (C) 2016--2022 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -17,17 +17,17 @@ * @file auditordb/test_auditordb.c * @brief test cases for DB interaction functions * @author Gabor X Toth + * @author Christian Grothoff */ #include "platform.h" #include <gnunet/gnunet_db_lib.h> #include "taler_auditordb_lib.h" #include "taler_auditordb_plugin.h" - /** - * Global result from the testcase. + * Currency we use, must match CURRENCY in "test-auditor-db-postgres.conf". */ -static int result = -1; +#define CURRENCY "EUR" /** * Report line of error if @a cond is true, and jump to label "drop". @@ -39,7 +39,6 @@ static int result = -1; goto drop; \ } while (0) - /** * Initializes @a ptr with random data. */ @@ -54,15 +53,124 @@ static int result = -1; /** - * Currency we use, must match CURRENCY in "test-auditor-db-postgres.conf". + * Global result from the testcase. */ -#define CURRENCY "EUR" +static int result = -1; + +/** + * Hash of denomination public key. + */ +static struct TALER_DenominationHashP denom_pub_hash; + +/** + * Another hash of a denomination public key. + */ +static struct TALER_DenominationHashP rnd_hash; + +/** + * Current time. + */ +static struct GNUNET_TIME_Timestamp now; + +/** + * Timestamp in the past. + */ +static struct GNUNET_TIME_Timestamp past; + +/** + * Timestamp in the future. + */ +static struct GNUNET_TIME_Timestamp future; /** * Database plugin under test. */ static struct TALER_AUDITORDB_Plugin *plugin; +/** + * Historic denomination revenue value. + */ +static struct TALER_Amount rbalance; + +/** + * Historic denomination loss value. + */ +static struct TALER_Amount rloss; + +/** + * Reserve profit value we are using. + */ +static struct TALER_Amount reserve_profits; + + +static enum GNUNET_GenericReturnValue +select_historic_denom_revenue_result ( + void *cls, + const struct TALER_DenominationHashP *denom_pub_hash2, + struct GNUNET_TIME_Timestamp revenue_timestamp2, + const struct TALER_Amount *revenue_balance2, + const struct TALER_Amount *loss2) +{ + static int n = 0; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "select_historic_denom_revenue_result: row %u\n", n); + + if ( (2 <= n++) + || (cls != NULL) + || ((0 != GNUNET_memcmp (&revenue_timestamp2, + &past)) + && (0 != GNUNET_memcmp (&revenue_timestamp2, + &now))) + || ((0 != GNUNET_memcmp (denom_pub_hash2, + &denom_pub_hash)) + && (0 != GNUNET_memcmp (denom_pub_hash2, + &rnd_hash))) + || (0 != TALER_amount_cmp (revenue_balance2, + &rbalance)) + || (0 != TALER_amount_cmp (loss2, + &rloss))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "select_historic_denom_revenue_result: result does not match\n"); + GNUNET_break (0); + return GNUNET_SYSERR; + } + return GNUNET_OK; +} + + +static enum GNUNET_GenericReturnValue +select_historic_reserve_revenue_result ( + void *cls, + struct GNUNET_TIME_Timestamp start_time2, + struct GNUNET_TIME_Timestamp end_time2, + const struct TALER_Amount *reserve_profits2) +{ + static int n = 0; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "select_historic_reserve_revenue_result: row %u\n", n); + + if ((2 <= n++) + || (cls != NULL) + || ((0 != GNUNET_memcmp (&start_time2, + &past)) + && (0 != GNUNET_memcmp (&start_time2, + &now))) + || (0 != GNUNET_memcmp (&end_time2, + &future)) + || (0 != TALER_amount_cmp (reserve_profits2, + &reserve_profits))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "select_historic_reserve_revenue_result: result does not match\n"); + GNUNET_break (0); + return GNUNET_SYSERR; + } + return GNUNET_OK; +} + /** * Main function that will be run by the scheduler. @@ -130,13 +238,8 @@ run (void *cls) struct TALER_MasterPublicKeyP master_pub; struct TALER_ReservePublicKeyP reserve_pub; - struct TALER_DenominationHashP rnd_hash; struct TALER_DenominationPrivateKey denom_priv; struct TALER_DenominationPublicKey denom_pub; - struct TALER_DenominationHashP denom_pub_hash; - struct GNUNET_TIME_Timestamp now; - struct GNUNET_TIME_Timestamp past; - struct GNUNET_TIME_Timestamp future; struct GNUNET_TIME_Timestamp date; RND_BLK (&master_pub); @@ -217,472 +320,364 @@ run (void *cls) (ppc.last_refund_serial_id != ppc2.last_refund_serial_id) || (ppc.last_withdraw_serial_id != ppc2.last_withdraw_serial_id) ); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: insert_reserve_info\n"); - - struct TALER_Amount reserve_balance; - struct TALER_Amount withdraw_fee_balance; - struct TALER_Amount purse_fee_balance; - struct TALER_Amount history_fee_balance; - struct TALER_Amount reserve_balance2 = {}; - struct TALER_Amount withdraw_fee_balance2 = {}; - struct TALER_Amount purse_fee_balance2 = {}; - struct TALER_Amount history_fee_balance2 = {}; - - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":12.345678", - &reserve_balance)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":23.456789", - &withdraw_fee_balance)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":23.456789", - &purse_fee_balance)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":23.456789", - &history_fee_balance)); - - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_reserve_info (plugin->cls, - &reserve_pub, - &master_pub, - &reserve_balance, - &withdraw_fee_balance, - past, - "payto://bla/blub")); - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: update_reserve_info\n"); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->update_reserve_info (plugin->cls, - &reserve_pub, - &master_pub, - &reserve_balance, - &withdraw_fee_balance, - future)); - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: get_reserve_info\n"); - - char *payto; + { + struct TALER_AUDITORDB_ReserveFeeBalance rfb; + struct TALER_AUDITORDB_ReserveFeeBalance rfb2; - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_reserve_info (plugin->cls, - &reserve_pub, - &master_pub, - &rowid, - &reserve_balance2, - &withdraw_fee_balance2, - &date, - &payto)); - FAILIF (0 != strcmp (payto, - "payto://bla/blub")); - GNUNET_free (payto); - FAILIF (0 != GNUNET_memcmp (&date, - &future) - || 0 != TALER_amount_cmp (&reserve_balance2, - &reserve_balance) - || 0 != TALER_amount_cmp (&withdraw_fee_balance2, - &withdraw_fee_balance)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: insert_reserve_info\n"); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":12.345678", + &rfb.reserve_balance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":11.245678", + &rfb.reserve_loss)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":23.456789", + &rfb.withdraw_fee_balance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":23.456719", + &rfb.close_fee_balance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":33.456789", + &rfb.purse_fee_balance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":43.456789", + &rfb.open_fee_balance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":53.456789", + &rfb.history_fee_balance)); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->insert_reserve_info (plugin->cls, + &reserve_pub, + &master_pub, + &rfb, + past, + "payto://bla/blub")); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: update_reserve_info\n"); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->update_reserve_info (plugin->cls, + &reserve_pub, + &master_pub, + &rfb, + future)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: get_reserve_info\n"); + { + char *payto; + + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->get_reserve_info (plugin->cls, + &reserve_pub, + &master_pub, + &rowid, + &rfb2, + &date, + &payto)); + FAILIF (0 != strcmp (payto, + "payto://bla/blub")); + GNUNET_free (payto); + } + FAILIF ( (0 != GNUNET_memcmp (&date, + &future)) + || (0 != TALER_amount_cmp (&rfb2.reserve_balance, + &rfb.reserve_balance)) + || (0 != TALER_amount_cmp (&rfb2.withdraw_fee_balance, + &rfb.withdraw_fee_balance)) + || (0 != TALER_amount_cmp (&rfb2.close_fee_balance, + &rfb.close_fee_balance)) + || (0 != TALER_amount_cmp (&rfb2.purse_fee_balance, + &rfb.purse_fee_balance)) + || (0 != TALER_amount_cmp (&rfb2.open_fee_balance, + &rfb.open_fee_balance)) + || (0 != TALER_amount_cmp (&rfb2.history_fee_balance, + &rfb.history_fee_balance)) + ); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: insert_reserve_summary\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: insert_reserve_summary\n"); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_reserve_summary (plugin->cls, - &master_pub, - &reserve_balance, - &withdraw_fee_balance, - &purse_fee_balance, - &history_fee_balance)); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->insert_reserve_summary (plugin->cls, + &master_pub, + &rfb)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: update_reserve_summary\n"); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->update_reserve_summary (plugin->cls, + &master_pub, + &rfb)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: get_reserve_summary\n"); + ZR_BLK (&rfb2); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->get_reserve_summary (plugin->cls, + &master_pub, + &rfb2)); + FAILIF ( (0 != TALER_amount_cmp (&rfb2.reserve_balance, + &rfb.reserve_balance) || + (0 != TALER_amount_cmp (&rfb2.withdraw_fee_balance, + &rfb.withdraw_fee_balance)) || + (0 != TALER_amount_cmp (&rfb2.close_fee_balance, + &rfb.close_fee_balance)) || + (0 != TALER_amount_cmp (&rfb2.purse_fee_balance, + &rfb.purse_fee_balance)) || + (0 != TALER_amount_cmp (&rfb2.open_fee_balance, + &rfb.open_fee_balance)) || + (0 != TALER_amount_cmp (&rfb2.history_fee_balance, + &rfb.history_fee_balance)))); + } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: update_reserve_summary\n"); + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: insert_denomination_balance\n"); + + struct TALER_AUDITORDB_DenominationCirculationData dcd; + struct TALER_AUDITORDB_DenominationCirculationData dcd2; + + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":12.345678", + &dcd.denom_balance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":0.1", + &dcd.denom_loss)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":13.57986", + &dcd.denom_risk)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":12.57986", + &dcd.recoup_loss)); + dcd.num_issued = 62; + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->insert_denomination_balance (plugin->cls, + &denom_pub_hash, + &dcd)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: update_denomination_balance\n"); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->update_denomination_balance (plugin->cls, + &denom_pub_hash, + &dcd)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: get_denomination_balance\n"); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->update_reserve_summary (plugin->cls, - &master_pub, - &reserve_balance, - &withdraw_fee_balance, - &purse_fee_balance, - &history_fee_balance)); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->get_denomination_balance (plugin->cls, + &denom_pub_hash, + &dcd2)); + FAILIF (0 != TALER_amount_cmp (&dcd2.denom_balance, + &dcd.denom_balance)); + FAILIF (0 != TALER_amount_cmp (&dcd2.denom_loss, + &dcd.denom_loss)); + FAILIF (0 != TALER_amount_cmp (&dcd2.denom_risk, + &dcd.denom_risk)); + FAILIF (0 != TALER_amount_cmp (&dcd2.recoup_loss, + &dcd.recoup_loss)); + FAILIF (dcd2.num_issued != dcd.num_issued); + } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: get_reserve_summary\n"); + { + struct TALER_AUDITORDB_GlobalCoinBalance gcb; + struct TALER_AUDITORDB_GlobalCoinBalance gcb2; + + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":12.345678", + &gcb.total_escrowed)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":23.456789", + &gcb.deposit_fee_balance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":34.567890", + &gcb.melt_fee_balance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":45.678901", + &gcb.refund_fee_balance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":55.678901", + &gcb.purse_fee_balance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":65.678901", + &gcb.open_deposit_fee_balance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":13.57986", + &gcb.risk)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":0.1", + &gcb.loss)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":1.1", + &gcb.irregular_loss)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: insert_balance_summary\n"); - ZR_BLK (&reserve_balance2); - ZR_BLK (&withdraw_fee_balance2); - ZR_BLK (&purse_fee_balance2); - ZR_BLK (&history_fee_balance2); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->insert_balance_summary (plugin->cls, + &master_pub, + &gcb)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: update_balance_summary\n"); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->update_balance_summary (plugin->cls, + &master_pub, + &gcb)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: get_balance_summary\n"); + ZR_BLK (&gcb2); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->get_balance_summary (plugin->cls, + &master_pub, + &gcb2)); + FAILIF (0 != TALER_amount_cmp (&gcb2.total_escrowed, + &gcb.total_escrowed)); + FAILIF (0 != TALER_amount_cmp (&gcb2.deposit_fee_balance, + &gcb.deposit_fee_balance) ); + FAILIF (0 != TALER_amount_cmp (&gcb2.melt_fee_balance, + &gcb.melt_fee_balance) ); + FAILIF (0 != TALER_amount_cmp (&gcb2.refund_fee_balance, + &gcb.refund_fee_balance)); + FAILIF (0 != TALER_amount_cmp (&gcb2.purse_fee_balance, + &gcb.purse_fee_balance)); + FAILIF (0 != TALER_amount_cmp (&gcb2.open_deposit_fee_balance, + &gcb.open_deposit_fee_balance)); + FAILIF (0 != TALER_amount_cmp (&gcb2.risk, + &gcb.risk)); + FAILIF (0 != TALER_amount_cmp (&gcb2.loss, + &gcb.loss)); + FAILIF (0 != TALER_amount_cmp (&gcb2.irregular_loss, + &gcb.irregular_loss)); + } - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_reserve_summary (plugin->cls, - &master_pub, - &reserve_balance2, - &withdraw_fee_balance2, - &purse_fee_balance2, - &history_fee_balance2)); - - FAILIF ( (0 != TALER_amount_cmp (&reserve_balance2, - &reserve_balance) || - (0 != TALER_amount_cmp (&withdraw_fee_balance2, - &withdraw_fee_balance)) || - (0 != TALER_amount_cmp (&purse_fee_balance2, - &purse_fee_balance)) || - (0 != TALER_amount_cmp (&history_fee_balance2, - &history_fee_balance)))); GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: insert_denomination_balance\n"); - - struct TALER_Amount denom_balance; - struct TALER_Amount denom_loss; - struct TALER_Amount denom_loss2; - struct TALER_Amount deposit_fee_balance; - struct TALER_Amount melt_fee_balance; - struct TALER_Amount refund_fee_balance; - struct TALER_Amount denom_balance2; - struct TALER_Amount deposit_fee_balance2; - struct TALER_Amount melt_fee_balance2; - struct TALER_Amount refund_fee_balance2; - struct TALER_Amount rbalance; - struct TALER_Amount dbalance; - struct TALER_Amount rbalance2; - struct TALER_Amount dbalance2; - struct TALER_Amount loss; - struct TALER_Amount loss2; - struct TALER_Amount iirp; - struct TALER_Amount iirp2; - uint64_t nissued; - + "Test: insert_historic_denom_revenue\n"); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":12.345678", - &denom_balance)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":0.1", - &denom_loss)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":23.456789", - &deposit_fee_balance)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":34.567890", - &melt_fee_balance)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":45.678901", - &refund_fee_balance)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":13.57986", &rbalance)); GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":12.57986", - &dbalance)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":1.6", - &loss)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":1.1", - &iirp)); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_denomination_balance (plugin->cls, - &denom_pub_hash, - &denom_balance, - &denom_loss, - &rbalance, - &loss, - 42)); - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: update_denomination_balance\n"); - - ppc.last_withdraw_serial_id++; - ppc.last_deposit_serial_id++; - ppc.last_melt_serial_id++; - ppc.last_refund_serial_id++; - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->update_denomination_balance (plugin->cls, - &denom_pub_hash, - &denom_balance, - &denom_loss, - &rbalance, - &loss, - 62)); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: get_denomination_balance\n"); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_denomination_balance (plugin->cls, - &denom_pub_hash, - &denom_balance2, - &denom_loss2, - &rbalance2, - &loss2, - &nissued)); - - FAILIF (0 != GNUNET_memcmp (&denom_balance2, &denom_balance)); - FAILIF (0 != GNUNET_memcmp (&denom_loss2, &denom_loss)); - FAILIF (0 != GNUNET_memcmp (&rbalance2, &rbalance)); - FAILIF (62 != nissued); - - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: insert_balance_summary\n"); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_balance_summary (plugin->cls, - &master_pub, - &refund_fee_balance, - &melt_fee_balance, - &deposit_fee_balance, - &denom_balance, - &rbalance, - &loss, - &iirp)); - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: update_balance_summary\n"); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->update_balance_summary (plugin->cls, - &master_pub, - &denom_balance, - &deposit_fee_balance, - &melt_fee_balance, - &refund_fee_balance, - &rbalance, - &loss, - &iirp)); - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: get_balance_summary\n"); - - ZR_BLK (&denom_balance2); - ZR_BLK (&deposit_fee_balance2); - ZR_BLK (&melt_fee_balance2); - ZR_BLK (&refund_fee_balance2); - ZR_BLK (&rbalance2); - ZR_BLK (&loss2); - ZR_BLK (&iirp2); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_balance_summary (plugin->cls, - &master_pub, - &denom_balance2, - &deposit_fee_balance2, - &melt_fee_balance2, - &refund_fee_balance2, - &rbalance2, - &loss2, - &iirp2)); - - FAILIF ( (0 != GNUNET_memcmp (&denom_balance2, - &denom_balance) ) || - (0 != GNUNET_memcmp (&deposit_fee_balance2, - &deposit_fee_balance) ) || - (0 != GNUNET_memcmp (&melt_fee_balance2, - &melt_fee_balance) ) || - (0 != GNUNET_memcmp (&refund_fee_balance2, - &refund_fee_balance)) ); - FAILIF (0 != GNUNET_memcmp (&rbalance2, - &rbalance)); - FAILIF (0 != GNUNET_memcmp (&loss2, - &loss)); - FAILIF (0 != GNUNET_memcmp (&iirp2, - &iirp)); - - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: insert_historic_denom_revenue\n"); - + TALER_string_to_amount (CURRENCY ":23.456789", + &rloss)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_historic_denom_revenue (plugin->cls, &master_pub, &denom_pub_hash, past, &rbalance, - &loss)); - + &rloss)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_historic_denom_revenue (plugin->cls, &master_pub, &rnd_hash, now, &rbalance, - &loss)); - + &rloss)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: select_historic_denom_revenue\n"); - - int - select_historic_denom_revenue_result ( - void *cls, - const struct TALER_DenominationHashP *denom_pub_hash2, - struct GNUNET_TIME_Timestamp revenue_timestamp2, - const struct TALER_Amount *revenue_balance2, - const struct TALER_Amount *loss2) - { - static int n = 0; - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "select_historic_denom_revenue_result: row %u\n", n); - - if ((2 <= n++) - || (cls != NULL) - || ((0 != GNUNET_memcmp (&revenue_timestamp2, &past)) - && (0 != GNUNET_memcmp (&revenue_timestamp2, &now))) - || ((0 != GNUNET_memcmp (denom_pub_hash2, &denom_pub_hash)) - && (0 != GNUNET_memcmp (denom_pub_hash2, &rnd_hash))) - || (0 != GNUNET_memcmp (revenue_balance2, &rbalance)) - || (0 != GNUNET_memcmp (loss2, &loss))) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "select_historic_denom_revenue_result: result does not match\n"); - GNUNET_break (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; - } - - FAILIF (0 >= - plugin->select_historic_denom_revenue (plugin->cls, - &master_pub, - & - select_historic_denom_revenue_result, - NULL)); - + plugin->select_historic_denom_revenue ( + plugin->cls, + &master_pub, + &select_historic_denom_revenue_result, + NULL)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: insert_historic_reserve_revenue\n"); - - struct TALER_Amount reserve_profits; GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":56.789012", &reserve_profits)); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_historic_reserve_revenue (plugin->cls, &master_pub, past, future, &reserve_profits)); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_historic_reserve_revenue (plugin->cls, &master_pub, now, future, &reserve_profits)); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: select_historic_reserve_revenue\n"); - - int - select_historic_reserve_revenue_result ( - void *cls, - struct GNUNET_TIME_Timestamp start_time2, - struct GNUNET_TIME_Timestamp end_time2, - const struct TALER_Amount *reserve_profits2) - { - static int n = 0; - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "select_historic_reserve_revenue_result: row %u\n", n); - - if ((2 <= n++) - || (cls != NULL) - || ((0 != GNUNET_memcmp (&start_time2, &past)) - && (0 != GNUNET_memcmp (&start_time2, &now))) - || (0 != GNUNET_memcmp (&end_time2, &future)) - || (0 != GNUNET_memcmp (reserve_profits2, &reserve_profits))) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "select_historic_reserve_revenue_result: result does not match\n"); - GNUNET_break (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; - } - - FAILIF (0 >= plugin->select_historic_reserve_revenue (plugin->cls, &master_pub, select_historic_reserve_revenue_result, NULL)); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: insert_predicted_result\n"); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_predicted_result (plugin->cls, - &master_pub, - &rbalance, - &dbalance)); - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: update_predicted_result\n"); - - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":78.901234", - &rbalance)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":73.901234", - &dbalance)); + { + struct TALER_Amount dbalance; + struct TALER_Amount dbalance2; + struct TALER_Amount rbalance2; - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->update_predicted_result (plugin->cls, - &master_pub, - &rbalance, + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":2.535678", &dbalance)); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_wire_fee_summary (plugin->cls, - &master_pub, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: insert_predicted_result\n"); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->insert_predicted_result (plugin->cls, + &master_pub, + &rbalance, + &dbalance)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: update_predicted_result\n"); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":78.901234", &rbalance)); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->update_wire_fee_summary (plugin->cls, - &master_pub, - &reserve_profits)); - { - struct TALER_Amount rprof; - + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":73.901234", + &dbalance)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_wire_fee_summary (plugin->cls, - &master_pub, - &rprof)); - FAILIF (0 != - TALER_amount_cmp (&rprof, - &reserve_profits)); - } - FAILIF (0 > - plugin->commit (plugin->cls)); + plugin->update_predicted_result (plugin->cls, + &master_pub, + &rbalance, + &dbalance)); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->insert_wire_fee_summary (plugin->cls, + &master_pub, + &rbalance)); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->update_wire_fee_summary (plugin->cls, + &master_pub, + &reserve_profits)); + { + struct TALER_Amount rprof; + + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->get_wire_fee_summary (plugin->cls, + &master_pub, + &rprof)); + FAILIF (0 != + TALER_amount_cmp (&rprof, + &reserve_profits)); + } + FAILIF (0 > + plugin->commit (plugin->cls)); - FAILIF (GNUNET_OK != - plugin->start (plugin->cls)); + FAILIF (GNUNET_OK != + plugin->start (plugin->cls)); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: get_predicted_balance\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: get_predicted_balance\n"); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_predicted_balance (plugin->cls, - &master_pub, - &rbalance2, - &dbalance2)); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->get_predicted_balance (plugin->cls, + &master_pub, + &rbalance2, + &dbalance2)); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->del_reserve_info (plugin->cls, - &reserve_pub, - &master_pub)); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->del_reserve_info (plugin->cls, + &reserve_pub, + &master_pub)); - FAILIF (0 != TALER_amount_cmp (&rbalance2, - &rbalance)); - FAILIF (0 != TALER_amount_cmp (&dbalance2, - &dbalance)); + FAILIF (0 != TALER_amount_cmp (&rbalance2, + &rbalance)); + FAILIF (0 != TALER_amount_cmp (&dbalance2, + &dbalance)); - plugin->rollback (plugin->cls); + plugin->rollback (plugin->cls); + } #if GC_IMPLEMENTED FAILIF (GNUNET_OK != |