Review report

bitcoin/bitcoin: PR #36712

1 suggestion

Optional improvements

Link

[suggestion] · The += regression assertion also accepts an unchanged empty rate

The new test checks that addition does not crash, but its equality assertion also passes if empty_rate remains {0,0}, so it does not verify the result.

Location: src/test/amount_tests.cpp:101 (head).

Details and suggested fix

empty_rate starts as {0,0}, and CFeeRate::operator== uses ByRatio cross-multiplication. Comparing that empty value with {1,1} gives two zero products. An early return from operator+= for an empty left operand would therefore satisfy this assertion without performing the addition; BinaryOperatorTest only exercises nonempty operands. The current production implementation correctly produces {1000,1000}. Replace this assertion with BOOST_CHECK_EQUAL(empty_rate.GetFeePerK(), CAmount{1000}); to verify the result while retaining crash coverage. An unchanged empty rate returns 0 through the new guard. Keep the existing equality semantics rather than changing them to strengthen this test.


Coverage details