diff options
Diffstat (limited to 'src/backenddb/test_merchantdb.c')
-rw-r--r-- | src/backenddb/test_merchantdb.c | 82 |
1 files changed, 62 insertions, 20 deletions
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 2d0ca0ca..0d4b2c63 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -54,9 +54,13 @@ run (void *cls) uint64_t transaction_id; struct GNUNET_TIME_Absolute timestamp; struct GNUNET_TIME_Absolute refund; - struct TALER_Amount amount_without_fee; + struct TALER_Amount amount_with_fee; + struct TALER_Amount deposit_fee; struct TALER_CoinSpendPublicKeyP coin_pub; - json_t *exchange_proof = NULL; + struct TALER_ExchangePublicKeyP signkey_pub; + struct TALER_WireTransferIdentifierRawP wtid; + json_t *deposit_proof = NULL; + json_t *transfer_proof = NULL; FAILIF (NULL == (plugin = TALER_MERCHANTDB_plugin_load (cfg))); (void) plugin->drop_tables (plugin->cls); @@ -66,25 +70,59 @@ run (void *cls) RND_BLK (&h_contract); RND_BLK (&h_wire); RND_BLK (&transaction_id); + RND_BLK (&signkey_pub); + RND_BLK (&wtid); timestamp = GNUNET_TIME_absolute_get(); refund = GNUNET_TIME_absolute_get(); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":1.000010", - &amount_without_fee)); + &amount_with_fee)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":0.000010", + &deposit_fee)); RND_BLK (&coin_pub); - exchange_proof = json_object (); - GNUNET_assert (0 == json_object_set (exchange_proof, "test", json_string ("backenddb test"))); + deposit_proof = json_object (); + GNUNET_assert (0 == + json_object_set (deposit_proof, + "test", + json_string ("backenddb test A"))); + transfer_proof = json_object (); + GNUNET_assert (0 == + json_object_set (transfer_proof, + "test", + json_string ("backenddb test B"))); + FAILIF (GNUNET_OK != + plugin->store_transaction (plugin->cls, + transaction_id, + "http://localhost:8888/", + &h_contract, + &h_wire, + timestamp, + refund, + &amount_with_fee)); + FAILIF (GNUNET_OK != + plugin->store_deposit (plugin->cls, + transaction_id, + &coin_pub, + &amount_with_fee, + &deposit_fee, + &signkey_pub, + deposit_proof)); + FAILIF (GNUNET_OK != + plugin->store_coin_to_transfer (plugin->cls, + transaction_id, + &coin_pub, + &wtid)); + FAILIF (GNUNET_OK != + plugin->store_transfer_to_proof (plugin->cls, + "http://localhost:8888/", + &wtid, + &signkey_pub, + transfer_proof)); #if 0 - FAILIF (GNUNET_OK != plugin->store_payment (plugin->cls, - &h_contract, - &h_wire, - transaction_id, - timestamp, - refund, - &amount_without_fee, - &coin_pub, - exchange_proof)); - FAILIF (GNUNET_OK != plugin->check_payment (plugin->cls, transaction_id)); + FAILIF (GNUNET_OK != + plugin->check_payment (plugin->cls, + transaction_id)); #endif result = 0; @@ -92,15 +130,17 @@ run (void *cls) GNUNET_break (GNUNET_OK == plugin->drop_tables (plugin->cls)); TALER_MERCHANTDB_plugin_unload (plugin); plugin = NULL; - if (NULL != exchange_proof) - json_decref(exchange_proof); + if (NULL != deposit_proof) + json_decref (deposit_proof); + if (NULL != transfer_proof) + json_decref (transfer_proof); } + int main (int argc, char *const argv[]) { - const char *plugin_name; char *config_filename; char *testname; @@ -115,9 +155,11 @@ main (int argc, GNUNET_log_setup (argv[0], "WARNING", NULL); plugin_name++; (void) GNUNET_asprintf (&testname, - "test-merchantdb-%s", plugin_name); + "test-merchantdb-%s", + plugin_name); (void) GNUNET_asprintf (&config_filename, - "%s.conf", testname); + "%s.conf", + testname); cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, |