expand testcase to cover refund API, fix minor issues
This commit is contained in:
parent
691c9a859f
commit
966242341a
@ -44,20 +44,6 @@
|
||||
year = {1998},
|
||||
}
|
||||
|
||||
@TechReport{,
|
||||
author = {},
|
||||
title = {},
|
||||
institution = {},
|
||||
year = {},
|
||||
OPTkey = {},
|
||||
OPTtype = {},
|
||||
OPTnumber = {},
|
||||
OPTaddress = {},
|
||||
OPTmonth = {},
|
||||
OPTnote = {},
|
||||
OPTannote = {}
|
||||
}
|
||||
|
||||
@InProceedings{sander1999escrow,
|
||||
author = {Tomas Sander and Amnon Ta-Shma},
|
||||
title = {On Anonymous Electronic Cash and Crime},
|
||||
@ -236,6 +222,3 @@
|
||||
doi_url="http://dx.doi.org/10.1007/3-540-44598-6_14",
|
||||
url="https://www.iacr.org/archive/crypto2000/18800229/18800229.pdf"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -266,7 +266,6 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
|
||||
}
|
||||
TMH_plugin->free_coin_transaction_list (TMH_plugin->cls,
|
||||
tl);
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TMH_plugin->insert_deposit (TMH_plugin->cls,
|
||||
session,
|
||||
|
@ -100,8 +100,10 @@ common_free_coin_transaction_list (void *cls,
|
||||
{
|
||||
case TALER_EXCHANGEDB_TT_DEPOSIT:
|
||||
json_decref (list->details.deposit->wire);
|
||||
GNUNET_CRYPTO_rsa_public_key_free (list->details.deposit->coin.denom_pub.rsa_public_key);
|
||||
GNUNET_CRYPTO_rsa_signature_free (list->details.deposit->coin.denom_sig.rsa_signature);
|
||||
if (NULL != list->details.deposit->coin.denom_pub.rsa_public_key)
|
||||
GNUNET_CRYPTO_rsa_public_key_free (list->details.deposit->coin.denom_pub.rsa_public_key);
|
||||
if (NULL != list->details.deposit->coin.denom_sig.rsa_signature)
|
||||
GNUNET_CRYPTO_rsa_signature_free (list->details.deposit->coin.denom_sig.rsa_signature);
|
||||
GNUNET_free (list->details.deposit);
|
||||
break;
|
||||
case TALER_EXCHANGEDB_TT_REFRESH_MELT:
|
||||
|
@ -373,8 +373,8 @@ postgres_create_tables (void *cls)
|
||||
SQLEXEC("CREATE TABLE IF NOT EXISTS refunds "
|
||||
"(coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub)"
|
||||
",merchant_pub BYTEA NOT NULL CHECK(LENGTH(merchant_pub)=32)"
|
||||
",merchant_sig BYTEA NOT NULL CHECK(LENGTH(merchant_pub)=64)"
|
||||
",h_contract BYTEA NOT NULL CHECK(LENGTH(merchant_pub)=64)"
|
||||
",merchant_sig BYTEA NOT NULL CHECK(LENGTH(merchant_sig)=64)"
|
||||
",h_contract BYTEA NOT NULL CHECK(LENGTH(h_contract)=64)"
|
||||
",transaction_id INT8 NOT NULL"
|
||||
",rtransaction_id INT8 NOT NULL"
|
||||
",amount_with_fee_val INT8 NOT NULL"
|
||||
@ -442,9 +442,7 @@ postgres_create_tables (void *cls)
|
||||
execute to transmit funds to the merchants (and manage refunds). */
|
||||
SQLEXEC("CREATE TABLE IF NOT EXISTS deposits "
|
||||
"(serial_id BIGSERIAL PRIMARY KEY"
|
||||
",coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)"
|
||||
",denom_pub BYTEA NOT NULL REFERENCES denominations (pub)"
|
||||
",denom_sig BYTEA NOT NULL"
|
||||
",coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub)"
|
||||
",transaction_id INT8 NOT NULL"
|
||||
",amount_with_fee_val INT8 NOT NULL"
|
||||
",amount_with_fee_frac INT4 NOT NULL"
|
||||
@ -910,8 +908,6 @@ postgres_prepare (PGconn *db_conn)
|
||||
PREPARE ("insert_deposit",
|
||||
"INSERT INTO deposits "
|
||||
"(coin_pub"
|
||||
",denom_pub"
|
||||
",denom_sig"
|
||||
",transaction_id"
|
||||
",amount_with_fee_val"
|
||||
",amount_with_fee_frac"
|
||||
@ -929,8 +925,8 @@ postgres_prepare (PGconn *db_conn)
|
||||
",wire"
|
||||
") VALUES "
|
||||
"($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
|
||||
" $11, $12, $13, $14, $15, $16, $17, $18);",
|
||||
18, NULL);
|
||||
" $11, $12, $13, $14, $15, $16);",
|
||||
16, NULL);
|
||||
|
||||
/* Used in #postgres_insert_refund() to store refund information */
|
||||
PREPARE ("insert_refund",
|
||||
@ -1070,9 +1066,7 @@ postgres_prepare (PGconn *db_conn)
|
||||
about how a coin has been spend with /deposit requests. */
|
||||
PREPARE ("get_deposit_with_coin_pub",
|
||||
"SELECT"
|
||||
" denom_pub"
|
||||
",denom_sig"
|
||||
",transaction_id"
|
||||
" transaction_id"
|
||||
",amount_with_fee_val"
|
||||
",amount_with_fee_frac"
|
||||
",amount_with_fee_curr"
|
||||
@ -2551,6 +2545,106 @@ postgres_iterate_matching_deposits (void *cls,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the record for a known coin.
|
||||
*
|
||||
* @param cls the plugin closure
|
||||
* @param session the database session handle
|
||||
* @param coin_pub the public key of the coin to search for
|
||||
* @param coin_info place holder for the returned coin information object
|
||||
* @return #GNUNET_SYSERR upon error; #GNUNET_NO if no coin is found; #GNUNET_OK
|
||||
* if upon succesfullying retrieving the record data info @a
|
||||
* coin_info
|
||||
*/
|
||||
static int
|
||||
get_known_coin (void *cls,
|
||||
struct TALER_EXCHANGEDB_Session *session,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
struct TALER_CoinPublicInfo *coin_info)
|
||||
{
|
||||
PGresult *result;
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (coin_pub),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
int nrows;
|
||||
|
||||
result = GNUNET_PQ_exec_prepared (session->conn,
|
||||
"get_known_coin",
|
||||
params);
|
||||
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
||||
{
|
||||
BREAK_DB_ERR (result);
|
||||
PQclear (result);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
nrows = PQntuples (result);
|
||||
if (0 == nrows)
|
||||
{
|
||||
PQclear (result);
|
||||
return GNUNET_NO;
|
||||
}
|
||||
GNUNET_assert (1 == nrows); /* due to primary key */
|
||||
if (NULL == coin_info)
|
||||
return GNUNET_YES;
|
||||
{
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
GNUNET_PQ_result_spec_rsa_public_key ("denom_pub",
|
||||
&coin_info->denom_pub.rsa_public_key),
|
||||
GNUNET_PQ_result_spec_rsa_signature ("denom_sig",
|
||||
&coin_info->denom_sig.rsa_signature),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_PQ_extract_result (result, rs, 0))
|
||||
{
|
||||
PQclear (result);
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
}
|
||||
PQclear (result);
|
||||
coin_info->coin_pub = *coin_pub;
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a coin we know of into the DB. The coin can then be referenced by
|
||||
* tables for deposits, refresh and refund functionality.
|
||||
*
|
||||
* @param cls plugin closure
|
||||
* @param session the shared database session
|
||||
* @param coin_info the public coin info
|
||||
* @return #GNUNET_SYSERR upon error; #GNUNET_OK upon success
|
||||
*/
|
||||
static int
|
||||
insert_known_coin (void *cls,
|
||||
struct TALER_EXCHANGEDB_Session *session,
|
||||
const struct TALER_CoinPublicInfo *coin_info)
|
||||
{
|
||||
PGresult *result;
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (&coin_info->coin_pub),
|
||||
GNUNET_PQ_query_param_rsa_public_key (coin_info->denom_pub.rsa_public_key),
|
||||
GNUNET_PQ_query_param_rsa_signature (coin_info->denom_sig.rsa_signature),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
result = GNUNET_PQ_exec_prepared (session->conn,
|
||||
"insert_known_coin",
|
||||
params);
|
||||
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
||||
{
|
||||
BREAK_DB_ERR (result);
|
||||
PQclear (result);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
PQclear (result);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert information about deposited coin into the database.
|
||||
*
|
||||
@ -2568,8 +2662,6 @@ postgres_insert_deposit (void *cls,
|
||||
int ret;
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (&deposit->coin.coin_pub),
|
||||
GNUNET_PQ_query_param_rsa_public_key (deposit->coin.denom_pub.rsa_public_key),
|
||||
GNUNET_PQ_query_param_rsa_signature (deposit->coin.denom_sig.rsa_signature),
|
||||
GNUNET_PQ_query_param_uint64 (&deposit->transaction_id),
|
||||
TALER_PQ_query_param_amount (&deposit->amount_with_fee),
|
||||
TALER_PQ_query_param_amount (&deposit->deposit_fee),
|
||||
@ -2583,6 +2675,29 @@ postgres_insert_deposit (void *cls,
|
||||
TALER_PQ_query_param_json (deposit->wire),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
|
||||
/* check if the coin is already known */
|
||||
ret = get_known_coin (cls,
|
||||
session,
|
||||
&deposit->coin.coin_pub,
|
||||
NULL);
|
||||
if (GNUNET_SYSERR == ret)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
if (GNUNET_NO == ret) /* if not, insert it */
|
||||
{
|
||||
if (GNUNET_SYSERR ==
|
||||
insert_known_coin (cls,
|
||||
session,
|
||||
&deposit->coin))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
}
|
||||
|
||||
result = GNUNET_PQ_exec_prepared (session->conn,
|
||||
"insert_deposit",
|
||||
params);
|
||||
@ -2757,106 +2872,6 @@ postgres_create_refresh_session (void *cls,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a coin we know of into the DB. The coin can then be referenced by
|
||||
* tables for deposits, lock and refresh functionality.
|
||||
*
|
||||
* @param cls plugin closure
|
||||
* @param session the shared database session
|
||||
* @param coin_info the public coin info
|
||||
* @return #GNUNET_SYSERR upon error; #GNUNET_OK upon success
|
||||
*/
|
||||
static int
|
||||
insert_known_coin (void *cls,
|
||||
struct TALER_EXCHANGEDB_Session *session,
|
||||
const struct TALER_CoinPublicInfo *coin_info)
|
||||
{
|
||||
PGresult *result;
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (&coin_info->coin_pub),
|
||||
GNUNET_PQ_query_param_rsa_public_key (coin_info->denom_pub.rsa_public_key),
|
||||
GNUNET_PQ_query_param_rsa_signature (coin_info->denom_sig.rsa_signature),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
result = GNUNET_PQ_exec_prepared (session->conn,
|
||||
"insert_known_coin",
|
||||
params);
|
||||
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
||||
{
|
||||
BREAK_DB_ERR (result);
|
||||
PQclear (result);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
PQclear (result);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the record for a known coin.
|
||||
*
|
||||
* @param cls the plugin closure
|
||||
* @param session the database session handle
|
||||
* @param coin_pub the public key of the coin to search for
|
||||
* @param coin_info place holder for the returned coin information object
|
||||
* @return #GNUNET_SYSERR upon error; #GNUNET_NO if no coin is found; #GNUNET_OK
|
||||
* if upon succesfullying retrieving the record data info @a
|
||||
* coin_info
|
||||
*/
|
||||
static int
|
||||
get_known_coin (void *cls,
|
||||
struct TALER_EXCHANGEDB_Session *session,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
struct TALER_CoinPublicInfo *coin_info)
|
||||
{
|
||||
PGresult *result;
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (coin_pub),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
int nrows;
|
||||
|
||||
result = GNUNET_PQ_exec_prepared (session->conn,
|
||||
"get_known_coin",
|
||||
params);
|
||||
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
||||
{
|
||||
BREAK_DB_ERR (result);
|
||||
PQclear (result);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
nrows = PQntuples (result);
|
||||
if (0 == nrows)
|
||||
{
|
||||
PQclear (result);
|
||||
return GNUNET_NO;
|
||||
}
|
||||
GNUNET_assert (1 == nrows); /* due to primary key */
|
||||
if (NULL == coin_info)
|
||||
return GNUNET_YES;
|
||||
{
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
GNUNET_PQ_result_spec_rsa_public_key ("denom_pub",
|
||||
&coin_info->denom_pub.rsa_public_key),
|
||||
GNUNET_PQ_result_spec_rsa_signature ("denom_sig",
|
||||
&coin_info->denom_sig.rsa_signature),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_PQ_extract_result (result, rs, 0))
|
||||
{
|
||||
PQclear (result);
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
}
|
||||
PQclear (result);
|
||||
coin_info->coin_pub = *coin_pub;
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store the given /refresh/melt request in the database.
|
||||
*
|
||||
@ -2898,10 +2913,10 @@ postgres_insert_refresh_melt (void *cls,
|
||||
}
|
||||
if (GNUNET_NO == ret) /* if not, insert it */
|
||||
{
|
||||
ret = insert_known_coin (cls,
|
||||
session,
|
||||
&melt->coin);
|
||||
if (ret == GNUNET_SYSERR)
|
||||
if (GNUNET_SYSERR ==
|
||||
insert_known_coin (cls,
|
||||
session,
|
||||
&melt->coin))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
@ -2988,10 +3003,11 @@ postgres_get_refresh_melt (void *cls,
|
||||
PQclear (result);
|
||||
}
|
||||
/* fetch the coin info and denomination info */
|
||||
if (GNUNET_OK != get_known_coin (cls,
|
||||
session,
|
||||
&coin.coin_pub,
|
||||
&coin))
|
||||
if (GNUNET_OK !=
|
||||
get_known_coin (cls,
|
||||
session,
|
||||
&coin.coin_pub,
|
||||
&coin))
|
||||
return GNUNET_SYSERR;
|
||||
if (NULL == melt)
|
||||
{
|
||||
@ -3803,15 +3819,6 @@ postgres_get_coin_transactions (void *cls,
|
||||
deposit = GNUNET_new (struct TALER_EXCHANGEDB_Deposit);
|
||||
{
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
/* FIXME: do we care about the denom_*s? We do not keep
|
||||
them for refresh/refund, and it's unclear why we'd
|
||||
bother with them here. (Kept for now, once we have
|
||||
the auditor done we should decide if we want to always
|
||||
take these along, or always drop them.) */
|
||||
GNUNET_PQ_result_spec_rsa_public_key ("denom_pub",
|
||||
&deposit->coin.denom_pub.rsa_public_key),
|
||||
GNUNET_PQ_result_spec_rsa_signature ("denom_sig",
|
||||
&deposit->coin.denom_sig.rsa_signature),
|
||||
GNUNET_PQ_result_spec_uint64 ("transaction_id",
|
||||
&deposit->transaction_id),
|
||||
TALER_PQ_result_spec_amount ("amount_with_fee",
|
||||
|
@ -24,8 +24,14 @@
|
||||
#include "taler_json_lib.h"
|
||||
#include "taler_exchangedb_plugin.h"
|
||||
|
||||
/**
|
||||
* Global result from the testcase.
|
||||
*/
|
||||
static int result;
|
||||
|
||||
/**
|
||||
* Report line of error if @a cond is true, and jump to label "drop".
|
||||
*/
|
||||
#define FAILIF(cond) \
|
||||
do { \
|
||||
if (!(cond)){ break;} \
|
||||
@ -34,17 +40,48 @@ static int result;
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* Initializes @a ptr with random data.
|
||||
*/
|
||||
#define RND_BLK(ptr) \
|
||||
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (*ptr))
|
||||
|
||||
/**
|
||||
* Initializes @a ptr with zeros.
|
||||
*/
|
||||
#define ZR_BLK(ptr) \
|
||||
memset (ptr, 0, sizeof (*ptr))
|
||||
|
||||
|
||||
/**
|
||||
* Currency we use.
|
||||
*/
|
||||
#define CURRENCY "EUR"
|
||||
|
||||
/**
|
||||
* Database plugin under test.
|
||||
*/
|
||||
static struct TALER_EXCHANGEDB_Plugin *plugin;
|
||||
|
||||
|
||||
/**
|
||||
* Test API relating to persisting the wire plugins preparation data.
|
||||
*
|
||||
* @param session database session to use for the test
|
||||
* @return #GNUNET_OK on success
|
||||
*/
|
||||
static int
|
||||
test_wire_prepare (struct TALER_EXCHANGEDB_Session *session)
|
||||
{
|
||||
/*
|
||||
FIXME #4401: test: wire_prepare_data_insert
|
||||
FIXME #4401: test: wire_prepare_data_mark_finished
|
||||
FIXME #4401: test: wire_prepare_data_get
|
||||
*/
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the given reserve has the given amount of balance and expiry
|
||||
*
|
||||
@ -198,6 +235,12 @@ static struct TALER_Amount fee_refund;
|
||||
static struct TALER_Amount amount_with_fee;
|
||||
|
||||
|
||||
/**
|
||||
* Free memory associated with @a commit_coins.
|
||||
*
|
||||
* @param commit_coins memory to release
|
||||
* @param size size of the @a commit_coins array
|
||||
*/
|
||||
static void
|
||||
free_refresh_commit_coins_array (struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins,
|
||||
unsigned int size)
|
||||
@ -216,11 +259,21 @@ free_refresh_commit_coins_array (struct TALER_EXCHANGEDB_RefreshCommitCoin *comm
|
||||
GNUNET_free (commit_coins);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Number of newly minted coins to use in the test.
|
||||
*/
|
||||
#define MELT_NEW_COINS 5
|
||||
|
||||
/**
|
||||
*
|
||||
* @param session database sesison to use
|
||||
* @param refresh_session details about the refresh session to use
|
||||
* @param session_hash refresh melt session hash to use
|
||||
*/
|
||||
static int
|
||||
test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session,
|
||||
struct TALER_EXCHANGEDB_RefreshSession *refresh_session,
|
||||
const struct TALER_EXCHANGEDB_RefreshSession *refresh_session,
|
||||
const struct GNUNET_HashCode *session_hash)
|
||||
{
|
||||
struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins;
|
||||
@ -364,7 +417,8 @@ test_melting (struct TALER_EXCHANGEDB_Session *session)
|
||||
&fee_refresh,
|
||||
&fee_refund);
|
||||
/* create MELT_OLD_COINS number of refresh melts */
|
||||
melts = GNUNET_new_array (MELT_OLD_COINS, struct TALER_EXCHANGEDB_RefreshMelt);
|
||||
melts = GNUNET_new_array (MELT_OLD_COINS,
|
||||
struct TALER_EXCHANGEDB_RefreshMelt);
|
||||
for (cnt=0; cnt < MELT_OLD_COINS; cnt++)
|
||||
{
|
||||
struct GNUNET_HashCode hc;
|
||||
@ -381,19 +435,21 @@ test_melting (struct TALER_EXCHANGEDB_Session *session)
|
||||
melts[cnt].session_hash = session_hash;
|
||||
melts[cnt].amount_with_fee = amount_with_fee;
|
||||
melts[cnt].melt_fee = fee_refresh;
|
||||
FAILIF (GNUNET_OK != plugin->insert_refresh_melt (plugin->cls,
|
||||
session,
|
||||
cnt,
|
||||
&melts[cnt]));
|
||||
FAILIF (GNUNET_OK !=
|
||||
plugin->insert_refresh_melt (plugin->cls,
|
||||
session,
|
||||
cnt,
|
||||
&melts[cnt]));
|
||||
}
|
||||
for (cnt = 0; cnt < MELT_OLD_COINS; cnt++)
|
||||
{
|
||||
struct TALER_EXCHANGEDB_RefreshMelt ret_melt;
|
||||
FAILIF (GNUNET_OK != plugin->get_refresh_melt (plugin->cls,
|
||||
session,
|
||||
&session_hash,
|
||||
cnt,
|
||||
&ret_melt));
|
||||
FAILIF (GNUNET_OK !=
|
||||
plugin->get_refresh_melt (plugin->cls,
|
||||
session,
|
||||
&session_hash,
|
||||
cnt,
|
||||
&ret_melt));
|
||||
FAILIF (0 != GNUNET_CRYPTO_rsa_signature_cmp
|
||||
(ret_melt.coin.denom_sig.rsa_signature,
|
||||
melts[cnt].coin.denom_sig.rsa_signature));
|
||||
@ -579,6 +635,9 @@ cb_wtid_check (void *cls,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Here #deposit_cb() will store the row ID of the deposit.
|
||||
*/
|
||||
static unsigned long long deposit_rowid;
|
||||
|
||||
|
||||
@ -647,7 +706,7 @@ deposit_cb (void *cls,
|
||||
}
|
||||
|
||||
|
||||
static struct TALER_EXCHANGEDB_Refund refund;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -670,9 +729,13 @@ run (void *cls)
|
||||
struct TALER_EXCHANGEDB_CollectableBlindcoin *withdraw;
|
||||
struct TALER_EXCHANGEDB_Deposit deposit;
|
||||
struct TALER_EXCHANGEDB_Deposit deposit2;
|
||||
struct TALER_EXCHANGEDB_Refund refund;
|
||||
struct TALER_EXCHANGEDB_TransactionList *tl;
|
||||
struct TALER_EXCHANGEDB_TransactionList *tlp;
|
||||
struct TALER_WireTransferIdentifierRawP wtid;
|
||||
json_t *wire;
|
||||
json_t *just;
|
||||
unsigned int matched;
|
||||
const char * const json_wire_str =
|
||||
"{ \"type\":\"SEPA\", \
|
||||
\"IBAN\":\"DE67830654080004822650\", \
|
||||
@ -929,7 +992,6 @@ run (void *cls)
|
||||
session,
|
||||
&deposit));
|
||||
|
||||
|
||||
result = 10;
|
||||
deposit2 = deposit;
|
||||
deposit2.transaction_id++; /* should fail if transaction id is different */
|
||||
@ -951,6 +1013,124 @@ run (void *cls)
|
||||
&deposit2));
|
||||
FAILIF (GNUNET_OK != test_melting (session));
|
||||
|
||||
|
||||
/* test insert_refund! */
|
||||
refund.coin = deposit.coin;
|
||||
refund.merchant_pub = deposit.merchant_pub;
|
||||
RND_BLK (&refund.merchant_sig);
|
||||
refund.h_contract = deposit.h_contract;
|
||||
refund.transaction_id = deposit.transaction_id;
|
||||
refund.rtransaction_id = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
|
||||
refund.refund_amount = deposit.amount_with_fee;
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_amount_get_zero (CURRENCY, &refund.refund_fee));
|
||||
FAILIF (GNUNET_OK !=
|
||||
plugin->insert_refund (plugin->cls,
|
||||
session,
|
||||
&refund));
|
||||
|
||||
tl = plugin->get_coin_transactions (plugin->cls,
|
||||
session,
|
||||
&refund.coin.coin_pub);
|
||||
GNUNET_assert (NULL != tl);
|
||||
matched = 0;
|
||||
for (tlp = tl; NULL != tlp; tlp = tlp->next)
|
||||
{
|
||||
switch (tlp->type)
|
||||
{
|
||||
case TALER_EXCHANGEDB_TT_DEPOSIT:
|
||||
{
|
||||
struct TALER_EXCHANGEDB_Deposit *have = tlp->details.deposit;
|
||||
|
||||
FAILIF (0 != memcmp (&have->coin.coin_pub,
|
||||
&deposit.coin.coin_pub,
|
||||
sizeof (struct TALER_CoinSpendPublicKeyP)));
|
||||
/* Note: we're not comparing the denomination keys, as there is
|
||||
still the question of whether we should even bother exporting
|
||||
them here. */
|
||||
FAILIF (0 != memcmp (&have->csig,
|
||||
&deposit.csig,
|
||||
sizeof (struct TALER_CoinSpendSignatureP)));
|
||||
FAILIF (0 != memcmp (&have->merchant_pub,
|
||||
&deposit.merchant_pub,
|
||||
sizeof (struct TALER_MerchantPublicKeyP)));
|
||||
FAILIF (0 != memcmp (&have->h_contract,
|
||||
&deposit.h_contract,
|
||||
sizeof (struct GNUNET_HashCode)));
|
||||
FAILIF (0 != memcmp (&have->h_wire,
|
||||
&deposit.h_wire,
|
||||
sizeof (struct GNUNET_HashCode)));
|
||||
/* Note: not comparing 'wire', seems truly redundant and would be tricky */
|
||||
FAILIF (have->transaction_id != deposit.transaction_id);
|
||||
FAILIF (have->timestamp.abs_value_us != deposit.timestamp.abs_value_us);
|
||||
FAILIF (have->refund_deadline.abs_value_us != deposit.refund_deadline.abs_value_us);
|
||||
FAILIF (have->wire_deadline.abs_value_us != deposit.wire_deadline.abs_value_us);
|
||||
FAILIF (0 != TALER_amount_cmp (&have->amount_with_fee,
|
||||
&deposit.amount_with_fee));
|
||||
FAILIF (0 != TALER_amount_cmp (&have->deposit_fee,
|
||||
&deposit.deposit_fee));
|
||||
matched |= 1;
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
/* this coin pub was actually never melted... */
|
||||
case TALER_EXCHANGEDB_TT_REFRESH_MELT:
|
||||
FAILIF (0 != memcmp (&melt,
|
||||
&tlp->details.melt,
|
||||
sizeof (struct TALER_EXCHANGEDB_RefreshMelt)));
|
||||
matched |= 2;
|
||||
break;
|
||||
#endif
|
||||
case TALER_EXCHANGEDB_TT_REFUND:
|
||||
{
|
||||
struct TALER_EXCHANGEDB_Refund *have = tlp->details.refund;
|
||||
|
||||
FAILIF (0 != memcmp (&have->coin.coin_pub,
|
||||
&refund.coin.coin_pub,
|
||||
sizeof (struct TALER_CoinSpendPublicKeyP)));
|
||||
/* Note: we're not comparing the denomination keys, as there is
|
||||
still the question of whether we should even bother exporting
|
||||
them here. */
|
||||
FAILIF (0 != memcmp (&have->merchant_pub,
|
||||
&refund.merchant_pub,
|
||||
sizeof (struct TALER_MerchantPublicKeyP)));
|
||||
FAILIF (0 != memcmp (&have->merchant_sig,
|
||||
&refund.merchant_sig,
|
||||
sizeof (struct TALER_MerchantSignatureP)));
|
||||
FAILIF (0 != memcmp (&have->h_contract,
|
||||
&refund.h_contract,
|
||||
sizeof (struct GNUNET_HashCode)));
|
||||
FAILIF (have->transaction_id != refund.transaction_id);
|
||||
FAILIF (have->rtransaction_id != refund.rtransaction_id);
|
||||
FAILIF (0 != TALER_amount_cmp (&have->refund_amount,
|
||||
&refund.refund_amount));
|
||||
FAILIF (0 != TALER_amount_cmp (&have->refund_fee,
|
||||
&refund.refund_fee));
|
||||
matched |= 4;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
FAILIF (1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
FAILIF (5 != matched);
|
||||
|
||||
plugin->free_coin_transaction_list (plugin->cls,
|
||||
tl);
|
||||
|
||||
FAILIF (GNUNET_OK != test_wire_prepare (session));
|
||||
|
||||
/* FIXME #4401: test: insert_refresh_commit_links
|
||||
FIXME #4401: test: get_refresh_commit_links
|
||||
FIXME #4401: test: get_melt_commitment
|
||||
FIXME #4401: test: free_melt_commitment
|
||||
FIXME #4401: test: insert_refresh_out
|
||||
FIXME #4401: test: get_link_data_list
|
||||
FIXME #4401: test: free_link_data_list
|
||||
FIXME #4401: test: get_transfer
|
||||
*/
|
||||
|
||||
/* setup values for wire transfer aggregation data */
|
||||
memset (&wtid, 42, sizeof (wtid));
|
||||
memset (&merchant_pub_wt, 43, sizeof (merchant_pub_wt));
|
||||
@ -969,29 +1149,7 @@ run (void *cls)
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_string_to_amount (CURRENCY "KUDOS:1.000000",
|
||||
&transfer_value_wt));
|
||||
#if 0
|
||||
/* FIXME #4401: test insert_refund! */
|
||||
refund.FOO = bar;
|
||||
FAILIF (GNUNET_OK !=
|
||||
plugin->insert_refund (plugin->cls,
|
||||
session,
|
||||
&refund));
|
||||
#endif
|
||||
/* FIXME #4401: test: insert_refresh_commit_links
|
||||
FIXME #4401: test: get_refresh_commit_links
|
||||
FIXME #4401: test: get_melt_commitment
|
||||
FIXME #4401: test: free_melt_commitment
|
||||
FIXME #4401: test: insert_refresh_out
|
||||
FIXME #4401: test: get_link_data_list
|
||||
FIXME #4401: test: free_link_data_list
|
||||
FIXME #4401: test: get_transfer
|
||||
FIXME #4401: test: get_coin_transactions
|
||||
FIXME #4401: test: free_coin_transaction_list
|
||||
FIXME #4401: test: wire_prepare_data_insert
|
||||
FIXME #4401: test: wire_prepare_data_mark_finished
|
||||
FIXME #4401: test: wire_prepare_data_get
|
||||
|
||||
*/
|
||||
|
||||
FAILIF (GNUNET_NO !=
|
||||
plugin->lookup_wire_transfer (plugin->cls,
|
||||
|
Loading…
Reference in New Issue
Block a user