diff options
author | Sree Harsha Totakura <sreeharsha@totakura.in> | 2015-08-18 14:53:13 +0200 |
---|---|---|
committer | Sree Harsha Totakura <sreeharsha@totakura.in> | 2015-08-18 15:11:27 +0200 |
commit | 543d28459aaec75b34ddec8103f9e8f2dfe277e1 (patch) | |
tree | be1a3988affdfd15e519deadb043fe7f899fad7e /src/mintdb/test_mintdb.c | |
parent | 0767119202d0a516b141cf789aaaac66a5794746 (diff) |
mintdb postgres: test insert_refresh_commit_coins()
Diffstat (limited to 'src/mintdb/test_mintdb.c')
-rw-r--r-- | src/mintdb/test_mintdb.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/mintdb/test_mintdb.c b/src/mintdb/test_mintdb.c index f0a66a51f..f2a4d8d35 100644 --- a/src/mintdb/test_mintdb.c +++ b/src/mintdb/test_mintdb.c @@ -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++) |