Add TestShell class
Summary:
A BitcoinTestFramework child class which can be imported by an external user or
project. TestShell.setup() initiates an underlying BitcoinTestFramework object
with bitcoind subprocesses, rpc interfaces and test logging.
TestShell.shutdown() safely tears down the BitcoinTestFramework object.
This is a backport of Core PR17288 [6/7]
https://github.com/bitcoin/bitcoin/pull/17288/commits/f5112369cf91451d2d0bf574a9bfdaea04696939
Depends on D8245
Test Plan:
$ python3 >>> import sys >>> sys.path.insert(0, "/home/pierre/dev/bitcoin-abc/test/functional") >>> from test_framework.test_shell import TestShell >>> test = TestShell() >>> test.setup(num_nodes=2, configfile="/home/pierre/dev/bitcoin-abc/build/test/config.ini") 2020-11-03T09:36:41.939000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_cu4wq1lu >>> test.nodes[0].generate(2) ['1239cf08ec1a14d8fd058a6ce7d01bfca7b72ba2cafe98a2d792b545d3b47031', '20b4a2dad83310cad98f1db91000267bb33e8d927a59ade6f371200de55ae216'] >>> test.nodes[0].getblockchaininfo() {'chain': 'regtest', 'blocks': 202, 'headers': 202, 'bestblockhash': '20b4a2dad83310cad98f1db91000267bb33e8d927a59ade6f371200de55ae216', 'difficulty': Decimal('4.656542373906925E-10'), 'mediantime': 1296688637, 'verificationprogress': 1, 'initialblockdownload': False, 'chainwork': '0000000000000000000000000000000000000000000000000000000000000196', 'size_on_disk': 46753, 'pruned': False, 'softforks': {'testdummy': {'type': 'bip9', 'bip9': {'status': 'started', 'bit': 28, 'start_time': 0, 'timeout': 9223372036854775807, 'since': 144, 'statistics': {'period': 144, 'threshold': 108, 'elapsed': 59, 'count': 59, 'possible': True}}, 'active': False}}, 'warnings': 'This is a pre-release test build - use at your own risk - do not use for mining or merchant applications'} >>> test.shutdown() 2020-11-03T09:37:44.840000Z TestFramework (INFO): Stopping nodes 2020-11-03T09:37:45.097000Z TestFramework (INFO): Cleaning up /tmp/bitcoin_func_test_cu4wq1lu on exit 2020-11-03T09:37:45.097000Z TestFramework (INFO): Tests successful
Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien
Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D8246