tests: Add missing locks to tests
Summary:
Add missing locks to tests to satisfy lock requirements (such as
EXCLUSIVE_LOCKS_REQUIRED(...) (Clang Thread Safety Analysis),
AssertLockHeld(...) and implicit lock assumptions).
This doesn't clear all the thread sanitizer issues, so running with the
tsan enabled still output a lot of errors.
Backport of core PR11623
Completes T543
Test Plan:
make check
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Subscribers: teamcity, schancel
Differential Revision: https://reviews.bitcoinabc.org/D2617