more work on test, noting what is left to do

This commit is contained in:
Christian Grothoff 2016-05-06 23:51:15 +02:00
parent d6d0ddbe07
commit d55b2cd59d
3 changed files with 115 additions and 6 deletions

View File

@ -1555,6 +1555,10 @@ postgres_get_denomination_info (void *cls,
0)); 0));
} }
PQclear (result); PQclear (result);
issue->properties.purpose.size = htonl (sizeof (struct TALER_DenominationKeyValidityPS));
issue->properties.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY);
GNUNET_CRYPTO_rsa_public_key_hash (denom_pub->rsa_public_key,
&issue->properties.denom_hash);
return GNUNET_OK; return GNUNET_OK;
EXITIF_exit: EXITIF_exit:

View File

@ -120,6 +120,8 @@ create_denom_key_pair (unsigned int size,
{ {
struct DenomKeyPair *dkp; struct DenomKeyPair *dkp;
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation dki; struct TALER_EXCHANGEDB_DenominationKeyIssueInformation dki;
struct TALER_EXCHANGEDB_DenominationKeyInformationP issue2;
struct GNUNET_TIME_Absolute now;
dkp = GNUNET_new (struct DenomKeyPair); dkp = GNUNET_new (struct DenomKeyPair);
dkp->priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (size); dkp->priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (size);
@ -133,17 +135,19 @@ create_denom_key_pair (unsigned int size,
0, 0,
sizeof (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation)); sizeof (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation));
dki.denom_pub = dkp->pub; dki.denom_pub = dkp->pub;
dki.issue.properties.start = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); now = GNUNET_TIME_absolute_get ();
GNUNET_TIME_round_abs (&now);
dki.issue.properties.start = GNUNET_TIME_absolute_hton (now);
dki.issue.properties.expire_withdraw = GNUNET_TIME_absolute_hton dki.issue.properties.expire_withdraw = GNUNET_TIME_absolute_hton
(GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), (GNUNET_TIME_absolute_add (now,
GNUNET_TIME_UNIT_HOURS)); GNUNET_TIME_UNIT_HOURS));
dki.issue.properties.expire_deposit = GNUNET_TIME_absolute_hton dki.issue.properties.expire_deposit = GNUNET_TIME_absolute_hton
(GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_add
(GNUNET_TIME_absolute_get (), (now,
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 2))); GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 2)));
dki.issue.properties.expire_legal = GNUNET_TIME_absolute_hton dki.issue.properties.expire_legal = GNUNET_TIME_absolute_hton
(GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_add
(GNUNET_TIME_absolute_get (), (now,
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 3))); GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 3)));
TALER_amount_hton (&dki.issue.properties.value, value); TALER_amount_hton (&dki.issue.properties.value, value);
TALER_amount_hton (&dki.issue.properties.fee_withdraw, fee_withdraw); TALER_amount_hton (&dki.issue.properties.fee_withdraw, fee_withdraw);
@ -152,6 +156,9 @@ create_denom_key_pair (unsigned int size,
TALER_amount_hton (&dki.issue.properties.fee_refund, fee_refund); TALER_amount_hton (&dki.issue.properties.fee_refund, fee_refund);
GNUNET_CRYPTO_rsa_public_key_hash (dkp->pub.rsa_public_key, GNUNET_CRYPTO_rsa_public_key_hash (dkp->pub.rsa_public_key,
&dki.issue.properties.denom_hash); &dki.issue.properties.denom_hash);
dki.issue.properties.purpose.size = htonl (sizeof (struct TALER_DenominationKeyValidityPS));
dki.issue.properties.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY);
if (GNUNET_OK != if (GNUNET_OK !=
plugin->insert_denomination_info (plugin->cls, plugin->insert_denomination_info (plugin->cls,
session, session,
@ -162,6 +169,24 @@ create_denom_key_pair (unsigned int size,
destroy_denom_key_pair (dkp); destroy_denom_key_pair (dkp);
return NULL; return NULL;
} }
if (GNUNET_OK !=
plugin->get_denomination_info (plugin->cls,
session,
&dki.denom_pub,
&issue2))
{
GNUNET_break(0);
destroy_denom_key_pair (dkp);
return NULL;
}
if (0 != memcmp (&dki.issue,
&issue2,
sizeof (issue2)))
{
GNUNET_break(0);
destroy_denom_key_pair (dkp);
return NULL;
}
return dkp; return dkp;
} }
@ -554,6 +579,9 @@ cb_wtid_check (void *cls,
} }
static unsigned long long deposit_rowid;
/** /**
* Function called with details about deposits that * Function called with details about deposits that
* have been made. Called in the test on the * have been made. Called in the test on the
@ -589,6 +617,7 @@ deposit_cb (void *cls,
struct TALER_EXCHANGEDB_Deposit *deposit = cls; struct TALER_EXCHANGEDB_Deposit *deposit = cls;
struct GNUNET_HashCode h_wire; struct GNUNET_HashCode h_wire;
deposit_rowid = rowid;
if (NULL != wire) if (NULL != wire)
TALER_JSON_hash (wire, &h_wire); TALER_JSON_hash (wire, &h_wire);
if ( (0 != memcmp (merchant_pub, if ( (0 != memcmp (merchant_pub,
@ -618,6 +647,9 @@ deposit_cb (void *cls,
} }
static struct TALER_EXCHANGEDB_Refund refund;
/** /**
* Main function that will be run by the scheduler. * Main function that will be run by the scheduler.
* *
@ -663,6 +695,12 @@ run (void *cls)
result = 77; result = 77;
return; return;
} }
if (GNUNET_OK !=
plugin->create_tables (plugin->cls))
{
result = 77;
goto drop;
}
if (NULL != if (NULL !=
(session = plugin->get_session (plugin->cls))) (session = plugin->get_session (plugin->cls)))
{ {
@ -847,6 +885,51 @@ run (void *cls)
&deposit.merchant_pub, &deposit.merchant_pub,
&deposit_cb, &deposit, &deposit_cb, &deposit,
2)); 2));
FAILIF (1 !=
plugin->get_ready_deposit (plugin->cls,
session,
&deposit_cb,
&deposit));
FAILIF (GNUNET_OK !=
plugin->start (plugin->cls,
session));
FAILIF (GNUNET_OK !=
plugin->mark_deposit_tiny (plugin->cls,
session,
deposit_rowid));
FAILIF (0 !=
plugin->get_ready_deposit (plugin->cls,
session,
&deposit_cb,
&deposit));
plugin->rollback (plugin->cls,
session);
FAILIF (1 !=
plugin->get_ready_deposit (plugin->cls,
session,
&deposit_cb,
&deposit));
FAILIF (GNUNET_OK !=
plugin->start (plugin->cls,
session));
FAILIF (GNUNET_NO !=
plugin->test_deposit_done (plugin->cls,
session,
&deposit));
FAILIF (GNUNET_OK !=
plugin->mark_deposit_done (plugin->cls,
session,
deposit_rowid));
FAILIF (GNUNET_OK !=
plugin->commit (plugin->cls,
session));
FAILIF (GNUNET_YES !=
plugin->test_deposit_done (plugin->cls,
session,
&deposit));
result = 10; result = 10;
deposit2 = deposit; deposit2 = deposit;
deposit2.transaction_id++; /* should fail if transaction id is different */ deposit2.transaction_id++; /* should fail if transaction id is different */
@ -886,6 +969,29 @@ run (void *cls)
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY "KUDOS:1.000000", TALER_string_to_amount (CURRENCY "KUDOS:1.000000",
&transfer_value_wt)); &transfer_value_wt));
#if 0
/* FIXME: test insert_refund! */
refund.FOO = bar;
FAILIF (GNUNET_OK !=
plugin->insert_refund (plugin->cls,
session,
&refund));
#endif
/* FIXME: test: insert_refresh_commit_links
FIXME: test: get_refresh_commit_links
FIXME: test: get_melt_commitment
FIXME: test: free_melt_commitment
FIXME: test: insert_refresh_out
FIXME: test: get_link_data_list
FIXME: test: free_link_data_list
FIXME: test: get_transfer
FIXME: test: get_coin_transactions
FIXME: test: free_coin_transaction_list
FIXME: test: wire_prepare_data_insert
FIXME: test: wire_prepare_data_mark_finished
FIXME: test: wire_prepare_data_get
*/
FAILIF (GNUNET_NO != FAILIF (GNUNET_NO !=
plugin->lookup_wire_transfer (plugin->cls, plugin->lookup_wire_transfer (plugin->cls,

View File

@ -1360,7 +1360,6 @@ struct TALER_EXCHANGEDB_Plugin
* @e get_link_data_list() enable the owner of an old coin to determine * @e get_link_data_list() enable the owner of an old coin to determine
* the private keys of the new coins after the melt. * the private keys of the new coins after the melt.
* *
*
* @param cls the @e cls of this struct with the plugin-specific state * @param cls the @e cls of this struct with the plugin-specific state
* @param session database connection * @param session database connection
* @param coin_pub public key of the coin * @param coin_pub public key of the coin