double melt test no works with age restriction

- added missing field h_age_commitment in exchange's error response
- slight refactoring
This commit is contained in:
Özgür Kesim 2022-02-22 18:35:10 +01:00
parent fbdc1996a6
commit 7910ca183f
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7
6 changed files with 39 additions and 25 deletions

View File

@ -111,6 +111,9 @@ TEH_RESPONSE_compile_transaction_history (
GNUNET_JSON_pack_data_auto ("h_denom_pub", GNUNET_JSON_pack_data_auto ("h_denom_pub",
&deposit->h_denom_pub), &deposit->h_denom_pub),
GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_allow_null (
deposit->no_age_commitment ?
GNUNET_JSON_pack_string (
"h_age_commitment", NULL) :
GNUNET_JSON_pack_data_auto ("h_age_commitment", GNUNET_JSON_pack_data_auto ("h_age_commitment",
&deposit->h_age_commitment)), &deposit->h_age_commitment)),
GNUNET_JSON_pack_data_auto ("coin_sig", GNUNET_JSON_pack_data_auto ("coin_sig",
@ -146,7 +149,7 @@ TEH_RESPONSE_compile_transaction_history (
/* Age restriction is optional. We communicate a NULL value to /* Age restriction is optional. We communicate a NULL value to
* JSON_PACK below */ * JSON_PACK below */
if (! TALER_AgeCommitmentHash_isNullOrZero (&melt->h_age_commitment)) if (! melt->no_age_commitment)
phac = &melt->h_age_commitment; phac = &melt->h_age_commitment;
if (0 != if (0 !=

View File

@ -5644,14 +5644,13 @@ postgres_get_known_coin (void *cls,
GNUNET_PQ_query_param_auto_from_type (coin_pub), GNUNET_PQ_query_param_auto_from_type (coin_pub),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
bool is_null;
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
&coin_info->denom_pub_hash), &coin_info->denom_pub_hash),
GNUNET_PQ_result_spec_allow_null ( GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash", GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash",
&coin_info->h_age_commitment), &coin_info->h_age_commitment),
&is_null), &coin_info->no_age_commitment),
TALER_PQ_result_spec_denom_sig ("denom_sig", TALER_PQ_result_spec_denom_sig ("denom_sig",
&coin_info->denom_sig), &coin_info->denom_sig),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
@ -6590,7 +6589,6 @@ add_coin_deposit (void *cls,
struct TALER_EXCHANGEDB_DepositListEntry *deposit; struct TALER_EXCHANGEDB_DepositListEntry *deposit;
struct TALER_EXCHANGEDB_TransactionList *tl; struct TALER_EXCHANGEDB_TransactionList *tl;
uint64_t serial_id; uint64_t serial_id;
bool is_null;
chc->have_deposit_or_melt = true; chc->have_deposit_or_melt = true;
deposit = GNUNET_new (struct TALER_EXCHANGEDB_DepositListEntry); deposit = GNUNET_new (struct TALER_EXCHANGEDB_DepositListEntry);
@ -6605,7 +6603,7 @@ add_coin_deposit (void *cls,
GNUNET_PQ_result_spec_allow_null ( GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash", GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash",
&deposit->h_age_commitment), &deposit->h_age_commitment),
&is_null), &deposit->no_age_commitment),
GNUNET_PQ_result_spec_timestamp ("wallet_timestamp", GNUNET_PQ_result_spec_timestamp ("wallet_timestamp",
&deposit->timestamp), &deposit->timestamp),
GNUNET_PQ_result_spec_timestamp ("refund_deadline", GNUNET_PQ_result_spec_timestamp ("refund_deadline",
@ -6671,7 +6669,6 @@ add_coin_melt (void *cls,
struct TALER_EXCHANGEDB_MeltListEntry *melt; struct TALER_EXCHANGEDB_MeltListEntry *melt;
struct TALER_EXCHANGEDB_TransactionList *tl; struct TALER_EXCHANGEDB_TransactionList *tl;
uint64_t serial_id; uint64_t serial_id;
bool hac_isnull;
chc->have_deposit_or_melt = true; chc->have_deposit_or_melt = true;
melt = GNUNET_new (struct TALER_EXCHANGEDB_MeltListEntry); melt = GNUNET_new (struct TALER_EXCHANGEDB_MeltListEntry);
@ -6691,7 +6688,7 @@ add_coin_melt (void *cls,
GNUNET_PQ_result_spec_allow_null ( GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_auto_from_type ("h_age_commitment", GNUNET_PQ_result_spec_auto_from_type ("h_age_commitment",
&melt->h_age_commitment), &melt->h_age_commitment),
&hac_isnull), &melt->no_age_commitment),
GNUNET_PQ_result_spec_uint64 ("melt_serial_id", GNUNET_PQ_result_spec_uint64 ("melt_serial_id",
&serial_id), &serial_id),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
@ -6708,9 +6705,6 @@ add_coin_melt (void *cls,
return; return;
} }
if (hac_isnull)
memset (&melt->h_age_commitment, 0, sizeof(melt->h_age_commitment));
} }
tl = GNUNET_new (struct TALER_EXCHANGEDB_TransactionList); tl = GNUNET_new (struct TALER_EXCHANGEDB_TransactionList);
tl->next = chc->head; tl->next = chc->head;

