diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-08-13 00:45:02 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-08-13 00:45:02 +0200 |
commit | 4e0b5104382a1271261a24c4b97cb50f63aea976 (patch) | |
tree | 1277741e531ce9df2677e0faae2be395af7b5494 /src/lib/exchange_api_common.c | |
parent | 6256bdb15a7c43b644132ae8c78adf31bcae4d28 (diff) | |
download | exchange-4e0b5104382a1271261a24c4b97cb50f63aea976.tar.xz |
extend tests to discover corner cases from #6478, fix code to actually work for those cases
Diffstat (limited to 'src/lib/exchange_api_common.c')
-rw-r--r-- | src/lib/exchange_api_common.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index b07ac1112..3591a7bbc 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -643,6 +643,7 @@ TALER_EXCHANGE_verify_coin_history ( { struct TALER_MerchantSignatureP sig; struct TALER_Amount refund_fee; + struct TALER_Amount sig_amount; struct TALER_RefundRequestPS rr = { .purpose.size = htonl (sizeof (rr)), .purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND), @@ -658,7 +659,7 @@ TALER_EXCHANGE_verify_coin_history ( GNUNET_JSON_spec_fixed_auto ("merchant_pub", &rr.merchant), GNUNET_JSON_spec_uint64 ("rtransaction_id", - &rr.rtransaction_id), // FIXME: shouldn't this be NBO!? + &rr.rtransaction_id), GNUNET_JSON_spec_end () }; @@ -670,9 +671,19 @@ TALER_EXCHANGE_verify_coin_history ( GNUNET_break_op (0); return GNUNET_SYSERR; } - abort (); // FIXME: this shows the case is not tested! ... + if (0 > + TALER_amount_add (&sig_amount, + &refund_fee, + &amount)) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } TALER_amount_hton (&rr.refund_amount, - &amount); + &sig_amount); + rr.rtransaction_id = GNUNET_htonll (rr.rtransaction_id); + TALER_amount_hton (&rr.refund_amount, + &sig_amount); if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND, &rr, |