mintdb postgres: test insert_refresh_commit_coins()

This commit is contained in:
Sree Harsha Totakura 2015-08-18 14:53:13 +02:00
parent 0767119202
commit 543d28459a

View File

@ -300,11 +300,60 @@ test_melting (struct TALER_MINTDB_Session *session)
(ret_denom_pubs[cnt].rsa_public_key,
new_denom_pubs[cnt].rsa_public_key));
}
struct TALER_MINTDB_RefreshCommitCoin *commit_coins;
struct TALER_MINTDB_RefreshCommitCoin *ccoin;
struct TALER_RefreshLinkEncrypted *rlink;
size_t size;
uint16_t cnc_index;
#define COIN_ENC_MAX_SIZE 512
commit_coins = GNUNET_new_array (MELT_NEW_COINS,
struct TALER_MINTDB_RefreshCommitCoin);
cnc_index = (uint16_t) GNUNET_CRYPTO_random_u32
(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_MIN (MELT_NEW_COINS, UINT16_MAX));
for (cnt=0; cnt < MELT_NEW_COINS; cnt++)
{
ccoin = &commit_coins[cnt];
size = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
COIN_ENC_MAX_SIZE);
rlink = GNUNET_malloc (sizeof (struct TALER_RefreshLinkEncrypted) + size);
ccoin->refresh_link = rlink;
ccoin->coin_ev_size = GNUNET_CRYPTO_random_u64
(GNUNET_CRYPTO_QUALITY_WEAK, COIN_ENC_MAX_SIZE);
ccoin->coin_ev = GNUNET_malloc (ccoin->coin_ev_size);
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
ccoin->coin_ev,
ccoin->coin_ev_size);
rlink->blinding_key_enc_size = size;
RND_BLK (&rlink->coin_priv_enc);
rlink->blinding_key_enc = (const char *) &rlink[1];
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
(void *)rlink->blinding_key_enc,
rlink->blinding_key_enc_size);
}
FAILIF (GNUNET_OK !=
plugin->insert_refresh_commit_coins (plugin->cls,
session,
&session_hash,
cnc_index,
MELT_NEW_COINS,
commit_coins));
ret = GNUNET_OK;
drop:
destroy_denom_key_pair (dkp);
if (NULL != commit_coins)
{
for (cnt = 0; cnt < MELT_NEW_COINS; cnt++)
{
ccoin = &commit_coins[cnt];
GNUNET_free_non_null (ccoin->coin_ev);
rlink = (struct TALER_RefreshLinkEncrypted *) ccoin->refresh_link;
GNUNET_free_non_null (rlink);
}
GNUNET_free (commit_coins);
}
if (NULL != melts)
{
for (cnt = 0; cnt < MELT_OLD_COINS; cnt++)