From 4e0b5104382a1271261a24c4b97cb50f63aea976 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 13 Aug 2020 00:45:02 +0200 Subject: extend tests to discover corner cases from #6478, fix code to actually work for those cases --- src/lib/exchange_api_common.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/lib/exchange_api_common.c') 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, -- cgit v1.2.3