diff options
| author | Christian Grothoff <christian@grothoff.org> | 2017-03-18 22:38:31 +0100 | 
|---|---|---|
| committer | Christian Grothoff <christian@grothoff.org> | 2017-03-18 22:38:31 +0100 | 
| commit | 0f5ce284c4601f1819a9d2a91c120acdaa72fe15 (patch) | |
| tree | 1fb75c3a0a97cf193f87bbf5ae915277fe8ef8ca /src/auditordb | |
| parent | 69ac028a13497d9fa0b7ebf5e3c7992a492aab13 (diff) | |
deal with some minor FIXMEs in auditor
Diffstat (limited to 'src/auditordb')
| -rw-r--r-- | src/auditordb/plugin_auditordb_postgres.c | 60 | ||||
| -rw-r--r-- | src/auditordb/test_auditordb.c | 27 | 
2 files changed, 22 insertions, 65 deletions
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index 8c7eca19..58f1152f 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -279,7 +279,7 @@ postgres_create_tables (void *cls)  	   ",last_deposit_serial_id INT8 NOT NULL"             ",last_melt_serial_id INT8 NOT NULL"  	   ",last_refund_serial_id INT8 NOT NULL" -	   ",last_prewire_serial_id INT8 NOT NULL" +	   ",last_wire_out_serial_id INT8 NOT NULL"  	   ")");    /* Table with all of the customer reserves and their respective @@ -298,8 +298,6 @@ postgres_create_tables (void *cls)             ",withdraw_fee_balance_frac INT4 NOT NULL"             ",withdraw_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"             ",expiration_date INT8 NOT NULL" -	   ",last_reserve_in_serial_id INT8 NOT NULL" -           ",last_reserve_out_serial_id INT8 NOT NULL"             ",auditor_reserves_rowid BIGSERIAL"  	   ")"); @@ -552,7 +550,7 @@ postgres_prepare (PGconn *db_conn)  	   ",last_deposit_serial_id"             ",last_melt_serial_id"  	   ",last_refund_serial_id" -	   ",last_prewire_serial_id" +	   ",last_wire_out_serial_id"             ") VALUES ($1,$2,$3,$4,$5,$6,$7);",             7, NULL); @@ -564,7 +562,7 @@ postgres_prepare (PGconn *db_conn)  	   ",last_deposit_serial_id=$3"             ",last_melt_serial_id=$4"  	   ",last_refund_serial_id=$5" -	   ",last_prewire_serial_id=$6" +	   ",last_wire_out_serial_id=$6"             " WHERE master_pub=$7",             7, NULL); @@ -576,7 +574,7 @@ postgres_prepare (PGconn *db_conn)  	   ",last_deposit_serial_id"             ",last_melt_serial_id"  	   ",last_refund_serial_id" -	   ",last_prewire_serial_id" +	   ",last_wire_out_serial_id"             " FROM auditor_progress"             " WHERE master_pub=$1;",             1, NULL); @@ -593,10 +591,8 @@ postgres_prepare (PGconn *db_conn)             ",withdraw_fee_balance_frac"             ",withdraw_fee_balance_curr"             ",expiration_date" -	   ",last_reserve_in_serial_id" -           ",last_reserve_out_serial_id" -           ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);", -           11, NULL); +           ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9);", +           9, NULL);    /* Used in #postgres_update_reserve_info() */    PREPARE ("auditor_reserves_update", @@ -608,10 +604,8 @@ postgres_prepare (PGconn *db_conn)             ",withdraw_fee_balance_frac=$5"             ",withdraw_fee_balance_curr=$6"             ",expiration_date=$7" -	   ",last_reserve_in_serial_id=$8" -           ",last_reserve_out_serial_id=$9" -           " WHERE reserve_pub=$10 AND master_pub=$11;", -           11, NULL); +           " WHERE reserve_pub=$8 AND master_pub=$9;", +           9, NULL);    /* Used in #postgres_get_reserve_info() */    PREPARE ("auditor_reserves_select", @@ -623,8 +617,6 @@ postgres_prepare (PGconn *db_conn)             ",withdraw_fee_balance_frac"             ",withdraw_fee_balance_curr"             ",expiration_date" -	   ",last_reserve_in_serial_id" -           ",last_reserve_out_serial_id"             ",auditor_reserves_rowid"             " FROM auditor_reserves"             " WHERE reserve_pub=$1 AND master_pub=$2;", @@ -1278,7 +1270,7 @@ postgres_insert_auditor_progress (void *cls,      GNUNET_PQ_query_param_uint64 (&pp->last_deposit_serial_id),      GNUNET_PQ_query_param_uint64 (&pp->last_melt_serial_id),      GNUNET_PQ_query_param_uint64 (&pp->last_refund_serial_id), -    GNUNET_PQ_query_param_uint64 (&pp->last_prewire_serial_id), +    GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id),      GNUNET_PQ_query_param_end    };    int ret; @@ -1323,7 +1315,7 @@ postgres_update_auditor_progress (void *cls,      GNUNET_PQ_query_param_uint64 (&pp->last_deposit_serial_id),      GNUNET_PQ_query_param_uint64 (&pp->last_melt_serial_id),      GNUNET_PQ_query_param_uint64 (&pp->last_refund_serial_id), -    GNUNET_PQ_query_param_uint64 (&pp->last_prewire_serial_id), +    GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id),      GNUNET_PQ_query_param_auto_from_type (master_pub),      GNUNET_PQ_query_param_end    }; @@ -1373,7 +1365,7 @@ postgres_get_auditor_progress (void *cls,      GNUNET_PQ_result_spec_uint64 ("last_deposit_serial_id", &pp->last_deposit_serial_id),      GNUNET_PQ_result_spec_uint64 ("last_melt_serial_id", &pp->last_melt_serial_id),      GNUNET_PQ_result_spec_uint64 ("last_refund_serial_id", &pp->last_refund_serial_id), -    GNUNET_PQ_result_spec_uint64 ("last_prewire_serial_id", &pp->last_prewire_serial_id), +    GNUNET_PQ_result_spec_uint64 ("last_wire_out_serial_id", &pp->last_wire_out_serial_id),      GNUNET_PQ_result_spec_end    }; @@ -1424,10 +1416,6 @@ postgres_get_auditor_progress (void *cls,   * @param withdraw_fee_balance amount the exchange gained in withdraw fees   *                             due to withdrawals from this reserve   * @param expiration_date expiration date of the reserve - * @param last_reserve_in_serial_id up to which point did we consider - *                 incoming transfers for the above information - * @param last_reserve_out_serial_id up to which point did we consider - *                 withdrawals for the above information   * @return #GNUNET_OK on success; #GNUNET_SYSERR on failure   */  static int @@ -1437,9 +1425,7 @@ postgres_insert_reserve_info (void *cls,                                const struct TALER_MasterPublicKeyP *master_pub,                                const struct TALER_Amount *reserve_balance,                                const struct TALER_Amount *withdraw_fee_balance, -                              struct GNUNET_TIME_Absolute expiration_date, -                              uint64_t last_reserve_in_serial_id, -                              uint64_t last_reserve_out_serial_id) +                              struct GNUNET_TIME_Absolute expiration_date)  {    PGresult *result;    int ret; @@ -1449,8 +1435,6 @@ postgres_insert_reserve_info (void *cls,      TALER_PQ_query_param_amount (reserve_balance),      TALER_PQ_query_param_amount (withdraw_fee_balance),      GNUNET_PQ_query_param_auto_from_type (&expiration_date), -    GNUNET_PQ_query_param_uint64 (&last_reserve_in_serial_id), -    GNUNET_PQ_query_param_uint64 (&last_reserve_out_serial_id),      GNUNET_PQ_query_param_end    }; @@ -1487,10 +1471,6 @@ postgres_insert_reserve_info (void *cls,   * @param withdraw_fee_balance amount the exchange gained in withdraw fees   *                             due to withdrawals from this reserve   * @param expiration_date expiration date of the reserve - * @param last_reserve_in_serial_id up to which point did we consider - *                 incoming transfers for the above information - * @param last_reserve_out_serial_id up to which point did we consider - *                 withdrawals for the above information   * @return #GNUNET_OK on success; #GNUNET_SYSERR on failure   */  static int @@ -1500,9 +1480,7 @@ postgres_update_reserve_info (void *cls,                                const struct TALER_MasterPublicKeyP *master_pub,                                const struct TALER_Amount *reserve_balance,                                const struct TALER_Amount *withdraw_fee_balance, -                              struct GNUNET_TIME_Absolute expiration_date, -                              uint64_t last_reserve_in_serial_id, -                              uint64_t last_reserve_out_serial_id) +                              struct GNUNET_TIME_Absolute expiration_date)  {    PGresult *result;    int ret; @@ -1510,8 +1488,6 @@ postgres_update_reserve_info (void *cls,      TALER_PQ_query_param_amount (reserve_balance),      TALER_PQ_query_param_amount (withdraw_fee_balance),      GNUNET_PQ_query_param_auto_from_type (&expiration_date), -    GNUNET_PQ_query_param_uint64 (&last_reserve_in_serial_id), -    GNUNET_PQ_query_param_uint64 (&last_reserve_out_serial_id),      GNUNET_PQ_query_param_auto_from_type (reserve_pub),      GNUNET_PQ_query_param_auto_from_type (master_pub),      GNUNET_PQ_query_param_end @@ -1591,10 +1567,6 @@ postgres_del_reserve_info (void *cls,   * @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees   *                             due to withdrawals from this reserve   * @param[out] expiration_date expiration date of the reserve - * @param[out] last_reserve_in_serial_id up to which point did we consider - *                 incoming transfers for the above information - * @param[out] last_reserve_out_serial_id up to which point did we consider - *                 withdrawals for the above information   * @return #GNUNET_OK on success; #GNUNET_NO if there is no known   *         record about this reserve; #GNUNET_SYSERR on failure   */ @@ -1606,9 +1578,7 @@ postgres_get_reserve_info (void *cls,                             uint64_t *rowid,                             struct TALER_Amount *reserve_balance,                             struct TALER_Amount *withdraw_fee_balance, -                           struct GNUNET_TIME_Absolute *expiration_date, -                           uint64_t *last_reserve_in_serial_id, -                           uint64_t *last_reserve_out_serial_id) +                           struct GNUNET_TIME_Absolute *expiration_date)  {    struct GNUNET_PQ_QueryParam params[] = {      GNUNET_PQ_query_param_auto_from_type (reserve_pub), @@ -1641,8 +1611,6 @@ postgres_get_reserve_info (void *cls,      TALER_PQ_result_spec_amount ("reserve_balance", reserve_balance),      TALER_PQ_result_spec_amount ("withdraw_fee_balance", withdraw_fee_balance),      GNUNET_PQ_result_spec_auto_from_type ("expiration_date", expiration_date), -    GNUNET_PQ_result_spec_uint64 ("last_reserve_in_serial_id", last_reserve_in_serial_id), -    GNUNET_PQ_result_spec_uint64 ("last_reserve_out_serial_id", last_reserve_out_serial_id),      GNUNET_PQ_result_spec_uint64 ("auditor_reserves_rowid", rowid),      GNUNET_PQ_result_spec_end    }; diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c index d3e93313..03ceb609 100644 --- a/src/auditordb/test_auditordb.c +++ b/src/auditordb/test_auditordb.c @@ -208,7 +208,7 @@ run (void *cls)      .last_deposit_serial_id = 123,      .last_melt_serial_id = 456,      .last_refund_serial_id = 789, -    .last_prewire_serial_id = 555 +    .last_wire_out_serial_id = 555    };    struct TALER_AUDITORDB_ProgressPoint pp2 = {      .last_reserve_in_serial_id = 0, @@ -216,7 +216,7 @@ run (void *cls)      .last_deposit_serial_id = 0,      .last_melt_serial_id = 0,      .last_refund_serial_id = 0, -    .last_prewire_serial_id = 0 +    .last_wire_out_serial_id = 0    };    FAILIF (GNUNET_OK != @@ -232,7 +232,7 @@ run (void *cls)    pp.last_deposit_serial_id++;    pp.last_melt_serial_id++;    pp.last_refund_serial_id++; -  pp.last_prewire_serial_id++; +  pp.last_wire_out_serial_id++;    FAILIF (GNUNET_OK !=            plugin->update_auditor_progress (plugin->cls, @@ -253,7 +253,7 @@ run (void *cls)             (pp.last_deposit_serial_id != pp2.last_deposit_serial_id) ||             (pp.last_melt_serial_id != pp2.last_melt_serial_id) ||             (pp.last_refund_serial_id != pp2.last_refund_serial_id) || -           (pp.last_prewire_serial_id != pp2.last_prewire_serial_id) ); +           (pp.last_wire_out_serial_id != pp2.last_wire_out_serial_id) );    GNUNET_log (GNUNET_ERROR_TYPE_INFO,                "Test: insert_reserve_info\n"); @@ -275,16 +275,11 @@ run (void *cls)                                         &master_pub,                                         &reserve_balance,                                         &withdraw_fee_balance, -                                       past, -                                       pp.last_reserve_in_serial_id, -                                       pp.last_reserve_out_serial_id)); +                                       past));    GNUNET_log (GNUNET_ERROR_TYPE_INFO,                "Test: update_reserve_info\n"); -  pp.last_reserve_in_serial_id++; -  pp.last_reserve_out_serial_id++; -    FAILIF (GNUNET_OK !=            plugin->update_reserve_info (plugin->cls,                                         session, @@ -292,9 +287,7 @@ run (void *cls)                                         &master_pub,                                         &reserve_balance,                                         &withdraw_fee_balance, -                                       future, -                                       pp.last_reserve_in_serial_id, -                                       pp.last_reserve_out_serial_id)); +                                       future));    GNUNET_log (GNUNET_ERROR_TYPE_INFO,                "Test: get_reserve_info\n"); @@ -307,15 +300,11 @@ run (void *cls)                                      &rowid,                                      &reserve_balance2,                                      &withdraw_fee_balance2, -                                    &date, -                                    &pp2.last_reserve_in_serial_id, -                                    &pp2.last_reserve_out_serial_id)); +                                    &date));    FAILIF (0 != memcmp (&date, &future, sizeof (future))            || 0 != memcmp (&reserve_balance2, &reserve_balance, sizeof (reserve_balance)) -          || 0 != memcmp (&withdraw_fee_balance2, &withdraw_fee_balance, sizeof (withdraw_fee_balance)) -          || pp2.last_reserve_in_serial_id != pp.last_reserve_in_serial_id -          || pp2.last_reserve_out_serial_id != pp.last_reserve_out_serial_id); +          || 0 != memcmp (&withdraw_fee_balance2, &withdraw_fee_balance, sizeof (withdraw_fee_balance)));    GNUNET_log (GNUNET_ERROR_TYPE_INFO,                "Test: insert_reserve_summary\n");  | 
