Move the class `HasReason` from `miner_tests.cpp` to `setup_common.h` so that it can be reused by other tests.
Partial backport (2/4) of core PR19485:
https://github.com/bitcoin/bitcoin/pull/19845/commits/fe42411b4b07b99c591855f5f00ad45dfeec8e30
Depends on D9186.