completing test-case implementation:
This commit is contained in:
parent
6b9ccc4ca0
commit
6c774a1f03
@ -113,7 +113,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn,
|
|||||||
param_formats[off] = 1;
|
param_formats[off] = 1;
|
||||||
off++;
|
off++;
|
||||||
param_values[off] = (void *) amount->currency;
|
param_values[off] = (void *) amount->currency;
|
||||||
param_lengths[off] = strlen (amount->currency) + 1;
|
param_lengths[off] = strlen (amount->currency);
|
||||||
param_formats[off] = 1;
|
param_formats[off] = 1;
|
||||||
off++;
|
off++;
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn,
|
|||||||
param_formats[off] = 1;
|
param_formats[off] = 1;
|
||||||
off++;
|
off++;
|
||||||
param_values[off] = (void *) amount->currency;
|
param_values[off] = (void *) amount->currency;
|
||||||
param_lengths[off] = strlen (amount->currency) + 1;
|
param_lengths[off] = strlen (amount->currency);
|
||||||
param_formats[off] = 1;
|
param_formats[off] = 1;
|
||||||
off++;
|
off++;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ TALER_PQ_RESULT_SPEC_AMOUNT_NBO (const char *name,
|
|||||||
struct TALER_AmountNBO *amount)
|
struct TALER_AmountNBO *amount)
|
||||||
{
|
{
|
||||||
struct TALER_PQ_ResultSpec res =
|
struct TALER_PQ_ResultSpec res =
|
||||||
{TALER_PQ_RF_AMOUNT_NBO, (void *) (&amount), sizeof (amount), (name), NULL };
|
{TALER_PQ_RF_AMOUNT_NBO, (void *) (&amount), sizeof (*amount), (name), NULL };
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,12 @@ run_queries (PGconn *conn)
|
|||||||
sig = GNUNET_CRYPTO_rsa_sign (priv,
|
sig = GNUNET_CRYPTO_rsa_sign (priv,
|
||||||
msg,
|
msg,
|
||||||
sizeof (msg));
|
sizeof (msg));
|
||||||
|
TALER_string_to_amount ("EUR:5.5",
|
||||||
|
&hamount);
|
||||||
|
TALER_amount_hton (&namount,
|
||||||
|
&hamount);
|
||||||
|
TALER_string_to_amount ("EUR:4.4",
|
||||||
|
&hamount);
|
||||||
{
|
{
|
||||||
struct TALER_PQ_QueryParam params_insert[] = {
|
struct TALER_PQ_QueryParam params_insert[] = {
|
||||||
TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (pub),
|
TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (pub),
|
||||||
@ -143,19 +149,68 @@ run_queries (PGconn *conn)
|
|||||||
TALER_PQ_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fprintf (stderr,
|
||||||
|
"Inserting\n");
|
||||||
result = TALER_PQ_exec_prepared (conn,
|
result = TALER_PQ_exec_prepared (conn,
|
||||||
"test_insert",
|
"test_insert",
|
||||||
params_insert);
|
params_insert);
|
||||||
|
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Database failure: %s\n",
|
||||||
|
PQresultErrorMessage (result));
|
||||||
|
PQclear (result);
|
||||||
|
GNUNET_CRYPTO_rsa_signature_free (sig);
|
||||||
|
GNUNET_CRYPTO_rsa_private_key_free (priv);
|
||||||
|
GNUNET_CRYPTO_rsa_public_key_free (pub);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
|
fprintf (stderr,
|
||||||
|
"Selecting\n");
|
||||||
result = TALER_PQ_exec_prepared (conn,
|
result = TALER_PQ_exec_prepared (conn,
|
||||||
"test_select",
|
"test_select",
|
||||||
params_select);
|
params_select);
|
||||||
|
if (1 !=
|
||||||
|
PQntuples (result))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
PQclear (result);
|
||||||
|
GNUNET_CRYPTO_rsa_signature_free (sig);
|
||||||
|
GNUNET_CRYPTO_rsa_private_key_free (priv);
|
||||||
|
GNUNET_CRYPTO_rsa_public_key_free (pub);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
ret = TALER_PQ_extract_result (result,
|
ret = TALER_PQ_extract_result (result,
|
||||||
results_select,
|
results_select,
|
||||||
0);
|
0);
|
||||||
// FIXME: cmp results!
|
GNUNET_break (GNUNET_YES == ret);
|
||||||
|
fprintf (stderr,
|
||||||
|
"Verifying\n");
|
||||||
|
GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us);
|
||||||
|
GNUNET_break (forever.abs_value_us == forever2.abs_value_us);
|
||||||
|
GNUNET_break (0 ==
|
||||||
|
memcmp (&hc,
|
||||||
|
&hc2,
|
||||||
|
sizeof (struct GNUNET_HashCode)));
|
||||||
|
GNUNET_break (0 ==
|
||||||
|
TALER_amount_cmp (&hamount,
|
||||||
|
&hamount2));
|
||||||
|
TALER_string_to_amount ("EUR:5.5",
|
||||||
|
&hamount);
|
||||||
|
TALER_amount_ntoh (&hamount2,
|
||||||
|
&namount2);
|
||||||
|
GNUNET_break (0 ==
|
||||||
|
TALER_amount_cmp (&hamount,
|
||||||
|
&hamount2));
|
||||||
|
GNUNET_break (0 ==
|
||||||
|
GNUNET_CRYPTO_rsa_signature_cmp (sig,
|
||||||
|
sig2));
|
||||||
|
GNUNET_break (0 ==
|
||||||
|
GNUNET_CRYPTO_rsa_public_key_cmp (pub,
|
||||||
|
pub2));
|
||||||
|
|
||||||
TALER_PQ_cleanup_result (results_select);
|
TALER_PQ_cleanup_result (results_select);
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user