aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/test_node.py
AgeCommit message (Collapse)Author
2018-06-25qa: Avoid start/stop of the network thread mid-testMarcoFalke
2018-05-09[qa] Avoid printing to console during cache creationSuhas Daftuar
2018-05-09[tests] Allow stderr to be tested against specified stringJohn Newbery
Allow bitcoind's stderr to be tested against a specified string on shutdown.
2018-05-09[Tests] Use LIBC_FATAL_STDERR_=1 in testsJohn Newbery
By default, libc will print fatal errors to /dev/tty instead of stderr. Adding the LIBC_FATAL_STDERR_ to the environment variables allows us to catch libc errors in stderr and test for them.
2018-05-09[Tests] Write stdout/stderr to datadir instead of temp file.John Newbery
2018-04-25Merge #13051: qa: Normalize executable locationWladimir J. van der Laan
fa811b0 qa: Normalize executable location (MarcoFalke) Pull request description: This removes the need to override the executable locations by just reading them from the config file. Beside making the code easier to read, running individual test on Windows is now possible by default (without providing further command line arguments). Note: Of course, it is still possible to manually specify the location through the `BITCOIND` environment variable, e.g. `bitcoin-qt`. Tree-SHA512: bee6d22246796242d747120ca18aaab089f73067de213c9111182561985c5912228a0b0f7f9eec025ecfdb44db031f15652f30d67c489d481c995bb3232a7ac7
2018-04-21qa: Normalize executable locationMarcoFalke
2018-04-19[qa] Attach node index to test_node AssertionError and print messagesJames O'Beirne
to aid debugging. Feedback incorporated from @Empact.
2018-04-17Print to console by default when not run with -daemonEvan Klitzke
Printing to the debug log file can be disabled with -nodebulogfile
2018-04-09Merge #12902: [qa] Handle potential cookie race when starting nodeMarcoFalke
75d0e4c544 [qa] Delete cookie file before starting node (Suhas Daftuar) Pull request description: When a node is restarted during a test after an unclean shutdown (such as with -dbcrashratio), it's possible an old cookie file was left behind. This can cause a race condition when restarting the node, where the test framework might try to connect using credentials from the old cookie file, just as the node will generate new credentials and overwrite the old file. Delete any such cookie file if present prior to startup. Tree-SHA512: ae1e8bf8fd20e07c32b0715025693bb28b0e3dd34f328cae4346abf579b0c97b5db1c02782e1c46b7a3b6058d268b6d46b668e847658a6eed0be857ffb0d65dc
2018-04-09[qa] Delete cookie file before starting nodeSuhas Daftuar
If a cookie file exists in a datadir prior to node startup, it must have been leftover from a prior unclean shutdown. As bitcoind will overwrite it anyway, delete it before starting up to prevent the test framework from inadvertently trying to connect using stale credentials.
2018-04-08Merge #12904: [qa] Ensure bitcoind processes are cleaned up when tests endWladimir J. van der Laan
e36a0c0 [qa] Ensure bitcoind processes are cleaned up when tests end (Suhas Daftuar) Pull request description: When tests fail (such as due to a bug in the test, race condition, etc), it's possible that we could follow code paths that bypass our normal node shutdown that occurs in `TestNode.stop_node`. Add a destructor to `TestNode` that cleans this up. Tree-SHA512: 72e04bc21462ebd0cb346fd1fe0540da454acfbad41923a0b06ea2317e9045b68e58f9adb02d8200891aca89a9d03a022eb72282aeb31a3b3afe7c6843a4b450
2018-04-08[qa] Ensure bitcoind processes are cleaned up when tests endSuhas Daftuar
2018-04-01qa: Match full plain text by defaultMarcoFalke
2018-03-28[Tests] fix a typo in TestNode.assert_start_raises_init_error()Roman Zeyde
Also, use specific exception for testing TestNode initialization failure.
2018-03-22Merge #12076: qa: Use node.datadir instead of tmpdir in test frameworkWladimir J. van der Laan
c8330d4 qa: Use node.datadir instead of tmpdir in test framework (MarcoFalke) Pull request description: Commit c53c9831eedaf3b311bb942945268830f9ba3abc introduced the utility function `get_datadir_path`, however not all places in the code use this util function. Using the util function everywhere makes it easier to review pull requests related to the datadir. This commit replaces datadir path creation with the `datadir` member of `TestNode`, which itself uses `get_datadir_path`. Tree-SHA512: c75707ab7149d732a6d56152a5813138a33459d3d07577b60b89f2a207c83b7663fac5f203593677c9892d1c23a5eba4bd45c5c4ababf040d720b437240fcddf
2018-03-22Merge #12718: [Tests] Require exact match in assert_start_raises_init_eror ↵Wladimir J. van der Laan
(jnewbery) fae1374 qa: Allow for partial_match when checking init error (MarcoFalke) 5812273 [Tests] Require exact match in assert_start_raises_init_eror() (John Newbery) 0ec08a6 [Tests] Move assert_start_raises_init_error method to TestNode (John Newbery) Pull request description: Extracted from #12379, because the changes are important on their own. This allows for exact testing, since the match can be specified with a strict regex. Internal details (such as exact formatting of the error message) can still be fuzzed away by regex wildcards. Tree-SHA512: 605d2c9c42362a32d42321b066637577a026d0bb8cfc1c9f5737a4ca6503ffe85457a5122cea6e1101053ccc6c8aa1bbae3602e1fa7d2988bf7d5c275f412f66
2018-03-21Fix typosDimitris Apostolou
2018-03-19qa: Allow for partial_match when checking init errorMarcoFalke
This allows the tests to pass on different platforms
2018-03-19qa: Use node.datadir instead of tmpdir in test frameworkMarcoFalke
2018-03-18[Tests] Require exact match in assert_start_raises_init_eror()John Newbery
2018-03-18[Tests] Move assert_start_raises_init_error method to TestNodeJohn Newbery
2018-03-06[tests] bind functional test nodes to 127.0.0.1Sjors Provoost
Prevents OSX firewall allow-this-application-to-accept-inbound-connections permission popups and is generally safer. To prevent binding to 127.0.0.1, set self.bind_to_localhost_only = False.
2018-02-15qa: Move common args to bitcoin.confMarcoFalke
2018-01-24Merge #12089: qa: Make TestNodeCLI command optional in send_cliMarcoFalke
fae7b14a04 qa: Make TestNodeCLI command optional in send_cli (MarcoFalke) ffffb10a9f qa: Rename cli.args to cli.options (MarcoFalke) Pull request description: Makes the `command` optional, since there are valid bitcoin-cli calls that have no `command`: * `bitcoin-cli -?` * `bitcoin-cli -getinfo` * ... Also, rename self.args to self.options, since that is the name in the `bitcoin-cli -help` documentation. Tree-SHA512: f49c06024e78423301d70782946d47c0fb97a26876afba0a1f71ed329f5d7124aee4c2df520c7af74079bf9937851902f7be9c54abecc28dc29274584804d46c
2018-01-23qa: Make TestNodeCLI command optional in send_cliMarcoFalke
2018-01-23qa: Rename cli.args to cli.optionsMarcoFalke
That is the name in bitcoin-cli -help
2018-01-18Don't allow relative -walletdir pathsRussell Yanofsky
Also warn if bitcoind is configured to use a relative -datadir path. Specifying paths relative to the current working directory in a daemon process can be dangerous, because files can fail to be located even if the configuration doesn't change, but the daemon is started up differently. Specifying a relative -datadir now adds a warning to the debug log. It would not be backwards-compatible to forbid relative -datadir paths entirely, and it could also be also inconvenient for command line testing. Specifying a relative -walletdir now results in a startup error. But since the -walletdir option is new in 0.16.0, there should be no compatibility issues. Another reason not to use working directory paths for -walletdir specifically is that the default -walletdir is a "wallets" subdirectory inside the datadir, so it could be surprising that setting -walletdir manually would choose a directory rooted in a completely different location.
2018-01-08[tests] allow tests to be run with --usecliJohn Newbery
test_framework accepts a new --usecli parameter. Running the test with this parameter will cause all RPCs to be sent through bitcoin-cli rather than directly over http. By default, individual test cases do not support --usecli, and self.supports_cli must be set to True in the set_test_params method. We can make supports_cli default to True in future once we know which tests will fail with use_cli.
2018-01-08TestNodeCLI batch emulationRussell Yanofsky
Support same get_request and batch methods as AuthServiceProxy
2018-01-08Prevent TestNodeCLI.args mixupsRussell Yanofsky
Change TestNodeCLI.__call__() to return a new instance instead of modifying the existing instance. This way, it's possible to create different cli objects that have their own options (for example -rpcwallet options to connect to different wallets), and options set for a single call (`node.cli(options).method(args)`) will no longer leak into future calls.
2018-01-08Improve TestNodeCLI output parsingRussell Yanofsky
Parse JSONRPCException errors, and avoid JSON decode exception if RPC method returns a plain string.
2017-11-28[tests] Make NodeConnCB a subclass of NodeConnJohn Newbery
This makes NodeConnCB a subclass of NodeConn, and removes the need for the client code to know anything about the implementation details of NodeConnCB. NodeConn can now be swapped out for any other implementation of a low-level connection without changing client code.
2017-11-14Merge #11677: qa: Remove unused NodeConn membersMarcoFalke
fafdad0d4 qa: Remove unused NodeConn members (MarcoFalke) Pull request description: * `ver_send` and `ver_recv` were completely unused * `rpc` was only used once, in p2p-segwit. Imo better only pass it to the constructor in that single test Tree-SHA512: 7f85554d6d0fd2096516ca3c608811d5370da66cde35d8031bdc921607a7a4efdb26355896012f75f713f8df09e28d46ba46be69fd96a5898fabb1a25cbcb8ad
2017-11-13qa: Remove unused NodeConn membersMarcoFalke
2017-11-13qa: Only allow disconnecting all NodeConnsMarcoFalke
2017-11-08[tests] Add p2p connection to TestNodeJohn Newbery
p2p connections can now be added to TestNode instances. This commit also updates the example test to use the new p2p interface in TestNode to demonstrate usage. A future commit will update the existing tests to use p2p through the TestNode.
2017-11-08[tests] fix TestNode.__getattr__() methodJohn Newbery
2017-09-07[test] Replace check_output with low level versionJoão Barbosa
2017-09-07[test] Add support for custom arguments to TestNodeCLIJoão Barbosa
2017-09-06[qa] TestNode: Add wait_until_stopped helper methodMarcoFalke
2017-09-01Merge #11121: TestNode tidyupsMarcoFalke
7148b74dc [tests] Functional tests must explicitly set num_nodes (John Newbery) 5448a1471 [tests] don't override __init__() in individual tests (John Newbery) 6cf094a02 [tests] Avoid passing around member variables in test_framework (John Newbery) 36b626867 [tests] TestNode: separate add_node from start_node (John Newbery) be2a2ab6a [tests] fix - use rpc_timeout as rpc timeout (John Newbery) Pull request description: Some additional tidyups after the introduction of TestNode: - commit 1 makes TestNode use the correct rpc timeout. This should have been included in #11077 - commit 2 separates `add_node()` from `start_node()` as originally discussed here: https://github.com/bitcoin/bitcoin/pull/10556#discussion_r121161453 with @kallewoof . The test writer no longer needs to assign to `self.nodes` when starting/stopping nodes. - commit 3 adds a `set_test_params()` method, so individual tests don't need to override `__init__()` and call `super().__init__()` Tree-SHA512: 0adb030623b96675b5c29e2890ce99ccd837ed05f721d0c91b35378c5ac01b6658174aac12f1f77402e1d38b61f39b3c43b4df85c96952565dde1cda05b0db84
2017-09-01[tests] TestNode: separate add_node from start_nodeJohn Newbery
Separates the act of creating a TestNode object from starting the node. The test_framework now keeps track of its list of TestNodes, and test writers can call start_node() and stop_node() without having to update the self.nodes list.
2017-09-01[tests] fix - use rpc_timeout as rpc timeoutJohn Newbery
2017-08-24Merge #10798: [tests] [utils] test bitcoin-cliMarcoFalke
c6ec4358a [tests] Add bitcoin_cli.py test script (John Newbery) b23549f6e [tests] add TestNodeCLI class for calling bitcoin-cli for a node (John Newbery) Pull request description: We don't test bitcoin-cli at all. That means that we can miss inconsistencies between the bitcoin-cli client and the RPC interface, such as #10698 and #10747. It also means that the various bitcoin-cli options and features are untested and regressions could be silently introduced. Let's fix that. This PR adds bitcoin-cli testing in the python functional test_framework: 1. Add a bitcoin_cli.py test script that tests bitcoin-cli. At the moment it only tests that the result of `getinfo` is the same if you run it as an RPC or through bitcoin-cli, but can easily be extended to test additional bitcoin-cli features **EDIT: `--usecli` option is moved to a separate PR. This PR now only covers the bitcoin_cli.py test.** 2. ~Add a `--usecli` option to the test framework. This changes the test to use bitcoin-cli for all RPC calls instead of using direct HTTP requests. This is somewhat experimental. It works for most tests, but there are some cases where it can't work transparently because:~ - ~the testcase is asserting on a specific error code, and bitcoin-cli returns a different error code from the direct RPC~ - ~we're sending a very large RPC request (eg `submitblock`) and it can't be serialized into a shell bitcoin-cli call.~ ~I think that even though `--usecli` doesn't work on all tests, it's still a useful experimental feature. Future potential enhancements:~ - ~enhance the framework to automatically skip tests that are known to fail with bitcoin-cli if the `--usecli` option is used.~ - ~run a subset of tests in Travis with `-usecli`~ This builds on and requires the `TestNode` PR #10711 . As an aside, this is a good demonstration of how tidy it is to add additional features/interfaces now that test node logic/state is encapsulated in a TestNode class. Addresses #10791 Tree-SHA512: a1e6be12e8e007f6f67b3d3bbcd142d835787300831eb38e6027a1ad25ca9d79c4bc99a41b19e31ee95205cba1b3b2d21a688b5909316aad70bfc2b4eb6d8a52
2017-08-23[tests] fix timeout issues from TestNodeJohn Newbery
Fixes a couple of bugs from the introduction of TestNode: - test scripts were no longer able to specify a custom timeout for starting a node. Therefore tests with nodes that take a long time to start up (eg pruning.py) would fail. - the test for whether a node has failed on start up was broken by changing 'assert x is None' to 'assert not x'. Since subprocess.poll() can return None (indicating the node is still running) or 0 (indicating the node exited with return code 0), this was a regression.
2017-08-20test: Increase initial RPC timeout to 60 secondsWladimir J. van der Laan
When running the tests locally with a parallelism of 4 on an otherwise busy system, RPC can take quite a wait to come up. Change the timeout to 60 seconds just to be safe.
2017-08-15[tests] add TestNodeCLI class for calling bitcoin-cli for a nodeJohn Newbery
2017-08-15[tests] Introduce TestNodeJohn Newbery
TestNode is a class responsible for all state related to a bitcoind node under test. It stores local state, is responsible for tracking the bitcoind process and delegates unrecognised messages to the RPC connection. This commit changes start_nodes and stop_nodes to start and stop the bitcoind nodes in parallel, making test setup and teardown much faster.