making mintdb tests pass again after API refactoring to remove total amount

This commit is contained in:
Christian Grothoff 2016-02-07 15:02:49 +01:00
parent 38378f38d7
commit d67011e2b5
6 changed files with 29 additions and 58 deletions

View File

@ -606,7 +606,6 @@ typedef void
* @param coin_pub which public key was this payment about
* @param coin_value amount contributed by this coin in total (with fee)
* @param coin_fee applicable fee for this coin
* @param transfer_value total amount of the wire transfer
*/
typedef void
(*TALER_MINTDB_WireTransferDataCallback)(void *cls,
@ -616,8 +615,7 @@ typedef void
uint64_t transaction_id,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *coin_value,
const struct TALER_Amount *coin_fee,
const struct TALER_Amount *transfer_value);
const struct TALER_Amount *coin_fee);
/**

View File

@ -1392,8 +1392,7 @@ deposit_wtid_cb (void *cls,
json_t *json,
const struct TALER_WireTransferIdentifierRawP *wtid,
struct GNUNET_TIME_Absolute execution_time,
const struct TALER_Amount *coin_contribution,
const struct TALER_Amount *total_amount)
const struct TALER_Amount *coin_contribution)
{
struct InterpreterState *is = cls;
struct Command *cmd = &is->commands[is->ip];
@ -1413,16 +1412,6 @@ deposit_wtid_cb (void *cls,
{
case MHD_HTTP_OK:
cmd->details.deposit_wtid.wtid = *wtid;
if (0 != TALER_amount_cmp (total_amount,
&cmd->details.deposit_wtid.total_amount_expected))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Total amount missmatch to command %s\n",
cmd->label);
json_dumpf (json, stderr, 0);
fail (is);
return;
}
break;
default:
break;

View File

@ -1565,12 +1565,6 @@ struct WtidTransactionContext
*/
struct TALER_Amount total;
/**
* Value we find in the DB for the @e total; only valid if @e is_valid
* is #GNUNET_YES.
*/
struct TALER_Amount db_transaction_value;
/**
* Public key of the merchant, only valid if @e is_valid
* is #GNUNET_YES.
@ -1612,7 +1606,6 @@ struct WtidTransactionContext
* @param coin_pub which public key was this payment about
* @param deposit_value amount contributed by this coin in total
* @param deposit_fee deposit fee charged by mint for this coin
* @param transaction_value total value of the wire transaction
*/
static void
handle_transaction_data (void *cls,
@ -1622,8 +1615,7 @@ handle_transaction_data (void *cls,
uint64_t transaction_id,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *deposit_value,
const struct TALER_Amount *deposit_fee,
const struct TALER_Amount *transaction_value)
const struct TALER_Amount *deposit_fee)
{
struct WtidTransactionContext *ctx = cls;
struct TALER_Amount delta;
@ -1634,7 +1626,6 @@ handle_transaction_data (void *cls,
{
ctx->merchant_pub = *merchant_pub;
ctx->h_wire = *h_wire;
ctx->db_transaction_value = *transaction_value;
ctx->is_valid = GNUNET_YES;
if (GNUNET_OK !=
TALER_amount_subtract (&ctx->total,
@ -1653,9 +1644,7 @@ handle_transaction_data (void *cls,
sizeof (struct TALER_MerchantPublicKeyP))) ||
(0 != memcmp (&ctx->h_wire,
h_wire,
sizeof (struct GNUNET_HashCode))) ||
(0 != TALER_amount_cmp (transaction_value,
&ctx->db_transaction_value)) )
sizeof (struct GNUNET_HashCode))) )
{
GNUNET_break (0);
ctx->is_valid = GNUNET_SYSERR;
@ -1741,15 +1730,8 @@ TMH_DB_execute_wire_deposits (struct MHD_Connection *connection,
return TMH_RESPONSE_reply_arg_unknown (connection,
"wtid");
}
if (0 != TALER_amount_cmp (&ctx.total,
&ctx.db_transaction_value))
{
/* FIXME: this CAN actually differ, due to rounding
down. But we should still check that the values
do match after rounding 'total' down! */
}
return TMH_RESPONSE_reply_wire_deposit_details (connection,
&ctx.db_transaction_value,
&ctx.total,
&ctx.merchant_pub,
&ctx.h_wire,
ctx.deposits);

View File

@ -3739,7 +3739,7 @@ postgres_get_coin_transactions (void *cls,
/**
* Lookup the list of Taler transactions that was aggregated
* Lookup the list of Taler transactions that were aggregated
* into a wire transfer by the respective @a wtid.
*
* @param cls closure
@ -3793,7 +3793,6 @@ postgres_lookup_wire_transfer (void *cls,
struct GNUNET_TIME_Absolute exec_time;
struct TALER_Amount coin_amount;
struct TALER_Amount coin_fee;
struct TALER_Amount transfer_amount;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("h_contract", &h_contract),
GNUNET_PQ_result_spec_auto_from_type ("h_wire", &h_wire),
@ -3803,8 +3802,7 @@ postgres_lookup_wire_transfer (void *cls,
GNUNET_PQ_result_spec_absolute_time ("execution_time", &exec_time),
TALER_PQ_result_spec_amount ("coin_amount", &coin_amount),
TALER_PQ_result_spec_amount ("coin_fee", &coin_fee),
TALER_PQ_result_spec_amount ("transfer_total", &transfer_amount),
GNUNET_PQ_result_spec_end
GNUNET_PQ_result_spec_end
};
if (GNUNET_OK != GNUNET_PQ_extract_result (result, rs, i))
{
@ -3819,8 +3817,7 @@ postgres_lookup_wire_transfer (void *cls,
transaction_id,
&coin_pub,
&coin_amount,
&coin_fee,
&transfer_amount);
&coin_fee);
}
PQclear (result);
return GNUNET_OK;

View File

@ -453,8 +453,7 @@ cb_wt_never (void *cls,
uint64_t transaction_id,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *coin_value,
const struct TALER_Amount *coin_fee,
const struct TALER_Amount *transfer_value)
const struct TALER_Amount *coin_fee)
{
GNUNET_assert (0); /* this statement should be unreachable */
}
@ -468,7 +467,6 @@ cb_wtid_never (void *cls,
const struct TALER_WireTransferIdentifierRawP *wtid,
const struct TALER_Amount *coin_contribution,
const struct TALER_Amount *coin_fee,
const struct TALER_Amount *total_amount,
struct GNUNET_TIME_Absolute execution_time)
{
GNUNET_assert (0);
@ -498,8 +496,7 @@ cb_wt_check (void *cls,
uint64_t transaction_id,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *coin_value,
const struct TALER_Amount *coin_fee,
const struct TALER_Amount *transfer_value)
const struct TALER_Amount *coin_fee)
{
GNUNET_assert (cls == &cb_wt_never);
GNUNET_assert (0 == memcmp (merchant_pub,
@ -519,8 +516,6 @@ cb_wt_check (void *cls,
&coin_value_wt));
GNUNET_assert (0 == TALER_amount_cmp (coin_fee,
&coin_fee_wt));
GNUNET_assert (0 == TALER_amount_cmp (transfer_value,
&transfer_value_wt));
}
@ -532,7 +527,6 @@ cb_wtid_check (void *cls,
const struct TALER_WireTransferIdentifierRawP *wtid,
const struct TALER_Amount *coin_contribution,
const struct TALER_Amount *coin_fee,
const struct TALER_Amount *total_amount,
struct GNUNET_TIME_Absolute execution_time)
{
GNUNET_assert (cls == &cb_wtid_never);
@ -545,8 +539,6 @@ cb_wtid_check (void *cls,
&coin_value_wt));
GNUNET_assert (0 == TALER_amount_cmp (coin_fee,
&coin_fee_wt));
GNUNET_assert (0 == TALER_amount_cmp (total_amount,
&transfer_value_wt));
}
@ -826,8 +818,7 @@ run (void *cls,
execution_time_wt,
&coin_pub_wt,
&coin_value_wt,
&coin_fee_wt,
&transfer_value_wt));
&coin_fee_wt));
FAILIF (GNUNET_OK !=
plugin->lookup_wire_transfer (plugin->cls,
session,

View File

@ -72,11 +72,25 @@ extract_amount_nbo_helper (PGresult *result,
frac_name);
curr_num = PQfnumber (result,
curr_name);
if ( (val_num < 0) ||
(frac_num < 0) ||
(curr_num < 0) )
if (val_num < 0)
{
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Field `%s' does not exist in result\n",
val_name);
return GNUNET_SYSERR;
}
if (frac_num < 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Field `%s' does not exist in result\n",
frac_name);
return GNUNET_SYSERR;
}
if (curr_num < 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Field `%s' does not exist in result\n",
curr_name);
return GNUNET_SYSERR;
}
if ( (PQgetisnull (result,