summaryrefslogtreecommitdiff
path: root/src/auditor/taler-auditor.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-01-15 15:17:02 +0100
committerFlorian Dold <florian.dold@gmail.com>2020-01-15 15:17:25 +0100
commitda5b3ba8aeb9d47e4f99cd22847c9b539ff8ee2b (patch)
tree6e67e1d08fd941144f464dfe55b8835db65687e6 /src/auditor/taler-auditor.c
parentb37fff0d5b08926169633ce8822de7ac616ae169 (diff)
downloadexchange-da5b3ba8aeb9d47e4f99cd22847c9b539ff8ee2b.tar.gz
exchange-da5b3ba8aeb9d47e4f99cd22847c9b539ff8ee2b.tar.bz2
exchange-da5b3ba8aeb9d47e4f99cd22847c9b539ff8ee2b.zip
round amounts based on config, do unit test for rounding
Diffstat (limited to 'src/auditor/taler-auditor.c')
-rw-r--r--src/auditor/taler-auditor.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c
index d4fb84d16..d2bc34046 100644
--- a/src/auditor/taler-auditor.c
+++ b/src/auditor/taler-auditor.c
@@ -86,6 +86,11 @@ static struct TALER_EXCHANGEDB_Plugin *edb;
static char *currency;
/**
+ * How many fractional digits does the currency use?
+ */
+static uint8_t currency_rounding_fractional_digits;
+
+/**
* Our configuration.
*/
static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -2895,7 +2900,8 @@ check_wire_out_cb
}
/* Round down to amount supported by wire method */
- GNUNET_break (TALER_amount_round (&final_amount));
+ GNUNET_break (TALER_amount_round_down (&final_amount,
+ currency_rounding_fractional_digits));
/* Calculate the exchange's gain as the fees plus rounding differences! */
if (GNUNET_OK !=
@@ -5204,6 +5210,30 @@ run (void *cls,
global_ret = 1;
return;
}
+ {
+ unsigned long long num;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ "taler",
+ "CURRENCY_ROUNDING_FRACTIONAL_DIGITS",
+ &num))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "No [taler]/CURRENCY_ROUNDING_FRACTIONAL_DIGITS specified, defaulting to 2 digits.\n");
+ currency_rounding_fractional_digits = 2;
+ }
+ else if (num > TALER_AMOUNT_FRAC_LEN)
+ {
+ global_ret = 1;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Value of CURRENCY_ROUNDING_FRACTIONAL_DIGITS too big.\n");
+ return;
+ }
+ else
+ {
+ currency_rounding_fractional_digits = (uint8_t) num;
+ }
+ }
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (cfg,
"exchangedb",