Review report

core: PR #36712

1 suggestion

Optional improvements

Link

[suggestion] · The new += assertion passes even if the empty rate is never updated

The new unit-test assertion would still pass if += left empty_rate unchanged, because cross-product equality makes an empty rate compare equal to the expected nonzero rate.

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

Details and suggested fix

empty_rate starts as {0,0}. Since CFeeRate::operator== delegates to ByRatio, leaving it unchanged would make the assertion evaluate 0*1 == 1*0 and pass. The test catches the original division by zero, but it would also accept a fix that skips addition when the left operand is empty. BinaryOperatorTest only adds to a nonempty rate, so it would not catch that case either. The current implementation correctly produces {1000,1000}. Replace the equality assertion with BOOST_CHECK_EQUAL(empty_rate.GetFeePerK(), CAmount{1000}); to distinguish that result from an unchanged empty rate, which returns 0.


Coverage details