test: Plug memory leaks and stack-use-after-scope
Summary:
Backport of core PR12477
https://github.com/bitcoin/bitcoin/pull/12477/files
The modifications in checkqueue_tests.cpp are already part of our
codebase.
The modifications of test_bitcoin are only required to clear memory
from avalanche_tests and DoS_tests. Avalanche tests use
std::_unique_ptr, making this fix useless, and so does DoS tests
since D2919.
Depends on D2919
Test Plan:
./src/bench/bitcoin-bench
Reviewers: #bitcoin_abc, deadalnix, jasonbcox
Reviewed By: #bitcoin_abc, deadalnix, jasonbcox
Subscribers: jasonbcox
Differential Revision: https://reviews.bitcoinabc.org/D2918