p2p_segwit.py
is a very long test, composed of multiple subtests. When it fails it’s difficult to debug for a couple of reasons:
- Control flow jumps between different methods in the test class, so it’s a little difficult to follow the code.
- state may be carried forward unintentionally from one subtest to the next.
Improve that by wrapping the subtests with a @subtest
decorator which:
- logs progress
- asserts state after each subtest
As usual, I’ve also included a few commits which generally tidy up the test and improve style.