summaryrefslogtreecommitdiff
path: root/src/exchangedb/plugin_exchangedb_postgres.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-04-09 21:28:45 +0200
committerChristian Grothoff <christian@grothoff.org>2017-04-09 21:28:45 +0200
commit70517233c99784bbd3018d2d7f4a2c0d15d84f90 (patch)
tree8be30e58233851a96cb0fedc08c172d21d25769b /src/exchangedb/plugin_exchangedb_postgres.c
parentc298436020e31c2d555b66374e10dc6350c7453c (diff)
downloadexchange-70517233c99784bbd3018d2d7f4a2c0d15d84f90.tar.gz
exchange-70517233c99784bbd3018d2d7f4a2c0d15d84f90.tar.bz2
exchange-70517233c99784bbd3018d2d7f4a2c0d15d84f90.zip
improve test case coverage for exchangedb
Diffstat (limited to 'src/exchangedb/plugin_exchangedb_postgres.c')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 1f1e5f11..c9c3d5fd 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -3373,9 +3373,7 @@ static void
free_dpk_result (struct TALER_DenominationPublicKey *denom_pubs,
unsigned int denom_pubs_len)
{
- unsigned int i;
-
- for (i=0;i<denom_pubs_len;i++)
+ for (unsigned int i=0;i<denom_pubs_len;i++)
{
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[i].rsa_public_key);
denom_pubs[i].rsa_public_key = NULL;
@@ -3724,10 +3722,9 @@ postgres_get_refresh_transfer_public_key (void *cls,
/**
- * Insert signature of a new coin generated during refresh into
+ * Get signature of a new coin generated during refresh into
* the database indexed by the refresh session and the index
- * of the coin. This data is later used should an old coin
- * be used to try to obtain the private keys during "/refresh/link".
+ * of the coin.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database connection
@@ -5988,7 +5985,7 @@ postgres_get_reserve_by_h_blind (void *cls,
* @param denom_pub_hash hash of the revoked denomination key
* @param master_sig signature affirming the revocation
* @return #GNUNET_OK on success,
- * #GNUNET_NO if the entry already exists
+ * #GNUNET_NO if the entry already exists (transaction must be rolled back!)
* #GNUNET_SYSERR on DB errors
*/
static int
@@ -6010,6 +6007,21 @@ postgres_insert_denomination_revocation (void *cls,
params);
if (PGRES_COMMAND_OK != PQresultStatus (result))
{
+ const char *efield;
+
+ efield = PQresultErrorField (result,
+ PG_DIAG_SQLSTATE);
+ if ( (PGRES_FATAL_ERROR == PQresultStatus(result)) &&
+ (NULL != strstr ("23505", /* unique violation */
+ efield)) )
+ {
+ /* This means we had the same reserve/justification/details
+ before */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Uniqueness violation, revocation details already known\n");
+ PQclear (result);
+ return GNUNET_NO;
+ }
ret = GNUNET_SYSERR;
BREAK_DB_ERR (result, session->conn);
}