-
Notifications
You must be signed in to change notification settings - Fork 113
Added util.py, includes source directory import and TestWrapper class. #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # Enter your source directory between the quotes here | ||
| SOURCE_DIRECTORY = '' | ||
|
|
||
| assert not SOURCE_DIRECTORY == '', 'SOURCE_DIRECTORY not configured' | ||
|
|
||
| print("Source directory configured as {}".format(SOURCE_DIRECTORY)) | ||
|
|
||
| import sys | ||
| sys.path.insert(0, SOURCE_DIRECTORY + '/test/functional') | ||
|
|
||
| ############################################################################# | ||
|
|
||
| import argparse | ||
| import os | ||
|
|
||
| from test_framework.test_framework import BitcoinTestFramework | ||
|
|
||
| # TestWrapper utility class. | ||
| class TestWrapper(BitcoinTestFramework): | ||
| """Wrapper Class for BitcoinTestFramework. | ||
|
|
||
| Provides the BitcoinTestFramework rpc & daemon process management | ||
| functionality to external python projects.""" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might note here that the value of this class instead of just using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, BitcoinTestFramework sets defaults when reading command line arguments with argparse. Since we don't do that, we have to set the defaults in TestWrapper. Only when these options are set can we run the setup() and shutdown(). |
||
|
|
||
| def set_test_params(self): | ||
| # This can be overriden in setup() parameter. | ||
| self.num_nodes=3 | ||
|
|
||
| def run_test(self): | ||
| pass | ||
|
|
||
| def setup(self, | ||
| bitcoind=os.path.abspath(SOURCE_DIRECTORY + "/src/bitcoind"), | ||
| bitcoincli=None, | ||
| setup_clean_chain=True, | ||
| num_nodes=3, | ||
| network_thread=None, | ||
| rpc_timeout=60, | ||
| supports_cli=False, | ||
| bind_to_localhost_only=True, | ||
| nocleanup=False, | ||
| noshutdown=False, | ||
| cachedir=os.path.abspath(SOURCE_DIRECTORY + "/test/cache"), | ||
| tmpdir=None, | ||
| loglevel='INFO', | ||
| trace_rpc=False, | ||
| port_seed=os.getpid(), | ||
| coveragedir=None, | ||
| configfile=os.path.abspath(SOURCE_DIRECTORY + "/test/config.ini"), | ||
| pdbonfailure=False, | ||
| usecli = False, | ||
| perf = False, | ||
| randomseed = None): | ||
|
|
||
| self.setup_clean_chain = setup_clean_chain | ||
| self.num_nodes = num_nodes | ||
| self.network_thread = network_thread | ||
| self.rpc_timeout = rpc_timeout | ||
| self.supports_cli = supports_cli | ||
| self.bind_to_localhost_only = bind_to_localhost_only | ||
|
|
||
| self.options = argparse.Namespace | ||
| self.options.nocleanup = nocleanup | ||
| self.options.noshutdown = noshutdown | ||
| self.options.cachedir = cachedir | ||
| self.options.tmpdir = tmpdir | ||
| self.options.loglevel = loglevel | ||
| self.options.trace_rpc = trace_rpc | ||
| self.options.port_seed = port_seed | ||
| self.options.coveragedir = coveragedir | ||
| self.options.configfile = configfile | ||
| self.options.pdbonfailure = pdbonfailure | ||
| self.options.usecli = usecli | ||
| self.options.perf = perf | ||
| self.options.randomseed = randomseed | ||
|
|
||
| self.options.bitcoind = bitcoind | ||
| self.options.bitcoincli = bitcoincli | ||
|
|
||
| super(TestWrapper,self).setup() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not strong on best practices for keeping user config values separate from other utility functions. Could keep as setup.py and somehow reference path from util.py, but could be awkward.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the only reason source dir path import and TestWrapper are consolidated in util.py is because I wanted to avoid to reference path from util.py, after setup.py sets source directory.