aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2016-10-20 23:28:36 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2016-10-20 23:28:36 +0200
commitac554444b124ae5643525bfbfa643c026c20bd37 (patch)
tree8a74ca9665a6bc0acc41d0d320ec9ff2974c05a6 /src
parenta36ee9b4910e312f7d1c3309b60a75f5c257a7e9 (diff)
Adding auditor-related db functions in testcase. Each cb is just a stub.
Diffstat (limited to 'src')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c34
-rw-r--r--src/exchangedb/test_exchangedb.c207
2 files changed, 223 insertions, 18 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 8e82917f8..29ab802cf 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -4372,9 +4372,9 @@ postgres_select_deposits_above_serial_id (void *cls,
};
PGresult *result;
result = GNUNET_PQ_exec_prepared (session->conn,
- "audit_get_deposits_incr",
- params);
- if (PGRES_COMMAND_OK !=
+ "audit_get_deposits_incr",
+ params);
+ if (PGRES_TUPLES_OK !=
PQresultStatus (result))
{
BREAK_DB_ERR (result);
@@ -4475,7 +4475,7 @@ postgres_select_refreshs_above_serial_id (void *cls,
"audit_get_refresh_sessions_incr",
params);
- if (PGRES_COMMAND_OK !=
+ if (PGRES_TUPLES_OK !=
PQresultStatus (result))
{
BREAK_DB_ERR (result);
@@ -4502,12 +4502,10 @@ postgres_select_refreshs_above_serial_id (void *cls,
uint16_t num_newcoins;
uint16_t noreveal_index;
-
-
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
- &coin_pub),
- GNUNET_PQ_result_spec_auto_from_type ("coin_sig",
+ GNUNET_PQ_result_spec_auto_from_type ("old_coin_pub",
+ &coin_pub),
+ GNUNET_PQ_result_spec_auto_from_type ("old_coin_sig",
&coin_sig),
TALER_PQ_result_spec_amount ("amount_with_fee",
&amount_with_fee),
@@ -4564,7 +4562,7 @@ postgres_select_refunds_above_serial_id (void *cls,
result = GNUNET_PQ_exec_prepared (session->conn,
"audit_get_refunds_incr",
params);
- if (PGRES_COMMAND_OK !=
+ if (PGRES_TUPLES_OK !=
PQresultStatus (result))
{
BREAK_DB_ERR (result);
@@ -4652,7 +4650,7 @@ postgres_select_reserves_in_above_serial_id (void *cls,
result = GNUNET_PQ_exec_prepared (session->conn,
"audit_reserves_in_get_transactions_incr",
params);
- if (PGRES_COMMAND_OK !=
+ if (PGRES_TUPLES_OK !=
PQresultStatus (result))
{
BREAK_DB_ERR (result);
@@ -4680,7 +4678,7 @@ postgres_select_reserves_in_above_serial_id (void *cls,
struct GNUNET_TIME_Absolute execution_date;
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_auto_from_type ("merchant_pub",
+ GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
&reserve_pub),
TALER_PQ_result_spec_amount ("credit",
&credit),
@@ -4740,7 +4738,7 @@ postgres_select_reserves_out_above_serial_id (void *cls,
result = GNUNET_PQ_exec_prepared (session->conn,
"audit_get_reserves_out_incr",
params);
- if (PGRES_COMMAND_OK !=
+ if (PGRES_TUPLES_OK !=
PQresultStatus (result))
{
BREAK_DB_ERR (result);
@@ -4771,10 +4769,10 @@ postgres_select_reserves_out_above_serial_id (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("h_blind_ev",
&h_blind_ev),
- GNUNET_PQ_result_spec_auto_from_type ("denom_pub",
- &denom_pub),
- GNUNET_PQ_result_spec_auto_from_type ("denom_sig",
- &denom_sig),
+ GNUNET_PQ_result_spec_rsa_public_key ("denom_pub",
+ &denom_pub.rsa_public_key),
+ GNUNET_PQ_result_spec_rsa_signature ("denom_sig",
+ &denom_sig.rsa_signature),
GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
&reserve_pub),
GNUNET_PQ_result_spec_auto_from_type ("reserve_sig",
@@ -4837,7 +4835,7 @@ postgres_select_prepare_above_serial_id (void *cls,
result = GNUNET_PQ_exec_prepared (session->conn,
"audit_get_wire_incr",
params);
- if (PGRES_COMMAND_OK !=
+ if (PGRES_TUPLES_OK !=
PQresultStatus (result))
{
BREAK_DB_ERR (result);
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 00c7a9ef6..7b91e3b37 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -18,6 +18,7 @@
* @brief test cases for DB interaction functions
* @author Sree Harsha Totakura
* @author Christian Grothoff
+ * @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_exchangedb_lib.h"
@@ -103,6 +104,26 @@ mark_prepare_cb (void *cls,
rowid));
}
+/**
+ * Callback with data about a prepared wire transfer.
+ *
+ * @param cls closure
+ * @param rowid row identifier used to mark prepared transaction as done
+ * @param wire_method which wire method is this preparation data for
+ * @param buf transaction data that was persisted, NULL on error
+ * @param buf_size number of bytes in @a buf, 0 on error
+ * @param finished did we complete the transfer yet?
+ */
+void
+audit_wire_cb (void *cls,
+ unsigned long long rowid,
+ const char *wire_method,
+ const char *buf,
+ size_t buf_size,
+ int finished)
+{
+ return;
+}
/**
* Test API relating to persisting the wire plugins preparation data.
@@ -134,6 +155,12 @@ test_wire_prepare (struct TALER_EXCHANGEDB_Session *session)
session,
&dead_prepare_cb,
NULL));
+ FAILIF (GNUNET_OK !=
+ plugin->select_prepare_above_serial_id (plugin->cls,
+ session,
+ 0,
+ &audit_wire_cb,
+ NULL));
return GNUNET_OK;
drop:
return GNUNET_SYSERR;
@@ -465,6 +492,37 @@ check_transfer_data (void *cls,
*ok = GNUNET_SYSERR;
}
+/**
+ * Function called with details about coins that were melted,
+ * with the goal of auditing the refresh's execution.
+ *
+ * @param cls closure
+ * @param rowid unique serial ID for the refresh session in our DB
+ * @param merchant_pub public key of the merchant
+ * @param coin_pub public key of the coin
+ * @param coin_sig signature from the coin
+ * @param amount_with_fee amount that was deposited including fee
+ * @param transaction_id unique transaction ID chosen by the merchant
+ * @param h_contract hash of the contract between merchant and customer
+ * @param refund_deadline by which the merchant adviced that he might want
+ * to get a refund
+ * @param wire_deadline by which the merchant adviced that he would like the
+ * wire transfer to be executed
+ * @param receiver_wire_account wire details for the merchant, NULL from iterate_matching_deposits()
+ * @param done flag set if the deposit was already executed (or not)
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
+ */
+int
+audit_refresh_session_cb (void *cls,
+ unsigned long long rowid, /* FIXME: decide data type for serial_id! */
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_CoinSpendSignatureP *coin_sig,
+ const struct TALER_Amount *amount_with_fee,
+ uint16_t num_newcoins,
+ uint16_t noreveal_index)
+{
+ return GNUNET_OK;
+}
/**
* Function to test melting of coins as part of a refresh session
@@ -538,6 +596,12 @@ test_melting (struct TALER_EXCHANGEDB_Session *session)
session,
&session_hash,
&ret_refresh_session));
+
+ FAILIF (GNUNET_OK != plugin->select_refreshs_above_serial_id (plugin->cls,
+ session,
+ 0,
+ &audit_refresh_session_cb,
+ NULL));
FAILIF (ret_refresh_session.num_newcoins != refresh_session.num_newcoins);
FAILIF (ret_refresh_session.noreveal_index != refresh_session.noreveal_index);
@@ -874,6 +938,124 @@ deposit_cb (void *cls,
return GNUNET_OK;
}
+/**
+ * Callback for #select_deposits_above_serial_id ()
+ *
+ * @param cls closure
+ * @param rowid unique serial ID for the deposit in our DB
+ * @param merchant_pub public key of the merchant
+ * @param coin_pub public key of the coin
+ * @param coin_sig signature from the coin
+ * @param amount_with_fee amount that was deposited including fee
+ * @param transaction_id unique transaction ID chosen by the merchant
+ * @param h_contract hash of the contract between merchant and customer
+ * @param refund_deadline by which the merchant adviced that he might want
+ * to get a refund
+ * @param wire_deadline by which the merchant adviced that he would like the
+ * wire transfer to be executed
+ * @param receiver_wire_account wire details for the merchant, NULL from iterate_matching_deposits()
+ * @param done flag set if the deposit was already executed (or not)
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
+ */
+int
+audit_deposit_cb (void *cls,
+ unsigned long long rowid,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_CoinSpendSignatureP *coin_sig,
+ const struct TALER_Amount *amount_with_fee,
+ uint64_t transaction_id,
+ const struct GNUNET_HashCode *h_contract,
+ struct GNUNET_TIME_Absolute refund_deadline,
+ struct GNUNET_TIME_Absolute wire_deadline,
+ const json_t *receiver_wire_account,
+ int done)
+{
+ return GNUNET_OK;
+}
+
+
+/**
+ * Function called with details about coins that were refunding,
+ * with the goal of auditing the refund's execution.
+ *
+ * @param cls closure
+ * @param rowid unique serial ID for the refund in our DB
+ * @param coin_pub public key of the coin
+ * @param merchant_pub public key of the merchant
+ * @param merchant_sig signature of the merchant
+ * @param h_contract hash of the contract between merchant and customer
+ * @param transaction_id original transaction ID chosen by the merchant
+ * @param rtransaction_id refund transaction ID chosen by the merchant
+ * @param amount_with_fee amount that was deposited including fee
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
+ */
+int
+audit_refund_cb (void *cls,
+ unsigned long long rowid, /* FIXME: decide data type for serial_id! */
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_MerchantSignatureP *merchant_sig,
+ const struct GNUNET_HashCode *h_contract,
+ uint64_t transaction_id,
+ uint64_t rtransaction_id,
+ const struct TALER_Amount *amount_with_fee)
+{
+ return GNUNET_OK;
+}
+
+
+/**
+ * Function called with details about incoming wire transfers.
+ *
+ * @param cls closure
+ * @param rowid unique serial ID for the refresh session in our DB
+ * @param reserve_pub public key of the reserve (also the WTID)
+ * @param credit amount that was received
+ * @param sender_account_details information about the sender's bank account
+ * @param transfer_details information that uniquely identifies the wire transfer
+ * @param execution_date when did we receive the funds
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
+ */
+int
+audit_reserve_in_cb (void *cls,
+ unsigned long long rowid, /* FIXME: decide data type for serial_id! */
+ const struct TALER_ReservePublicKeyP *reserve_pub,
+ const struct TALER_Amount *credit,
+ const json_t *sender_account_details,
+ const json_t *transfer_details,
+ struct GNUNET_TIME_Absolute execution_date)
+{
+ return GNUNET_OK;
+}
+
+/**
+ * Function called with details about withdraw operations.
+ *
+ * @param cls closure
+ * @param rowid unique serial ID for the refresh session in our DB
+ * @param h_blind_ev blinded hash of the coin's public key
+ * @param denom_pub public denomination key of the deposited coin
+ * @param denom_sig signature over the deposited coin
+ * @param reserve_pub public key of the reserve
+ * @param reserve_sig signature over the withdraw operation
+ * @param execution_date when did the wallet withdraw the coin
+ * @param amount_with_fee amount that was withdrawn
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
+ */
+int
+audit_reserve_out_cb (void *cls,
+ unsigned long long rowid, /* FIXME: decide data type for serial_id! */
+ const struct GNUNET_HashCode *h_blind_ev,
+ const struct TALER_DenominationPublicKey *denom_pub,
+ const struct TALER_DenominationSignature *denom_sig,
+ const struct TALER_ReservePublicKeyP *reserve_pub,
+ const struct TALER_ReserveSignatureP *reserve_sig,
+ struct GNUNET_TIME_Absolute execution_date,
+ const struct TALER_Amount *amount_with_fee)
+{
+ return GNUNET_OK;
+}
/**
* Test garbage collection.
@@ -1121,6 +1303,19 @@ run (void *cls)
}
}
FAILIF (3 != cnt);
+
+ FAILIF (GNUNET_OK !=
+ plugin->select_reserves_in_above_serial_id (plugin->cls,
+ session,
+ 0,
+ &audit_reserve_in_cb,
+ NULL));
+ FAILIF (GNUNET_OK !=
+ plugin->select_reserves_out_above_serial_id (plugin->cls,
+ session,
+ 0,
+ &audit_reserve_out_cb,
+ NULL));
/* Tests for deposits */
memset (&deposit, 0, sizeof (deposit));
RND_BLK (&deposit.coin.coin_pub);
@@ -1145,6 +1340,12 @@ run (void *cls)
plugin->have_deposit (plugin->cls,
session,
&deposit));
+ FAILIF (GNUNET_OK !=
+ plugin->select_deposits_above_serial_id (plugin->cls,
+ session,
+ 0,
+ &audit_deposit_cb,
+ NULL));
result = 9;
FAILIF (1 !=
plugin->iterate_matching_deposits (plugin->cls,
@@ -1232,6 +1433,12 @@ run (void *cls)
plugin->insert_refund (plugin->cls,
session,
&refund));
+ FAILIF (GNUNET_OK !=
+ plugin->select_refunds_above_serial_id (plugin->cls,
+ session,
+ 0,
+ &audit_refund_cb,
+ NULL));
tl = plugin->get_coin_transactions (plugin->cls,
session,