diff options
Diffstat (limited to 'src/auditordb')
-rw-r--r-- | src/auditordb/plugin_auditordb_postgres.c | 294 | ||||
-rw-r--r-- | src/auditordb/test_auditordb.c | 111 |
2 files changed, 118 insertions, 287 deletions
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index e5e3764a6..67a8d7a88 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -142,7 +142,6 @@ postgres_drop_tables (void *cls, struct GNUNET_PQ_ExecuteStatement es[] = { GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_predicted_result;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_historic_ledger;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_historic_losses;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_historic_denomination_revenue;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_balance_summary;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_denomination_pending;"), @@ -329,6 +328,9 @@ postgres_create_tables (void *cls) ",denom_risk_val INT8 NOT NULL" ",denom_risk_frac INT4 NOT NULL" ",denom_risk_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" + ",payback_loss_val INT8 NOT NULL" + ",payback_loss_frac INT4 NOT NULL" + ",payback_loss_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" ")"), /* Table with the sum of the outstanding coins from "auditor_denomination_pending" (denom_pubs must belong to the @@ -353,6 +355,9 @@ postgres_create_tables (void *cls) ",risk_val INT8 NOT NULL" ",risk_frac INT4 NOT NULL" ",risk_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" + ",loss_val INT8 NOT NULL" + ",loss_frac INT4 NOT NULL" + ",loss_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" ")"), /* Table with historic profits; basically, when a denom_pub has expired and everything associated with it is garbage collected, @@ -370,16 +375,6 @@ postgres_create_tables (void *cls) ",revenue_balance_val INT8 NOT NULL" ",revenue_balance_frac INT4 NOT NULL" ",revenue_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" - ")"), - /* Table with historic losses; basically, when we need to - invalidate a denom_pub because the denom_priv was - compromised, we incur a loss. These losses are totaled - up here. (NOTE: the 'bankrupcy' protocol is not yet - implemented, so right now this table is not used.) */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_historic_losses" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)" - ",loss_timestamp INT8 NOT NULL" ",loss_balance_val INT8 NOT NULL" ",loss_balance_frac INT4 NOT NULL" ",loss_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" @@ -440,8 +435,8 @@ postgres_create_tables (void *cls) ")"), GNUNET_PQ_make_try_execute ("CREATE INDEX history_ledger_by_master_pub_and_time " "ON auditor_historic_ledger(master_pub,timestamp)"), - /* Table with the sum of the ledger, auditor_historic_revenue, - auditor_historic_losses and the auditor_reserve_balance. This is the + /* Table with the sum of the ledger, auditor_historic_revenue and + the auditor_reserve_balance. This is the final amount that the exchange should have in its bank account right now. */ GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_predicted_result" @@ -855,8 +850,11 @@ postgres_prepare (PGconn *db_conn) ",denom_risk_val" ",denom_risk_frac" ",denom_risk_curr" - ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8);", - 8), + ",payback_loss_val" + ",payback_loss_frac" + ",payback_loss_curr" + ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);", + 11), /* Used in #postgres_update_denomination_balance() */ GNUNET_PQ_make_prepare ("auditor_denomination_pending_update", "UPDATE auditor_denomination_pending SET" @@ -867,8 +865,11 @@ postgres_prepare (PGconn *db_conn) ",denom_risk_val=$5" ",denom_risk_frac=$6" ",denom_risk_curr=$7" - " WHERE denom_pub_hash=$8", - 8), + ",payback_loss_val=$8" + ",payback_loss_frac=$9" + ",payback_loss_curr=$10" + " WHERE denom_pub_hash=$11", + 11), /* Used in #postgres_get_denomination_balance() */ GNUNET_PQ_make_prepare ("auditor_denomination_pending_select", "SELECT" @@ -879,6 +880,9 @@ postgres_prepare (PGconn *db_conn) ",denom_risk_val" ",denom_risk_frac" ",denom_risk_curr" + ",payback_loss_val" + ",payback_loss_frac" + ",payback_loss_curr" " FROM auditor_denomination_pending" " WHERE denom_pub_hash=$1", 1), @@ -899,10 +903,14 @@ postgres_prepare (PGconn *db_conn) ",refund_fee_balance_frac" ",refund_fee_balance_curr" ",risk_val" - ",risk_frac" + ",risk_frac" ",risk_curr" - ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16);", - 16), + ",loss_val" + ",loss_frac" + ",loss_curr" + ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10," + " $11,$12,$13,$14,$15,$16,$17,$18,$19);", + 19), /* Used in #postgres_update_balance_summary() */ GNUNET_PQ_make_prepare ("auditor_balance_summary_update", "UPDATE auditor_balance_summary SET" @@ -921,8 +929,11 @@ postgres_prepare (PGconn *db_conn) ",risk_val=$13" ",risk_frac=$14" ",risk_curr=$15" - " WHERE master_pub=$16;", - 16), + ",loss_val=$16" + ",loss_frac=$17" + ",loss_curr=$18" + " WHERE master_pub=$19;", + 19), /* Used in #postgres_get_balance_summary() */ GNUNET_PQ_make_prepare ("auditor_balance_summary_select", "SELECT" @@ -941,6 +952,9 @@ postgres_prepare (PGconn *db_conn) ",risk_val" ",risk_frac" ",risk_curr" + ",loss_val" + ",loss_frac" + ",loss_curr" " FROM auditor_balance_summary" " WHERE master_pub=$1;", 1), @@ -953,8 +967,11 @@ postgres_prepare (PGconn *db_conn) ",revenue_balance_val" ",revenue_balance_frac" ",revenue_balance_curr" - ") VALUES ($1,$2,$3,$4,$5,$6);", - 6), + ",loss_balance_val" + ",loss_balance_frac" + ",loss_balance_curr" + ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9);", + 9), /* Used in #postgres_select_historic_denom_revenue() */ GNUNET_PQ_make_prepare ("auditor_historic_denomination_revenue_select", "SELECT" @@ -963,29 +980,10 @@ postgres_prepare (PGconn *db_conn) ",revenue_balance_val" ",revenue_balance_frac" ",revenue_balance_curr" - " FROM auditor_historic_denomination_revenue" - " WHERE master_pub=$1;", - 1), - /* Used in #postgres_insert_historic_losses() */ - GNUNET_PQ_make_prepare ("auditor_historic_losses_insert", - "INSERT INTO auditor_historic_losses" - "(master_pub" - ",denom_pub_hash" - ",loss_timestamp" - ",loss_balance_val" - ",loss_balance_frac" - ",loss_balance_curr" - ") VALUES ($1,$2,$3,$4,$5,$6);", - 6), - /* Used in #postgres_select_historic_losses() */ - GNUNET_PQ_make_prepare ("auditor_historic_losses_select", - "SELECT" - " denom_pub_hash" - ",loss_timestamp" ",loss_balance_val" ",loss_balance_frac" ",loss_balance_curr" - " FROM auditor_historic_losses" + " FROM auditor_historic_denomination_revenue" " WHERE master_pub=$1;", 1), /* Used in #postgres_insert_historic_reserve_revenue() */ @@ -2640,6 +2638,7 @@ postgres_get_wire_fee_summary (void *cls, * @param denom_pub_hash hash of the denomination public key * @param denom_balance value of coins outstanding with this denomination key * @param denom_risk value of coins issued with this denomination key + * @param payback_loss losses from payback (if this denomination was revoked) * @param num_issued how many coins of this denomination did the exchange blind-sign * @return transaction status code */ @@ -2649,6 +2648,7 @@ postgres_insert_denomination_balance (void *cls, const struct GNUNET_HashCode *denom_pub_hash, const struct TALER_Amount *denom_balance, const struct TALER_Amount *denom_risk, + const struct TALER_Amount *payback_loss, uint64_t num_issued) { struct GNUNET_PQ_QueryParam params[] = { @@ -2656,6 +2656,7 @@ postgres_insert_denomination_balance (void *cls, TALER_PQ_query_param_amount (denom_balance), GNUNET_PQ_query_param_uint64 (&num_issued), TALER_PQ_query_param_amount (denom_risk), + TALER_PQ_query_param_amount (payback_loss), GNUNET_PQ_query_param_end }; @@ -2674,6 +2675,7 @@ postgres_insert_denomination_balance (void *cls, * @param denom_pub_hash hash of the denomination public key * @param denom_balance value of coins outstanding with this denomination key * @param denom_risk value of coins issued with this denomination key + * @param payback_loss losses from payback (if this denomination was revoked) * @param num_issued how many coins of this denomination did the exchange blind-sign * @return transaction status code */ @@ -2683,12 +2685,14 @@ postgres_update_denomination_balance (void *cls, const struct GNUNET_HashCode *denom_pub_hash, const struct TALER_Amount *denom_balance, const struct TALER_Amount *denom_risk, + const struct TALER_Amount *payback_loss, uint64_t num_issued) { struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_amount (denom_balance), GNUNET_PQ_query_param_uint64 (&num_issued), TALER_PQ_query_param_amount (denom_risk), + TALER_PQ_query_param_amount (payback_loss), GNUNET_PQ_query_param_auto_from_type (denom_pub_hash), GNUNET_PQ_query_param_end }; @@ -2707,6 +2711,7 @@ postgres_update_denomination_balance (void *cls, * @param denom_pub_hash hash of the denomination public key * @param[out] denom_balance value of coins outstanding with this denomination key * @param[out] denom_risk value of coins issued with this denomination key + * @param[out] payback_loss losses from payback (if this denomination was revoked) * @param[out] num_issued how many coins of this denomination did the exchange blind-sign * @return transaction status code */ @@ -2716,6 +2721,7 @@ postgres_get_denomination_balance (void *cls, const struct GNUNET_HashCode *denom_pub_hash, struct TALER_Amount *denom_balance, struct TALER_Amount *denom_risk, + struct TALER_Amount *payback_loss, uint64_t *num_issued) { struct GNUNET_PQ_QueryParam params[] = { @@ -2725,6 +2731,7 @@ postgres_get_denomination_balance (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { TALER_PQ_result_spec_amount ("denom_balance", denom_balance), TALER_PQ_result_spec_amount ("denom_risk", denom_risk), + TALER_PQ_result_spec_amount ("payback_loss", payback_loss), GNUNET_PQ_result_spec_uint64 ("num_issued", num_issued), GNUNET_PQ_result_spec_end }; @@ -2748,6 +2755,7 @@ postgres_get_denomination_balance (void *cls, * @param melt_fee_balance total melt fees collected for this DK * @param refund_fee_balance total refund fees collected for this DK * @param risk maximum risk exposure of the exchange + * @param loss materialized @a risk from payback * @return transaction status code */ static enum GNUNET_DB_QueryStatus @@ -2758,7 +2766,8 @@ postgres_insert_balance_summary (void *cls, const struct TALER_Amount *deposit_fee_balance, const struct TALER_Amount *melt_fee_balance, const struct TALER_Amount *refund_fee_balance, - const struct TALER_Amount *risk) + const struct TALER_Amount *risk, + const struct TALER_Amount *loss) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2767,6 +2776,7 @@ postgres_insert_balance_summary (void *cls, TALER_PQ_query_param_amount (melt_fee_balance), TALER_PQ_query_param_amount (refund_fee_balance), TALER_PQ_query_param_amount (risk), + TALER_PQ_query_param_amount (loss), GNUNET_PQ_query_param_end }; @@ -2800,6 +2810,7 @@ postgres_insert_balance_summary (void *cls, * @param melt_fee_balance total melt fees collected for this DK * @param refund_fee_balance total refund fees collected for this DK * @param risk maximum risk exposure of the exchange + * @param loss materialized @a risk from payback * @return transaction status code */ static enum GNUNET_DB_QueryStatus @@ -2810,7 +2821,8 @@ postgres_update_balance_summary (void *cls, const struct TALER_Amount *deposit_fee_balance, const struct TALER_Amount *melt_fee_balance, const struct TALER_Amount *refund_fee_balance, - const struct TALER_Amount *risk) + const struct TALER_Amount *risk, + const struct TALER_Amount *loss) { struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_amount (denom_balance), @@ -2818,6 +2830,7 @@ postgres_update_balance_summary (void *cls, TALER_PQ_query_param_amount (melt_fee_balance), TALER_PQ_query_param_amount (refund_fee_balance), TALER_PQ_query_param_amount (risk), + TALER_PQ_query_param_amount (loss), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; @@ -2839,6 +2852,7 @@ postgres_update_balance_summary (void *cls, * @param[out] melt_fee_balance total melt fees collected for this DK * @param[out] refund_fee_balance total refund fees collected for this DK * @param[out] risk maximum risk exposure of the exchange + * @param[out] loss losses from payback (on revoked denominations) * @return transaction status code */ static enum GNUNET_DB_QueryStatus @@ -2849,7 +2863,8 @@ postgres_get_balance_summary (void *cls, struct TALER_Amount *deposit_fee_balance, struct TALER_Amount *melt_fee_balance, struct TALER_Amount *refund_fee_balance, - struct TALER_Amount *risk) + struct TALER_Amount *risk, + struct TALER_Amount *loss) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2861,13 +2876,14 @@ postgres_get_balance_summary (void *cls, TALER_PQ_result_spec_amount ("melt_fee_balance", melt_fee_balance), TALER_PQ_result_spec_amount ("refund_fee_balance", refund_fee_balance), TALER_PQ_result_spec_amount ("risk", risk), + TALER_PQ_result_spec_amount ("loss", loss), GNUNET_PQ_result_spec_end }; return GNUNET_PQ_eval_prepared_singleton_select (session->conn, - "auditor_balance_summary_select", - params, - rs); + "auditor_balance_summary_select", + params, + rs); } @@ -2891,13 +2907,15 @@ postgres_insert_historic_denom_revenue (void *cls, const struct TALER_MasterPublicKeyP *master_pub, const struct GNUNET_HashCode *denom_pub_hash, struct GNUNET_TIME_Absolute revenue_timestamp, - const struct TALER_Amount *revenue_balance) + const struct TALER_Amount *revenue_balance, + const struct TALER_Amount *loss_balance) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_auto_from_type (denom_pub_hash), TALER_PQ_query_param_absolute_time (&revenue_timestamp), TALER_PQ_query_param_amount (revenue_balance), + TALER_PQ_query_param_amount (loss_balance), GNUNET_PQ_query_param_end }; @@ -2950,10 +2968,12 @@ historic_denom_revenue_cb (void *cls, struct GNUNET_HashCode denom_pub_hash; struct GNUNET_TIME_Absolute revenue_timestamp; struct TALER_Amount revenue_balance; + struct TALER_Amount loss; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &denom_pub_hash), TALER_PQ_result_spec_absolute_time ("revenue_timestamp", &revenue_timestamp), TALER_PQ_result_spec_amount ("revenue_balance", &revenue_balance), + TALER_PQ_result_spec_amount ("loss_balance", &loss), GNUNET_PQ_result_spec_end }; @@ -2970,9 +2990,10 @@ historic_denom_revenue_cb (void *cls, hrc->qs = i + 1; if (GNUNET_OK != hrc->cb (hrc->cb_cls, - &denom_pub_hash, - revenue_timestamp, - &revenue_balance)) + &denom_pub_hash, + revenue_timestamp, + &revenue_balance, + &loss)) break; } } @@ -3018,152 +3039,6 @@ postgres_select_historic_denom_revenue (void *cls, /** - * Insert information about an exchange's historic - * losses (from compromised denomination keys). - * - * Note yet used, need to implement exchange's bankrupcy - * protocol (and tables!) first. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use - * @param master_pub master key of the exchange - * @param denom_pub_hash hash of the denomination key - * @param loss_timestamp when did this profit get realized - * @param loss_balance what was the total loss - * @return transaction status code - */ -static enum GNUNET_DB_QueryStatus -postgres_insert_historic_losses (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct GNUNET_HashCode *denom_pub_hash, - struct GNUNET_TIME_Absolute loss_timestamp, - const struct TALER_Amount *loss_balance) -{ - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (master_pub), - GNUNET_PQ_query_param_auto_from_type (denom_pub_hash), - TALER_PQ_query_param_absolute_time (&loss_timestamp), - TALER_PQ_query_param_amount (loss_balance), - GNUNET_PQ_query_param_end - }; - - return GNUNET_PQ_eval_prepared_non_select (session->conn, - "auditor_historic_losses_insert", - params); -} - - -/** - * Closure for #losses_cb. - */ -struct LossContext -{ - /** - * Function to call for each result. - */ - TALER_AUDITORDB_HistoricLossesDataCallback cb; - - /** - * Closure for @e cb. - */ - void *cb_cls; - - /** - * Status code to return. - */ - enum GNUNET_DB_QueryStatus qs; -}; - - -/** - * Helper function for #postgres_select_historic_denom_revenue(). - * To be called with the results of a SELECT statement - * that has returned @a num_results results. - * - * @param cls closure of type `struct HistoricRevenueContext *` - * @param result the postgres result - * @param num_result the number of results in @a result - */ -static void -losses_cb (void *cls, - PGresult *result, - unsigned int num_results) -{ - struct LossContext *lctx = cls; - - for (unsigned int i = 0; i < num_results; i++) - { - struct GNUNET_HashCode denom_pub_hash; - struct GNUNET_TIME_Absolute loss_timestamp; - struct TALER_Amount loss_balance; - struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &denom_pub_hash), - TALER_PQ_result_spec_absolute_time ("loss_timestamp", &loss_timestamp), - TALER_PQ_result_spec_amount ("loss_balance", &loss_balance), - GNUNET_PQ_result_spec_end - }; - - if (GNUNET_OK != - GNUNET_PQ_extract_result (result, - rs, - i)) - { - GNUNET_break (0); - lctx->qs = GNUNET_DB_STATUS_HARD_ERROR; - return; - } - lctx->qs = i + 1; - if (GNUNET_OK != - lctx->cb (lctx->cb_cls, - &denom_pub_hash, - loss_timestamp, - &loss_balance)) - break; - } -} - - -/** - * Obtain all of the historic denomination key losses - * of the given @a master_pub. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use - * @param master_pub master key of the exchange - * @param cb function to call with the results - * @param cb_cls closure for @a cb - * @return transaction status code - */ -static enum GNUNET_DB_QueryStatus -postgres_select_historic_losses (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_AUDITORDB_HistoricLossesDataCallback cb, - void *cb_cls) -{ - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (master_pub), - GNUNET_PQ_query_param_end - }; - struct LossContext lctx = { - .cb = cb, - .cb_cls = cb_cls - }; - enum GNUNET_DB_QueryStatus qs; - - qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, - "auditor_historic_losses_select", - params, - &losses_cb, - &lctx); - if (qs <= 0) - return qs; - return lctx.qs; -} - - -/** * Insert information about an exchange's historic revenue from reserves. * * @param cls the @e cls of this struct with the plugin-specific state @@ -3191,8 +3066,8 @@ postgres_insert_historic_reserve_revenue (void *cls, }; return GNUNET_PQ_eval_prepared_non_select (session->conn, - "auditor_historic_reserve_summary_insert", - params); + "auditor_historic_reserve_summary_insert", + params); } @@ -3229,8 +3104,8 @@ struct HistoricReserveRevenueContext */ static void historic_reserve_revenue_cb (void *cls, - PGresult *result, - unsigned int num_results) + PGresult *result, + unsigned int num_results) { struct HistoricReserveRevenueContext *hrc = cls; @@ -3294,10 +3169,10 @@ postgres_select_historic_reserve_revenue (void *cls, }; qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, - "auditor_historic_reserve_summary_select", - params, - &historic_reserve_revenue_cb, - &hrc); + "auditor_historic_reserve_summary_select", + params, + &historic_reserve_revenue_cb, + &hrc); if (0 >= qs) return qs; return hrc.qs; @@ -3495,9 +3370,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->select_historic_denom_revenue = &postgres_select_historic_denom_revenue; plugin->insert_historic_denom_revenue = &postgres_insert_historic_denom_revenue; - plugin->select_historic_losses = &postgres_select_historic_losses; - plugin->insert_historic_losses = &postgres_insert_historic_losses; - plugin->select_historic_reserve_revenue = &postgres_select_historic_reserve_revenue; plugin->insert_historic_reserve_revenue = &postgres_insert_historic_reserve_revenue; diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c index 191043754..80c442a9a 100644 --- a/src/auditordb/test_auditordb.c +++ b/src/auditordb/test_auditordb.c @@ -371,6 +371,8 @@ run (void *cls) struct TALER_Amount refund_fee_balance2; struct TALER_Amount rbalance; struct TALER_Amount rbalance2; + struct TALER_Amount loss; + struct TALER_Amount loss2; uint64_t nissued; GNUNET_assert (GNUNET_OK == @@ -388,6 +390,9 @@ run (void *cls) GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":13.57986", &rbalance)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":1.6", + &loss)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_denomination_balance (plugin->cls, @@ -395,6 +400,7 @@ run (void *cls) &denom_pub_hash, &denom_balance, &rbalance, + &loss, 42)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -411,6 +417,7 @@ run (void *cls) &denom_pub_hash, &denom_balance, &rbalance, + &loss, 62)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: get_denomination_balance\n"); @@ -421,6 +428,7 @@ run (void *cls) &denom_pub_hash, &denom_balance2, &rbalance2, + &loss2, &nissued)); FAILIF (0 != GNUNET_memcmp (&denom_balance2, &denom_balance)); @@ -439,7 +447,8 @@ run (void *cls) &melt_fee_balance, &deposit_fee_balance, &denom_balance, - &rbalance)); + &rbalance, + &loss)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: update_balance_summary\n"); @@ -452,7 +461,8 @@ run (void *cls) &deposit_fee_balance, &melt_fee_balance, &refund_fee_balance, - &rbalance)); + &rbalance, + &loss)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: get_balance_summary\n"); @@ -462,6 +472,7 @@ run (void *cls) ZR_BLK (&melt_fee_balance2); ZR_BLK (&refund_fee_balance2); ZR_BLK (&rbalance2); + ZR_BLK (&loss2); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_balance_summary (plugin->cls, @@ -471,7 +482,8 @@ run (void *cls) &deposit_fee_balance2, &melt_fee_balance2, &refund_fee_balance2, - &rbalance2)); + &rbalance2, + &loss2)); FAILIF ( (0 != GNUNET_memcmp (&denom_balance2, &denom_balance) ) || @@ -483,6 +495,8 @@ run (void *cls) &refund_fee_balance)) ); FAILIF (0 != GNUNET_memcmp (&rbalance2, &rbalance)); + FAILIF (0 != GNUNET_memcmp (&loss2, + &loss)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -494,7 +508,8 @@ run (void *cls) &master_pub, &denom_pub_hash, past, - &rbalance)); + &rbalance, + &loss)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_historic_denom_revenue (plugin->cls, @@ -502,7 +517,8 @@ run (void *cls) &master_pub, &rnd_hash, now, - &rbalance)); + &rbalance, + &loss)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: select_historic_denom_revenue\n"); @@ -511,7 +527,8 @@ run (void *cls) select_historic_denom_revenue_result (void *cls, const struct GNUNET_HashCode *denom_pub_hash2, struct GNUNET_TIME_Absolute revenue_timestamp2, - const struct TALER_Amount *revenue_balance2) + const struct TALER_Amount *revenue_balance2, + const struct TALER_Amount *loss2) { static int n = 0; @@ -524,7 +541,8 @@ run (void *cls) && 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 (revenue_balance2, &rbalance) + || 0 != GNUNET_memcmp (loss2, &loss)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "select_historic_denom_revenue_result: result does not match\n"); @@ -542,63 +560,6 @@ run (void *cls) NULL)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: insert_historic_losses\n"); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_historic_losses (plugin->cls, - session, - &master_pub, - &denom_pub_hash, - past, - &rbalance)); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_historic_losses (plugin->cls, - session, - &master_pub, - &rnd_hash, - past, - &rbalance)); - - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: select_historic_losses\n"); - - int - select_historic_losses_result (void *cls, - const struct GNUNET_HashCode *denom_pub_hash2, - struct GNUNET_TIME_Absolute loss_timestamp2, - const struct TALER_Amount *loss_balance2) - { - static int n = 0; - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "select_historic_losses_result: row %u\n", n); - - if (2 <= n++ - || cls != NULL - || (0 != GNUNET_memcmp (&loss_timestamp2, &past) - && 0 != GNUNET_memcmp (&loss_timestamp2, &now)) - || (0 != GNUNET_memcmp (denom_pub_hash2, &denom_pub_hash) - && 0 != GNUNET_memcmp (denom_pub_hash2, &rnd_hash)) - || 0 != GNUNET_memcmp (loss_balance2, &rbalance)) - { - 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_losses (plugin->cls, - session, - &master_pub, - select_historic_losses_result, - NULL)); - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: insert_historic_reserve_revenue\n"); struct TALER_Amount reserve_profits; @@ -744,20 +705,18 @@ drop: { plugin->rollback (plugin->cls, session); - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: auditor_delete_exchange\n"); - FAILIF (GNUNET_OK != - plugin->start (plugin->cls, - session)); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->delete_exchange (plugin->cls, - session, - &master_pub)); - FAILIF (0 > - plugin->commit (plugin->cls, - session)); + GNUNET_break (GNUNET_OK == + plugin->start (plugin->cls, + session)); + GNUNET_break (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == + plugin->delete_exchange (plugin->cls, + session, + &master_pub)); + GNUNET_break (0 <= + plugin->commit (plugin->cls, + session)); } GNUNET_break (GNUNET_OK == plugin->drop_tables (plugin->cls, |