-first steps towards testing age-withdraw
This commit is contained in:
parent
2eb3ff1f64
commit
8706a36c95
@ -40,6 +40,7 @@ libtalertesting_la_LDFLAGS = \
|
|||||||
-version-info 0:0:0 \
|
-version-info 0:0:0 \
|
||||||
-no-undefined
|
-no-undefined
|
||||||
libtalertesting_la_SOURCES = \
|
libtalertesting_la_SOURCES = \
|
||||||
|
testing_api_cmd_age_withdraw.c \
|
||||||
testing_api_cmd_auditor_add_denom_sig.c \
|
testing_api_cmd_auditor_add_denom_sig.c \
|
||||||
testing_api_cmd_auditor_add.c \
|
testing_api_cmd_auditor_add.c \
|
||||||
testing_api_cmd_auditor_del.c \
|
testing_api_cmd_auditor_del.c \
|
||||||
|
@ -30,6 +30,18 @@
|
|||||||
#include "taler_extensions.h"
|
#include "taler_extensions.h"
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The input and state of coin
|
||||||
|
*/
|
||||||
|
struct CoinState
|
||||||
|
{
|
||||||
|
struct TALER_RefreshMasterSecretP secret;
|
||||||
|
|
||||||
|
struct TALER_EXCHANGE_AgeWithdrawCoinPrivateDetails details;
|
||||||
|
|
||||||
|
struct TALER_Amount amount;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State for a "age withdraw" CMD:
|
* State for a "age withdraw" CMD:
|
||||||
*/
|
*/
|
||||||
@ -55,6 +67,12 @@ struct AgeWithdrawState
|
|||||||
* Number of coins to withdraw
|
* Number of coins to withdraw
|
||||||
*/
|
*/
|
||||||
size_t num_coins;
|
size_t num_coins;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The input for the coins
|
||||||
|
*/
|
||||||
|
struct CoinState *coins;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -75,6 +93,8 @@ TALER_TESTING_cmd_age_withdraw (const char *label,
|
|||||||
aws->reserve_reference = reserve_reference;
|
aws->reserve_reference = reserve_reference;
|
||||||
aws->expected_response_code = expected_response_code;
|
aws->expected_response_code = expected_response_code;
|
||||||
|
|
||||||
|
// TODO[oec]: check max_age!?
|
||||||
|
|
||||||
cnt = 1;
|
cnt = 1;
|
||||||
va_start (ap, amount);
|
va_start (ap, amount);
|
||||||
while (NULL != (va_arg (ap, const char *)))
|
while (NULL != (va_arg (ap, const char *)))
|
||||||
@ -84,19 +104,14 @@ TALER_TESTING_cmd_age_withdraw (const char *label,
|
|||||||
struct CoinState);
|
struct CoinState);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
va_start (ap, amount);
|
va_start (ap, amount);
|
||||||
for (unsigned int i = 0; i<ws->num_coins; i++)
|
for (unsigned int i = 0; i<aws->num_coins; i++)
|
||||||
{
|
{
|
||||||
struct CoinState *cs = &ws->coins[i];
|
struct CoinState *cs = &aws->coins[i];
|
||||||
|
if (0 < max_age)
|
||||||
if (0 < age)
|
|
||||||
{
|
{
|
||||||
struct TALER_AgeCommitmentProof *acp;
|
|
||||||
struct TALER_AgeCommitmentHash *hac;
|
|
||||||
struct GNUNET_HashCode seed;
|
struct GNUNET_HashCode seed;
|
||||||
struct TALER_AgeMask mask;
|
struct TALER_AgeMask mask;
|
||||||
|
|
||||||
acp = GNUNET_new (struct TALER_AgeCommitmentProof);
|
|
||||||
hac = GNUNET_new (struct TALER_AgeCommitmentHash);
|
|
||||||
mask = TALER_extensions_get_age_restriction_mask ();
|
mask = TALER_extensions_get_age_restriction_mask ();
|
||||||
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
|
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
&seed,
|
&seed,
|
||||||
@ -105,21 +120,19 @@ TALER_TESTING_cmd_age_withdraw (const char *label,
|
|||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_age_restriction_commit (
|
TALER_age_restriction_commit (
|
||||||
&mask,
|
&mask,
|
||||||
age,
|
max_age,
|
||||||
&seed,
|
&seed,
|
||||||
acp))
|
&cs->details.age_commitment_proof))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Failed to generate age commitment for age %d at %s\n",
|
"Failed to generate age commitment for age %d at %s\n",
|
||||||
age,
|
max_age,
|
||||||
label);
|
label);
|
||||||
GNUNET_assert (0);
|
GNUNET_assert (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TALER_age_commitment_hash (&acp->commitment,
|
TALER_age_commitment_hash (&cs->details.age_commitment_proof.commitment,
|
||||||
hac);
|
&cs->details.h_age_commitment);
|
||||||
cs->age_commitment_proof = acp;
|
|
||||||
cs->h_age_commitment = hac;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -140,11 +153,11 @@ TALER_TESTING_cmd_age_withdraw (const char *label,
|
|||||||
|
|
||||||
{
|
{
|
||||||
struct TALER_TESTING_Command cmd = {
|
struct TALER_TESTING_Command cmd = {
|
||||||
.cls = ws,
|
.cls = aws,
|
||||||
.label = label,
|
.label = label,
|
||||||
.run = &age_withdraw_run,
|
.run = NULL, // &age_withdraw_run,
|
||||||
.cleanup = &age_withdraw_cleanup,
|
.cleanup = NULL, // &age_withdraw_cleanup,
|
||||||
.traits = &age_withdraw_traits
|
.traits = NULL, // &age_withdraw_traits
|
||||||
};
|
};
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
|
Loading…
Reference in New Issue
Block a user