diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-07-05 16:55:01 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-07-05 16:55:01 +0200 |
commit | 922323b4104abfaef2a11fed4e5e8292344a3bcd (patch) | |
tree | 8ed3781141741e743d120180b7e785f6a38eca3c /src/mint-lib | |
parent | f623214c1292b93fa8672361dfa978a506f4bef3 (diff) | |
download | exchange-922323b4104abfaef2a11fed4e5e8292344a3bcd.tar.xz |
misc bugfixes from tests
Diffstat (limited to 'src/mint-lib')
-rw-r--r-- | src/mint-lib/mint_api_admin.c | 4 | ||||
-rw-r--r-- | src/mint-lib/mint_api_deposit.c | 20 | ||||
-rw-r--r-- | src/mint-lib/test-mint-home/config/mint-common.conf | 5 | ||||
-rw-r--r-- | src/mint-lib/test_mint_api.c | 50 |
4 files changed, 60 insertions, 19 deletions
diff --git a/src/mint-lib/mint_api_admin.c b/src/mint-lib/mint_api_admin.c index 0169f8e7d..47158665a 100644 --- a/src/mint-lib/mint_api_admin.c +++ b/src/mint-lib/mint_api_admin.c @@ -246,7 +246,7 @@ struct TALER_MINT_AdminAddIncomingHandle * TALER_MINT_admin_add_incoming (struct TALER_MINT_Handle *mint, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *amount, - const struct GNUNET_TIME_Absolute execution_date, + struct GNUNET_TIME_Absolute execution_date, const json_t *wire, TALER_MINT_AdminAddIncomingResultCallback res_cb, void *res_cb_cls) @@ -256,6 +256,8 @@ TALER_MINT_admin_add_incoming (struct TALER_MINT_Handle *mint, json_t *admin_obj; CURL *eh; + GNUNET_assert (GNUNET_OK == + TALER_round_abs_time (&execution_date)); if (GNUNET_YES != MAH_handle_is_ready (mint)) { diff --git a/src/mint-lib/mint_api_deposit.c b/src/mint-lib/mint_api_deposit.c index 3c6939668..008634f20 100644 --- a/src/mint-lib/mint_api_deposit.c +++ b/src/mint-lib/mint_api_deposit.c @@ -37,7 +37,7 @@ */ #define JSON_WARN(error) \ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \ - "JSON parsing failed at %s:%u: %s (%s)", \ + "JSON parsing failed at %s:%u: %s (%s)\n", \ __FILE__, __LINE__, error.text, error.source) @@ -464,8 +464,8 @@ verify_signatures (const struct TALER_MINT_DenomPublicKey *dki, TALER_LOG_WARNING ("Invalid coin passed for /deposit\n"); return GNUNET_SYSERR; } - if (TALER_amount_cmp (&dki->fee_deposit, - amount) < 0) + if (0 < TALER_amount_cmp (&dki->fee_deposit, + amount)) { TALER_LOG_WARNING ("Deposit amount smaller than fee\n"); return GNUNET_SYSERR; @@ -615,17 +615,17 @@ TALER_MINT_deposit (struct TALER_MINT_Handle *mint, } deposit_obj = json_pack ("{s:o, s:o," /* f/wire */ - " s:s, s:s," /* H_wire, H_contract */ - " s:s, s:s," /* coin_pub, denom_pub */ - " s:s, s:s," /* ub_sig, timestamp */ - " s:I, s:s," /* transaction id, merchant_pub */ - " s:s, s:s}", /* refund_deadline, coin_sig */ + " s:o, s:o," /* H_wire, H_contract */ + " s:o, s:o," /* coin_pub, denom_pub */ + " s:o, s:o," /* ub_sig, timestamp */ + " s:I, s:o," /* transaction id, merchant_pub */ + " s:o, s:o}", /* refund_deadline, coin_sig */ "f", TALER_json_from_amount (amount), "wire", wire_details, "H_wire", TALER_json_from_data (&h_wire, sizeof (h_wire)), - "H_contract", TALER_json_from_data (&h_contract, - sizeof (h_contract)), + "H_contract", TALER_json_from_data (h_contract, + sizeof (struct GNUNET_HashCode)), "coin_pub", TALER_json_from_data (coin_pub, sizeof (*coin_pub)), "denom_pub", TALER_json_from_rsa_public_key (denom_pub->rsa_public_key), diff --git a/src/mint-lib/test-mint-home/config/mint-common.conf b/src/mint-lib/test-mint-home/config/mint-common.conf index 6d03c2a5b..1b8aa4218 100644 --- a/src/mint-lib/test-mint-home/config/mint-common.conf +++ b/src/mint-lib/test-mint-home/config/mint-common.conf @@ -2,8 +2,9 @@ # Currency supported by the mint (can only be one) CURRENCY = EUR -# Wire format supproted by the mint (currently only SEPA is implemented) -WIREFORMAT = SEPA +# Wire format supproted by the mint +# TEST is used for testing... (what a shock) +WIREFORMAT = TEST # HTTP port the mint listens to PORT = 8081 diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c index c59d4a03b..58f502bae 100644 --- a/src/mint-lib/test_mint_api.c +++ b/src/mint-lib/test_mint_api.c @@ -27,6 +27,7 @@ */ #include "platform.h" #include "taler_util.h" +#include "taler_signatures.h" #include "taler_mint_service.h" #include <microhttpd.h> @@ -506,6 +507,7 @@ interpreter_run (void *cls, struct TALER_ReservePublicKeyP reserve_pub; struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_Amount amount; + struct GNUNET_TIME_Absolute execution_date; json_t *wire; is->task = NULL; @@ -566,14 +568,22 @@ interpreter_run (void *cls, fail (is); return; } + execution_date = GNUNET_TIME_absolute_get (); + TALER_round_abs_time (&execution_date); cmd->details.admin_add_incoming.aih = TALER_MINT_admin_add_incoming (mint, &reserve_pub, &amount, - GNUNET_TIME_absolute_get (), + execution_date, wire, &add_incoming_cb, is); + if (NULL == cmd->details.admin_add_incoming.aih) + { + GNUNET_break (0); + fail (is); + return; + } trigger_context_task (); return; case OC_WITHDRAW_SIGN: @@ -629,6 +639,12 @@ interpreter_run (void *cls, &cmd->details.withdraw_sign.blinding_key, &withdraw_sign_cb, is); + if (NULL == cmd->details.withdraw_sign.wsh) + { + GNUNET_break (0); + fail (is); + return; + } trigger_context_task (); return; case OC_DEPOSIT: @@ -690,9 +706,30 @@ interpreter_run (void *cls, refund_deadline = GNUNET_TIME_UNIT_ZERO_ABS; } timestamp = GNUNET_TIME_absolute_get (); + TALER_round_abs_time (×tamp); + { + struct TALER_DepositRequestPS dr; + + dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS)); + dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT); + dr.h_contract = h_contract; + TALER_hash_json (wire, + &dr.h_wire); + dr.timestamp = GNUNET_TIME_absolute_hton (timestamp); + dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline); + dr.transaction_id = GNUNET_htonll (cmd->details.deposit.transaction_id); + TALER_amount_hton (&dr.amount_with_fee, + &amount); + TALER_amount_hton (&dr.deposit_fee, + &ref->details.withdraw_sign.pk->fee_deposit); + dr.merchant = merchant_pub; + dr.coin_pub = coin_pub; + GNUNET_assert (GNUNET_OK == + GNUNET_CRYPTO_eddsa_sign (&ref->details.withdraw_sign.coin_priv.eddsa_priv, + &dr.purpose, + &coin_sig.eddsa_signature)); - /* FIXME: init "coin_sig" here! */ - + } cmd->details.deposit.dh = TALER_MINT_deposit (mint, &amount, @@ -715,6 +752,7 @@ interpreter_run (void *cls, fail (is); return; } + trigger_context_task (); return; } default: @@ -938,7 +976,7 @@ run (void *cls, /* Fill reserve with EUR:5.01, as withdraw fee is 1 ct per config */ { .oc = OC_ADMIN_ADD_INCOMING, .label = "create-reserve-1", - .details.admin_add_incoming.wire = "{ \"bank\":\"source bank\", \"account\":42 }", + .details.admin_add_incoming.wire = "{ \"type\":\"TEST\", \"bank\":\"source bank\", \"account\":42 }", .details.admin_add_incoming.amount = "EUR:5.01" }, { .oc = OC_WITHDRAW_SIGN, .label = "withdraw-coin-1", @@ -948,7 +986,7 @@ run (void *cls, .label = "deposit-simple", .details.deposit.amount = "EUR:5", .details.deposit.coin_ref = "withdraw-coin-1", - .details.deposit.wire_details = "{ \"bank\":\"dest bank\", \"account\":42 }", + .details.deposit.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account\":42 }", .details.deposit.contract = "{ \"items\"={ \"name\":\"ice cream\", \"value\":1 } }", .details.deposit.transaction_id = 1 }, { .oc = OC_END } @@ -1007,7 +1045,7 @@ main (int argc, "-d", "test-mint-home", NULL); /* give child time to start and bind against the socket */ - sleep (1); + sleep (5); result = GNUNET_SYSERR; GNUNET_SCHEDULER_run (&run, NULL); GNUNET_OS_process_kill (mintd, |