diff options
Diffstat (limited to 'src/exchange-lib')
-rw-r--r-- | src/exchange-lib/exchange_api_handle.c | 10 | ||||
-rw-r--r-- | src/exchange-lib/exchange_api_refresh.c | 12 | ||||
-rw-r--r-- | src/exchange-lib/test_exchange_api.c | 133 | ||||
-rw-r--r-- | src/exchange-lib/test_exchange_api.conf | 9 |
4 files changed, 51 insertions, 113 deletions
diff --git a/src/exchange-lib/exchange_api_handle.c b/src/exchange-lib/exchange_api_handle.c index 47658052..04508aa3 100644 --- a/src/exchange-lib/exchange_api_handle.c +++ b/src/exchange-lib/exchange_api_handle.c @@ -247,7 +247,7 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key, { struct GNUNET_TIME_Absolute valid_from; struct GNUNET_TIME_Absolute withdraw_valid_until; - struct GNUNET_TIME_Absolute deposit_valid_until; + struct GNUNET_TIME_Absolute expire_deposit; struct GNUNET_TIME_Absolute expire_legal; struct TALER_Amount value; struct TALER_Amount fee_withdraw; @@ -262,7 +262,7 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key, GNUNET_JSON_spec_fixed_auto ("master_sig", &sig), GNUNET_JSON_spec_absolute_time ("stamp_expire_deposit", - &deposit_valid_until), + &expire_deposit), GNUNET_JSON_spec_absolute_time ("stamp_expire_withdraw", &withdraw_valid_until), GNUNET_JSON_spec_absolute_time ("stamp_start", @@ -302,7 +302,7 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key, denom_key_issue.master = *master_key; denom_key_issue.start = GNUNET_TIME_absolute_hton (valid_from); denom_key_issue.expire_withdraw = GNUNET_TIME_absolute_hton (withdraw_valid_until); - denom_key_issue.expire_spend = GNUNET_TIME_absolute_hton (deposit_valid_until); + denom_key_issue.expire_deposit = GNUNET_TIME_absolute_hton (expire_deposit); denom_key_issue.expire_legal = GNUNET_TIME_absolute_hton (expire_legal); TALER_amount_hton (&denom_key_issue.value, &value); @@ -326,7 +326,7 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key, denom_key->h_key = denom_key_issue.denom_hash; denom_key->valid_from = valid_from; denom_key->withdraw_valid_until = withdraw_valid_until; - denom_key->deposit_valid_until = deposit_valid_until; + denom_key->expire_deposit = expire_deposit; denom_key->expire_legal = expire_legal; denom_key->value = value; denom_key->fee_withdraw = fee_withdraw; @@ -431,7 +431,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor, } kv.start = GNUNET_TIME_absolute_hton (dk->valid_from); kv.expire_withdraw = GNUNET_TIME_absolute_hton (dk->withdraw_valid_until); - kv.expire_spend = GNUNET_TIME_absolute_hton (dk->deposit_valid_until); + kv.expire_deposit = GNUNET_TIME_absolute_hton (dk->expire_deposit); kv.expire_legal = GNUNET_TIME_absolute_hton (dk->expire_legal); TALER_amount_hton (&kv.value, &dk->value); diff --git a/src/exchange-lib/exchange_api_refresh.c b/src/exchange-lib/exchange_api_refresh.c index 5fe17567..f112152c 100644 --- a/src/exchange-lib/exchange_api_refresh.c +++ b/src/exchange-lib/exchange_api_refresh.c @@ -73,7 +73,7 @@ struct MeltedCoinP /** * Timestamp indicating when coins of this denomination become invalid. */ - struct GNUNET_TIME_AbsoluteNBO deposit_valid_until; + struct GNUNET_TIME_AbsoluteNBO expire_deposit; /** * Size of the encoded public key that follows. @@ -189,7 +189,7 @@ struct MeltedCoin /** * Timestamp indicating when coins of this denomination become invalid. */ - struct GNUNET_TIME_Absolute deposit_valid_until; + struct GNUNET_TIME_Absolute expire_deposit; /** * Denomination key of the original coin. @@ -396,7 +396,7 @@ serialize_melted_coin (const struct MeltedCoin *mc, &mc->original_value); for (i=0;i<TALER_CNC_KAPPA;i++) mcp.transfer_priv[i] = mc->transfer_priv[i]; - mcp.deposit_valid_until = GNUNET_TIME_absolute_hton (mc->deposit_valid_until); + mcp.expire_deposit = GNUNET_TIME_absolute_hton (mc->expire_deposit); mcp.pbuf_size = htons ((uint16_t) pbuf_size); mcp.sbuf_size = htons ((uint16_t) sbuf_size); memcpy (&buf[off], @@ -478,7 +478,7 @@ deserialize_melted_coin (struct MeltedCoin *mc, &mcp.original_value); for (i=0;i<TALER_CNC_KAPPA;i++) mc->transfer_priv[i] = mcp.transfer_priv[i]; - mc->deposit_valid_until = GNUNET_TIME_absolute_ntoh (mcp.deposit_valid_until); + mc->expire_deposit = GNUNET_TIME_absolute_ntoh (mcp.expire_deposit); return off; } @@ -891,8 +891,8 @@ TALER_EXCHANGE_refresh_prepare (unsigned int num_melts, md.melted_coins[i].transfer_priv[j].ecdhe_priv = *tpk; GNUNET_free (tpk); } - md.melted_coins[i].deposit_valid_until - = melt_pks[i].deposit_valid_until; + md.melted_coins[i].expire_deposit + = melt_pks[i].expire_deposit; md.melted_coins[i].pub_key.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (melt_pks[i].key.rsa_public_key); md.melted_coins[i].sig.rsa_signature diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c index 2936f68f..e48c59b2 100644 --- a/src/exchange-lib/test_exchange_api.c +++ b/src/exchange-lib/test_exchange_api.c @@ -48,14 +48,14 @@ static struct GNUNET_CURL_Context *ctx; static struct TALER_EXCHANGE_Handle *exchange; /** - * Task run on shutdown. + * Context for running the CURL event loop. */ -static struct GNUNET_SCHEDULER_Task *shutdown_task; +static struct GNUNET_CURL_RescheduleContext *rc; /** - * Task that runs the main event loop. + * Task run on timeout. */ -static struct GNUNET_SCHEDULER_Task *ctx_task; +static struct GNUNET_SCHEDULER_Task *timeout_task; /** * Result of the testcases, #GNUNET_OK on success @@ -570,27 +570,6 @@ struct InterpreterState /** - * Task that runs the context's event loop with the GNUnet scheduler. - * - * @param cls unused - */ -static void -context_task (void *cls); - - -/** - * Run the context task, the working set has changed. - */ -static void -trigger_context_task () -{ - GNUNET_SCHEDULER_cancel (ctx_task); - ctx_task = GNUNET_SCHEDULER_add_now (&context_task, - NULL); -} - - -/** * The testcase failed, return with an error code. * * @param is interpreter state to clean up @@ -1499,7 +1478,6 @@ interpreter_run (void *cls) fail (is); return; } - trigger_context_task (); return; case OC_WITHDRAW_STATUS: GNUNET_assert (NULL != @@ -1515,7 +1493,6 @@ interpreter_run (void *cls) &reserve_pub, &reserve_status_cb, is); - trigger_context_task (); return; case OC_WITHDRAW_SIGN: GNUNET_assert (NULL != @@ -1575,7 +1552,6 @@ interpreter_run (void *cls) fail (is); return; } - trigger_context_task (); return; case OC_DEPOSIT: { @@ -1728,7 +1704,6 @@ interpreter_run (void *cls) return; } json_decref (wire); - trigger_context_task (); return; } case OC_REFRESH_MELT: @@ -1826,7 +1801,6 @@ interpreter_run (void *cls) } } } - trigger_context_task (); return; case OC_REFRESH_REVEAL: ref = find_command (is, @@ -1845,7 +1819,6 @@ interpreter_run (void *cls) fail (is); return; } - trigger_context_task (); return; case OC_REFRESH_LINK: /* find reveal command */ @@ -1885,13 +1858,11 @@ interpreter_run (void *cls) fail (is); return; } - trigger_context_task (); return; case OC_WIRE: cmd->details.wire.wh = TALER_EXCHANGE_wire (exchange, &wire_cb, is); - trigger_context_task (); return; case OC_WIRE_DEPOSITS: if (NULL != cmd->details.wire_deposits.wtid_ref) @@ -1906,7 +1877,6 @@ interpreter_run (void *cls) &cmd->details.wire_deposits.wtid, &wire_deposits_cb, is); - trigger_context_task (); return; case OC_DEPOSIT_WTID: { @@ -1969,7 +1939,6 @@ interpreter_run (void *cls) ref->details.deposit.transaction_id, &deposit_wtid_cb, is); - trigger_context_task (); } return; default: @@ -1985,6 +1954,19 @@ interpreter_run (void *cls) /** + * Function run when the test terminates (good or bad) with timeout. + * + * @param cls NULL + */ +static void +do_timeout (void *cls) +{ + timeout_task = NULL; + GNUNET_SCHEDULER_shutdown (); +} + + +/** * Function run when the test terminates (good or bad). * Cleans up our state. * @@ -1997,7 +1979,6 @@ do_shutdown (void *cls) struct Command *cmd; unsigned int i; - shutdown_task = NULL; for (i=0;OC_END != (cmd = &is->commands[i])->oc;i++) { switch (cmd->oc) @@ -2156,11 +2137,6 @@ do_shutdown (void *cls) is->task = NULL; } GNUNET_free (is); - if (NULL != ctx_task) - { - GNUNET_SCHEDULER_cancel (ctx_task); - ctx_task = NULL; - } if (NULL != exchange) { TALER_EXCHANGE_disconnect (exchange); @@ -2171,6 +2147,16 @@ do_shutdown (void *cls) GNUNET_CURL_fini (ctx); ctx = NULL; } + if (NULL != rc) + { + GNUNET_CURL_gnunet_rc_destroy (rc); + rc = NULL; + } + if (NULL != timeout_task) + { + GNUNET_SCHEDULER_cancel (timeout_task); + timeout_task = NULL; + } } @@ -2209,60 +2195,6 @@ cert_cb (void *cls, /** - * Task that runs the context's event loop with the GNUnet scheduler. - * - * @param cls unused - */ -static void -context_task (void *cls) -{ - long timeout; - int max_fd; - fd_set read_fd_set; - fd_set write_fd_set; - fd_set except_fd_set; - struct GNUNET_NETWORK_FDSet *rs; - struct GNUNET_NETWORK_FDSet *ws; - struct GNUNET_TIME_Relative delay; - - ctx_task = NULL; - GNUNET_CURL_perform (ctx); - max_fd = -1; - timeout = -1; - FD_ZERO (&read_fd_set); - FD_ZERO (&write_fd_set); - FD_ZERO (&except_fd_set); - GNUNET_CURL_get_select_info (ctx, - &read_fd_set, - &write_fd_set, - &except_fd_set, - &max_fd, - &timeout); - if (timeout >= 0) - delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, - timeout); - else - delay = GNUNET_TIME_UNIT_FOREVER_REL; - rs = GNUNET_NETWORK_fdset_create (); - GNUNET_NETWORK_fdset_copy_native (rs, - &read_fd_set, - max_fd + 1); - ws = GNUNET_NETWORK_fdset_create (); - GNUNET_NETWORK_fdset_copy_native (ws, - &write_fd_set, - max_fd + 1); - ctx_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - delay, - rs, - ws, - &context_task, - cls); - GNUNET_NETWORK_fdset_destroy (rs); - GNUNET_NETWORK_fdset_destroy (ws); -} - - -/** * Main function that will be run by the scheduler. * * @param cls closure @@ -2507,19 +2439,20 @@ run (void *cls) is = GNUNET_new (struct InterpreterState); is->commands = commands; - ctx = GNUNET_CURL_init (); + ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule, + &rc); + rc = GNUNET_CURL_gnunet_rc_create (ctx); GNUNET_assert (NULL != ctx); - ctx_task = GNUNET_SCHEDULER_add_now (&context_task, - ctx); exchange = TALER_EXCHANGE_connect (ctx, "http://localhost:8081", &cert_cb, is, TALER_EXCHANGE_OPTION_END); GNUNET_assert (NULL != exchange); - shutdown_task + timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 150), - &do_shutdown, is); + &do_timeout, NULL); + GNUNET_SCHEDULER_add_shutdown (&do_shutdown, is); } diff --git a/src/exchange-lib/test_exchange_api.conf b/src/exchange-lib/test_exchange_api.conf index 5fcc3655..a8c69078 100644 --- a/src/exchange-lib/test_exchange_api.conf +++ b/src/exchange-lib/test_exchange_api.conf @@ -30,12 +30,17 @@ TESTRUN = YES [exchangedb-postgres] DB_CONN_STR = "postgres:///talercheck" -[wire-incoming-test] +[exchange-wire-incoming-sepa] +# This is the response we give out for the /wire request. It provides +# wallets with the bank information for transfers to the exchange. +SEPA_RESPONSE_FILE = ${TALER_CONFIG_HOME}/sepa.json + +[exchange-wire-incoming-test] # This is the response we give out for the /wire request. It provides # wallets with the bank information for transfers to the exchange. TEST_RESPONSE_FILE = ${TALER_CONFIG_HOME}/test.json -[wire-outgoing-test] +[exchange-wire-outgoing-test] # What is the main website of the bank? BANK_URI = "http://localhost:8082/" # Into which account at the 'bank' should (incoming) wire transfers be made? |