test: cover negative output after positive in CheckTransaction

bitcoin/bitcoin: PR #36931

1 suggestion

Optional improvements

Link

[suggestion] · Coinbase-shaped fixture leaves the rejection assertion passing under the mutant

The reject-reason assertion already kills mutant 4675, but the fixture's empty coinbase scriptSig means the rejection assertion would still pass after the negative-output check regresses.

Location: src/test/transaction_tests.cpp:382 (head).

Details and suggested fix

tx.vin.resize(1) creates a single input with a null prevout, making the transaction coinbase-shaped. Under mutant 4675, the output totals would be 1 and then 0, so the output checks would pass before the empty scriptSig causes rejection with bad-cb-length. Replace tx.vin.resize(1) with tx.vin.emplace_back(COutPoint{Txid{}, 0}); to isolate the negative-output condition. That input passes the remaining CheckTransaction checks, so the mutant would return true and fail the rejection assertion directly. Keep the reject-reason assertion; the unmutated code would still reject the second output with bad-txns-vout-negative.


Coverage details