add invariant checks for #6214
This commit is contained in:
parent
a039bf4d81
commit
727eccbe64
@ -41,12 +41,14 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
struct TALER_Amount spent = *off;
|
struct TALER_Amount spent = *off;
|
||||||
struct TALER_Amount refunded;
|
struct TALER_Amount refunded;
|
||||||
struct TALER_Amount deposit_fee;
|
struct TALER_Amount deposit_fee;
|
||||||
int have_refund;
|
bool have_refund;
|
||||||
|
bool have_deposit;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_amount_get_zero (spent.currency,
|
TALER_amount_get_zero (spent.currency,
|
||||||
&refunded));
|
&refunded));
|
||||||
have_refund = GNUNET_NO;
|
have_refund = false;
|
||||||
|
have_deposit = false;
|
||||||
for (struct TALER_EXCHANGEDB_TransactionList *pos = tl;
|
for (struct TALER_EXCHANGEDB_TransactionList *pos = tl;
|
||||||
NULL != pos;
|
NULL != pos;
|
||||||
pos = pos->next)
|
pos = pos->next)
|
||||||
@ -55,6 +57,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
{
|
{
|
||||||
case TALER_EXCHANGEDB_TT_DEPOSIT:
|
case TALER_EXCHANGEDB_TT_DEPOSIT:
|
||||||
/* spent += pos->amount_with_fee */
|
/* spent += pos->amount_with_fee */
|
||||||
|
have_deposit = true;
|
||||||
if (0 >
|
if (0 >
|
||||||
TALER_amount_add (&spent,
|
TALER_amount_add (&spent,
|
||||||
&spent,
|
&spent,
|
||||||
@ -94,7 +97,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
have_refund = GNUNET_YES;
|
have_refund = true;
|
||||||
break;
|
break;
|
||||||
case TALER_EXCHANGEDB_TT_OLD_COIN_RECOUP:
|
case TALER_EXCHANGEDB_TT_OLD_COIN_RECOUP:
|
||||||
/* refunded += pos->value */
|
/* refunded += pos->value */
|
||||||
@ -152,7 +155,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
GNUNET_break (have_deposit);
|
||||||
*ret = spent;
|
*ret = spent;
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
@ -4004,6 +4004,11 @@ struct CoinHistoryContext
|
|||||||
* Set to 'true' if the transaction failed.
|
* Set to 'true' if the transaction failed.
|
||||||
*/
|
*/
|
||||||
bool failed;
|
bool failed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to 'true' if we found a deposit (for invariant check).
|
||||||
|
*/
|
||||||
|
bool have_deposit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -4029,6 +4034,7 @@ add_coin_deposit (void *cls,
|
|||||||
struct TALER_EXCHANGEDB_TransactionList *tl;
|
struct TALER_EXCHANGEDB_TransactionList *tl;
|
||||||
uint64_t serial_id;
|
uint64_t serial_id;
|
||||||
|
|
||||||
|
chc->have_deposit = true;
|
||||||
deposit = GNUNET_new (struct TALER_EXCHANGEDB_DepositListEntry);
|
deposit = GNUNET_new (struct TALER_EXCHANGEDB_DepositListEntry);
|
||||||
{
|
{
|
||||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
@ -4506,6 +4512,7 @@ postgres_get_coin_transactions (
|
|||||||
*tlp = chc.head;
|
*tlp = chc.head;
|
||||||
if (NULL == chc.head)
|
if (NULL == chc.head)
|
||||||
return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
|
return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
|
||||||
|
GNUNET_break (chc.have_deposit);
|
||||||
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
|
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user