Skip to content

Commit 9951628

Browse files
committed
tests: Use legacy change type in subtract fee from outputs test
The subtract fee from outputs assumes that the leftover input amount will be dropped to fees. However this only happens if that amount is less than the cost of change. In the event that it is higher than the cost of change, the leftover amount will actually become a change output. To avoid this scenario, force a change type which has a high cost of change.
1 parent dcd6eeb commit 9951628

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/wallet/test/spend_tests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ BOOST_FIXTURE_TEST_CASE(SubtractFee, TestChain100Setup)
3333
CCoinControl coin_control;
3434
coin_control.m_feerate.emplace(10000);
3535
coin_control.fOverrideFeeRate = true;
36+
// We need to use a change type with high cost of change so that the leftover amount will be dropped to fee instead of added as a change output
37+
coin_control.m_change_type = OutputType::LEGACY;
3638
FeeCalculation fee_calc;
3739
BOOST_CHECK(CreateTransaction(*wallet, {recipient}, tx, fee, change_pos, error, coin_control, fee_calc));
3840
BOOST_CHECK_EQUAL(tx->vout.size(), 1);

0 commit comments

Comments
 (0)