From b7be0a1fedfeec26e4b7d35357157d5a9209f3ee Mon Sep 17 00:00:00 2001 From: Max Nikulin Date: Tue, 6 Aug 2024 16:10:12 +0700 Subject: Fix copy on write for amount_t::in_place_roundto - Copy amount quantity before rounding. - Fix `amount_t::roundto(int)`. - Transform `balance/testRound` into `balance/testRoundto`. It was a mix of `round` and `roundto` operation with unclear purpose and was relying on `in_place_roundto` behavior modifying all copies. There is no unit tests for balance `round` and `unround` any more. Closes #2362 --- src/amount.cc | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/amount.cc') diff --git a/src/amount.cc b/src/amount.cc index 604519df..da8cd6fc 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -685,14 +685,7 @@ void amount_t::in_place_roundto(int places) if (! quantity) throw_(amount_error, _("Cannot round an uninitialized amount")); - // - // _dup() call (see in_place_ceiling and in_place_floor) - // leads to 2 failures in the balance/testRound test, - // however in its absence this method affects copies of amount_t instances. - // Remove expected_failures from amount/testRound - // and update balance/testRound - // when uncommenting the following line. - // _dup(); + _dup(); mpz_t& scale(temp); if (places) -- cgit v1.2.3