[test] Throw error instead of segfaulting in failure scenario
Summary:
If the miner code is faulty and does not include any transactions in a block,
the code segfaults when it tries to access block transactions. Instead, add a
check that safely aborts the process.
This is a backport of core#21121 [2/4]
https://github.com/bitcoin/bitcoin/pull/21121/commits/a2d908e1daa1d1be74568bd7d1d04b724da7d79c
Test Plan: ninja check
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D12107