fixing misc. minor bugs, towards getting testcases to work
This commit is contained in:
parent
3ac86568b0
commit
6b9ccc4ca0
@ -60,6 +60,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn,
|
||||
break;
|
||||
case TALER_PQ_QF_RSA_PUBLIC_KEY:
|
||||
case TALER_PQ_QF_RSA_SIGNATURE:
|
||||
case TALER_PQ_QF_TIME_ABSOLUTE:
|
||||
len++;
|
||||
break;
|
||||
default:
|
||||
@ -67,6 +68,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn,
|
||||
GNUNET_assert (0);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* new scope to allow stack allocation without alloca */
|
||||
@ -190,6 +192,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn,
|
||||
GNUNET_assert (0);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
GNUNET_assert (off == len);
|
||||
res = PQexecPrepared (db_conn,
|
||||
@ -200,7 +203,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn,
|
||||
param_formats,
|
||||
1);
|
||||
for (off = 0; off < soff; off++)
|
||||
GNUNET_free (scratch[soff]);
|
||||
GNUNET_free (scratch[off]);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ TALER_PQ_RESULT_SPEC_AMOUNT (const char *name,
|
||||
struct TALER_Amount *amount)
|
||||
{
|
||||
struct TALER_PQ_ResultSpec res =
|
||||
{TALER_PQ_RF_AMOUNT, (void *) (&amount), sizeof (amount), (name), NULL };
|
||||
{TALER_PQ_RF_AMOUNT, (void *) (&amount), sizeof (*amount), (name), NULL };
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,17 @@ run_queries (PGconn *conn)
|
||||
struct TALER_Amount hamount2;
|
||||
struct TALER_AmountNBO namount;
|
||||
struct TALER_AmountNBO namount2;
|
||||
PGresult *result;
|
||||
int ret;
|
||||
struct GNUNET_CRYPTO_rsa_PrivateKey *priv;
|
||||
char msg[] = "Hello";
|
||||
|
||||
priv = GNUNET_CRYPTO_rsa_private_key_create (1024);
|
||||
pub = GNUNET_CRYPTO_rsa_private_key_get_public (priv);
|
||||
sig = GNUNET_CRYPTO_rsa_sign (priv,
|
||||
msg,
|
||||
sizeof (msg));
|
||||
{
|
||||
struct TALER_PQ_QueryParam params_insert[] = {
|
||||
TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (pub),
|
||||
TALER_PQ_QUERY_PARAM_RSA_SIGNATURE (sig),
|
||||
@ -131,10 +142,8 @@ run_queries (PGconn *conn)
|
||||
TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("namount", &namount2),
|
||||
TALER_PQ_RESULT_SPEC_END
|
||||
};
|
||||
PGresult *result;
|
||||
int ret;
|
||||
|
||||
// FIXME: init pub, sig
|
||||
|
||||
result = TALER_PQ_exec_prepared (conn,
|
||||
"test_insert",
|
||||
params_insert);
|
||||
@ -146,9 +155,13 @@ run_queries (PGconn *conn)
|
||||
results_select,
|
||||
0);
|
||||
// FIXME: cmp results!
|
||||
|
||||
TALER_PQ_cleanup_result (results_select);
|
||||
PQclear (result);
|
||||
|
||||
}
|
||||
GNUNET_CRYPTO_rsa_signature_free (sig);
|
||||
GNUNET_CRYPTO_rsa_private_key_free (priv);
|
||||
GNUNET_CRYPTO_rsa_public_key_free (pub);
|
||||
if (GNUNET_OK != ret)
|
||||
return 1;
|
||||
|
||||
@ -165,6 +178,9 @@ main(int argc,
|
||||
int ret;
|
||||
|
||||
// FIXME: pass valid connect string for tests...
|
||||
GNUNET_log_setup ("test-pq",
|
||||
"WARNING",
|
||||
NULL);
|
||||
conn = PQconnectdb ("postgres:///talercheck");
|
||||
if (CONNECTION_OK != PQstatus (conn))
|
||||
{
|
||||
@ -204,7 +220,6 @@ main(int argc,
|
||||
postgres_prepare (conn))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
PQclear (result);
|
||||
PQfinish (conn);
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user