Refactor TestFramework main() into setup/shutdown
Summary:
Setup and shutdown code now moved into dedicated methods. Test "success" is added as a BitcoinTestFramework member, which can be accessed outside of main.
Argument parsing also moved into separate method and called from main.
In our codebase, set_test_params() is called in main() rather than in __init__ because we want parser options to be available during test setup (D1974).
This is a backport of Core PR17288 [2/7]
https://github.com/bitcoin/bitcoin/pull/17288/commits/6b71241291a184c9ee197bf5f0c7e1414417a0a0
Depends on D8241
Test Plan: ninja && ninja check-functional
Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien
Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D8242