View File

@ -1055,6 +1055,11 @@ struct TALER_CoinPublicInfo
*/ */
struct TALER_AgeCommitmentHash h_age_commitment; struct TALER_AgeCommitmentHash h_age_commitment;
/**
* True, if age commitment is not applicable.
*/
bool no_age_commitment;
/** /**
* (Unblinded) signature over @e coin_pub with @e denom_pub, * (Unblinded) signature over @e coin_pub with @e denom_pub,
* which demonstrates that the coin is valid. * which demonstrates that the coin is valid.

View File

@ -1126,6 +1126,11 @@ struct TALER_EXCHANGEDB_DepositListEntry
*/ */
struct TALER_AgeCommitmentHash h_age_commitment; struct TALER_AgeCommitmentHash h_age_commitment;
/**
* true, if age commitment is not applicable
*/
bool no_age_commitment;
/** /**
* Detailed information about the receiver for executing the transaction. * Detailed information about the receiver for executing the transaction.
* URL in payto://-format. * URL in payto://-format.
@ -1321,6 +1326,11 @@ struct TALER_EXCHANGEDB_MeltListEntry
*/ */
struct TALER_AgeCommitmentHash h_age_commitment; struct TALER_AgeCommitmentHash h_age_commitment;
/**
* true, if no h_age_commitment is applicable
*/
bool no_age_commitment;
/** /**
* How much value is being melted? This amount includes the fees, * How much value is being melted? This amount includes the fees,
* so the final amount contributed to the melt is this value minus * so the final amount contributed to the melt is this value minus

View File

@ -477,7 +477,7 @@ TALER_EXCHANGE_verify_coin_history (
struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_MerchantPublicKeyP merchant_pub;
struct GNUNET_TIME_Timestamp refund_deadline = {0}; struct GNUNET_TIME_Timestamp refund_deadline = {0};
struct TALER_CoinSpendSignatureP sig; struct TALER_CoinSpendSignatureP sig;
struct TALER_AgeCommitmentHash *hac = NULL; struct TALER_AgeCommitmentHash hac = {0};
struct GNUNET_JSON_Specification spec[] = { struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("coin_sig", GNUNET_JSON_spec_fixed_auto ("coin_sig",
&sig), &sig),
@ -487,6 +487,9 @@ TALER_EXCHANGE_verify_coin_history (
&h_wire), &h_wire),
GNUNET_JSON_spec_fixed_auto ("h_denom_pub", GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
h_denom_pub), h_denom_pub),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
&hac)),
GNUNET_JSON_spec_timestamp ("timestamp", GNUNET_JSON_spec_timestamp ("timestamp",
&wallet_timestamp), &wallet_timestamp),
GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_mark_optional (
@ -508,11 +511,12 @@ TALER_EXCHANGE_verify_coin_history (
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (GNUNET_OK != if (GNUNET_OK !=
TALER_wallet_deposit_verify (&amount, TALER_wallet_deposit_verify (
&amount,
&fee, &fee,
&h_wire, &h_wire,
&h_contract_terms, &h_contract_terms,
hac, TALER_AgeCommitmentHash_isNullOrZero (&hac) ? NULL : &hac,
NULL /* h_extensions! */, NULL /* h_extensions! */,
h_denom_pub, h_denom_pub,
wallet_timestamp, wallet_timestamp,

View File

@ -644,7 +644,6 @@ run (void *cls,
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:0.1", "EUR:0.1",
MHD_HTTP_OK), MHD_HTTP_OK),
#if 0 /* FIXME oec */
/* Test running a failing melt operation (same operation /* Test running a failing melt operation (same operation
* again must fail) */ * again must fail) */
TALER_TESTING_cmd_melt ("refresh-melt-failing-age", TALER_TESTING_cmd_melt ("refresh-melt-failing-age",
@ -658,7 +657,6 @@ run (void *cls,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
NULL), NULL),
#endif
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };