aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
AgeCommit message (Collapse)Author
2018-05-17[qa] Handle disconnect_node raceSuhas Daftuar
Several tests call disconnect_nodes() on each node-pair in rapid succession, resulting in a race condition if a node disconnects a peer in-between the calculation of the nodeid's to disconnect and the invocation of the disconnectnode rpc call. Handle this. GitHub-Pull: #13201 Rebased-From: 09c6699
2018-04-20qa: Fix python TypeError in script.pyMarcoFalke
Github-Pull: #12475 Rebased-From: fa41d68a2e3f2148c3539a11b61ff835e3141c0d
2018-04-20[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. Github-Pull: #12902 Rebased-From: 75d0e4c5444249f0cf81ed0494e2c2717170b695
2018-04-20qa: Cache only chain and wallet for regtest datadirMarcoFalke
Github-Pull: #12638 Rebased-From: fa2310572f4cfcd3322409ce7e37dde155fc4bc9
2018-04-20[qa] Ensure bitcoind processes are cleaned up when tests endSuhas Daftuar
Github-Pull: #12904 Rebased-From: e36a0c08529bccc695ec71a7ec1df89367cc1628
2018-04-20test: Use wait_until in tests where time was used for pollingBen Woosley
Github-Pull: #12553 Rebased-From: 81b0822772169cb697b5994f49398e619d61a12d
2018-04-20[test] Round target fee to 8 decimals in assert_fee_amountKarl-Johan Alm
The output would produce arbitrary number of decimal points, sometimes resulting in 9 decimals: AssertionError: Fee of 0.00000415 BTC too low! (Should be 0.000006175 BTC) The above looks like the expected fee is 6175 sats when in reality it's 618. Github-Pull: #12486 Rebased-From: 42e1b5d9797b65d3ce13a7cbace15fbedbcd4018
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-17qa: Sync with validationinterface queue in sync_mempoolsMarcoFalke
2018-01-15Merge #11796: [tests] Functional test naming conventionWladimir J. van der Laan
5fecd84 [tests] Remove redundant import in blocktools.py test (Anthony Towns) 9b20bb4 [tests] Check tests conform to naming convention (Anthony Towns) 7250b4e [tests] README.md nit fixes (Anthony Towns) 82b2712 [tests] move witness util functions to blocktools.py (John Newbery) 1e10854 [tests] [docs] update README for new test naming scheme (John Newbery) Pull request description: Splitting #11774 into two parts -- this part updates the README with the proposed naming convention, and adds some checks to test_runner.py that the number of tests violating the naming convention doesn't increase too much. Idea is this part of the change should not introduce merge conflicts or require much rebasing, so reviews of the complicated bits won't become invalidated too often; while the second part will just be file renames, which will require regular rebasing and will introduce merge conflicts with pending PRs, but can be merged later, and should also be much easier to review, since it will only include relatively trivial changes. Tree-SHA512: b96557d41714addbbfe2aed62fb5a48639eaeb1eb3aba30ac1b3a86bb3cb8d796c6247f9c414c4695c4bf54c0ec9968ac88e2f88fb62483bc1a2f89368f7fc80
2018-01-12Merge #11970: Add test coverage for bitcoin-cli multiwallet callsMarcoFalke
a14dbff39e Allow multiwallet.py to be used with --usecli (Russell Yanofsky) f6ade9ce1a [tests] allow tests to be run with --usecli (John Newbery) ff9a363ff7 TestNodeCLI batch emulation (Russell Yanofsky) ca9085afc5 Prevent TestNodeCLI.args mixups (Russell Yanofsky) fcfb952bca Improve TestNodeCLI output parsing (Russell Yanofsky) Pull request description: Lack of test coverage was pointed out by @jnewbery in https://github.com/bitcoin/bitcoin/pull/11687#discussion_r158133900 Tree-SHA512: 5f10e31abad11a5edab0da4e2515e39547adb6ab9e55e50427ab2eb7ec9a43d6b896b579b15863e5edc9beee7d8bf1c84d9dabd247be0760a1b9ae39e1e8ee02
2018-01-10Merge #11403: SegWit wallet supportJonas Schnelli
b224a47a1 Add address_types test (Pieter Wuille) 7ee54fd7c Support downgrading after recovered keypool witness keys (Pieter Wuille) 940a21932 SegWit wallet support (Pieter Wuille) f37c64e47 Implicitly know about P2WPKH redeemscripts (Pieter Wuille) 57273f2b3 [test] Serialize CTransaction with witness by default (Pieter Wuille) cf2c0b6f5 Support P2WPKH and P2SH-P2WPKH in dumpprivkey (Pieter Wuille) 37c03d3e0 Support P2WPKH addresses in create/addmultisig (Pieter Wuille) 3eaa003c8 Extend validateaddress information for P2SH-embedded witness (Pieter Wuille) 30a27dc5b Expose method to find key for a single-key destination (Pieter Wuille) 985c79552 Improve witness destination types and use them more (Pieter Wuille) cbe197470 [refactor] GetAccount{PubKey,Address} -> GetAccountDestination (Pieter Wuille) 0c8ea6380 Abstract out IsSolvable from Witnessifier (Pieter Wuille) Pull request description: This implements a minimum viable implementation of SegWit wallet support, based on top of #11389, and includes part of the functionality from #11089. Two new configuration options are added: * `-addresstype`, with options `legacy`, `p2sh`, and `bech32`. It controls what kind of addresses are produced by `getnewaddress`, `getaccountaddress`, and `createmultisigaddress`. * `-changetype`, with the same options, and by default equal to `-addresstype`, that controls what kind of change is used. All wallet private and public keys can be used for any type of address. Support for address types dependent on different derivation paths will need a major overhaul of how our internal detection of outputs work. I expect that that will happen for a next major version. The above also applies to imported keys, as having a distinction there but not for normal operations is a disaster for testing, and probably for comprehension of users. This has some ugly effects, like needing to associate the provided label to `importprivkey` with each style address for the corresponding key. To deal with witness outputs requiring a corresponding redeemscript in wallet, three approaches are used: * All SegWit addresses created through `getnewaddress` or multisig RPCs explicitly get their redeemscripts added to the wallet file. This means that downgrading after creating a witness address will work, as long as the wallet file is up to date. * All SegWit keys in the wallet get an _implicit_ redeemscript added, without it being written to the file. This means recovery of an old backup will work, as long as you use new software. * All keypool keys that are seen used in transactions explicitly get their redeemscripts added to the wallet files. This means that downgrading after recovering from a backup that includes a witness address will work. These approaches correspond to solutions 3a, 1a, and 5a respectively from https://gist.github.com/sipa/125cfa1615946d0c3f3eec2ad7f250a2. As argued there, there is no full solution for dealing with the case where you both downgrade and restore a backup, so that's also not implemented. `dumpwallet`, `importwallet`, `importmulti`, `signmessage` and `verifymessage` don't work with SegWit addresses yet. They're remaining TODOs, for this PR or a follow-up. Because of that, several tests unexpectedly run with `-addresstype=legacy` for now. Tree-SHA512: d425dbe517c0422061ab8dacdc3a6ae47da071450932ed992c79559d922dff7b2574a31a8c94feccd3761c1dffb6422c50055e6dca8e3cf94a169bc95e39e959
2018-01-09[test] Serialize CTransaction with witness by defaultPieter Wuille
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.
2018-01-03[tests] Remove redundant import in blocktools.py testAnthony Towns
2018-01-03Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa
2017-12-19[tests] define NODE_NETWORK_LIMITED in test frameworkJohn Newbery
2017-12-11[tests] Add NetworkThread assertionsJohn Newbery
Check that P2PConnections aren't created after the NetworkThread has started and that at any time only one NetworkThread is running.
2017-12-11[tests] Add network_thread_ utility functions.John Newbery
Add network thread_start(), network_thread_running() and network_thread_join() utility functions in mininode.py and use network_thread_running() in network thread assertions.
2017-12-10Remove unused Python importspracticalswift
2017-11-30Merge #11791: [tests] Rename NodeConn and NodeConnCBMarcoFalke
873beca6d [tests] Rename NodeConn and NodeConnCB (John Newbery) Pull request description: Final step in #11518 NodeConn -> P2PConnection NodeConnCB -> P2PInterface This is basically just a rename. Should be an easy review. Tree-SHA512: fe1204b2b3d8182c5e324ffa7cb4099a47ef8536380e0bb9d37a5fccf76a24f548d1f1a7988ab8f830986a3058b670696de3fc891af5e5f75dbeb4e3273005d7
2017-11-30Merge #11789: [tests] [travis-ci] Combine logs on failureWladimir J. van der Laan
ff8a9b0 [tests] Add combinedlogslen argument to test_runner.py (John Newbery) dba94ea [tests] [travis-ci] Move Travis functional test log post processing to test_runner (John Newbery) bba1c54 [tests] Improve logging shutdown and add hint for combine_logs (John Newbery) Pull request description: Replaces #11779 . Notes from that PR: > Currently, when a functional test fails, the debug logs are printed sequentially to the travis log. This makes debugging race conditions based on the travis log hard. Instead, all logs events should be combined and sorted by their timestamp, then appended to the travis log. @MarcoFalke Tree-SHA512: 56c80067d6a2c92f7e6a35e3ae5160637a0de052d9da593c7be6e02233544a93c66d62456f903f85e2edc09e31ab4bdafd1aed1d9897ae48c634f82631f856f7
2017-11-29[tests] Rename NodeConn and NodeConnCBJohn Newbery
NodeConn -> P2PConnection NodeConnCB -> P2PInterface
2017-11-29Merge #11712: [tests] Split NodeConn from NodeConnCBMarcoFalke
e9dfa9bcc [tests] Move version message sending from NodeConn to NodeConnCB (John Newbery) dad596fc3 [tests] Make NodeConnCB a subclass of NodeConn (John Newbery) e30d40438 [tests] Move only: move NodeConnCB below NodeConn (John Newbery) 4d5059856 [tests] Tidy up mininode (John Newbery) f2ae6f32a [tests] Remove mininode periodic (half-hour) ping messages (John Newbery) ec59523c5 [tests] Remove rpc property from TestNode in p2p-segwit.py. (John Newbery) Pull request description: This is the final step in #11518, except for possibly renaming - for motivation, please see that PR. If this is merged, then migrating the test framework from asyncore to asyncio should be easier (I say should because I haven't dug too deeply into what would be required). Requesting review from @ryanofsky , since he always has good feedback on these refactor PRs, and I'd appreciate his take on this refactor. Note particularly that I've reverted the change suggested here: https://github.com/bitcoin/bitcoin/pull/11182#discussion_r148859555 . The idea, as always, is to present a simple interface to the test writer. Tree-SHA512: 94dd467a13ec799b101108cf47d4dccb6f6240b601e375e3d785313333bbb389c26072a50759aca663bbf3d6c8b867b99e36ae8800ab8ea115e0496c151926ce
2017-11-29[tests] [travis-ci] Move Travis functional test log post processing to ↵John Newbery
test_runner
2017-11-29[tests] Improve logging shutdown and add hint for combine_logsJohn Newbery
2017-11-28[tests] Move version message sending from NodeConn to NodeConnCBJohn Newbery
This commit moves the logic that sends a version message on connection from NodeConn to NodeConnCB. NodeConn should not be aware of the semantics or meaning of the P2P payloads.
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-28[tests] Move only: move NodeConnCB below NodeConnJohn Newbery
This is required since NodeConnCB will inherit from NodeConn after the next commit.
2017-11-28[tests] Tidy up mininodeJohn Newbery
Add docstrings and renames some methods. Also removes the redundant NodeConn.readable() method override.
2017-11-25Merge #11683: tests: Remove unused mininode functions ↵MarcoFalke
{ser,deser}_int_vector(...). Remove unused imports. f522fb7c9 tests: Remove unused mininode functions deser_int_vector(f) and ser_int_vector(l) (practicalswift) 0f3b752ec Remove unused imports (practicalswift) Pull request description: * Remove unused mininode functions `deser_int_vector(f)` and `ser_int_vector(l)`. Last use removed in 3858aabbd084b2cc4534c40a178bbcc22fb82968. Friendly ping @jnewbery :-) * Remove unused imports. Tree-SHA512: 840c5623eae9f929561f6e86816883c5904ec1af82fc8d5e56dee1c0b1fe22e8600c10f7358ed8b556b3aec8c65c4910f6eee30e8015a573c4df8bef91124d3e
2017-11-23[tests] Remove mininode periodic (half-hour) ping messagesJohn Newbery
2017-11-18Merge #11466: Specify custom wallet directory with -walletdir paramWladimir J. van der Laan
c1e5d40 Make debugging test crash easier (MeshCollider) 8263f6a Create walletdir if datadir doesn't exist and fix tests (MeshCollider) 9587a9c Default walletdir is wallets/ if it exists (MeshCollider) d987889 Add release notes for -walletdir and wallets/ dir (MeshCollider) 80c5cbc Add test for -walletdir (MeshCollider) 0530ba0 Add -walletdir parameter to specify custom wallet dir (MeshCollider) Pull request description: Closes #11348 Adds a `-walletdir` parameter which specifies a directory to use for wallets, allowing them to be stored separately from the 'main' data directory. Creates a new `wallets/` directory in datadir if this is the first time running, and defaults to using it if it exists. Includes tests and release notes. Things which might need to be considered more: - there is no 'lock' on the wallets directory, which might be needed? - because this uses a new wallets/ directory by default, downgrading to an earlier version won't see the wallets in that directory (not a big deal though, users can just copy them up to the main dir) - jnewbery suggested putting each wallet in its own directory, which is a good idea, but out of scope for this PR IMO. EDIT: this is being done in https://github.com/bitcoin/bitcoin/pull/11687 - doc/files.md needs updating (will do soon) I also considered including a cleanup by removing caching of data directory paths and instead just initialise them once on startup (c.f. #3073), but decided it wasn't super relevant here will just complicate review. Tree-SHA512: c8ac04bfe9a810c32055f2c8b8fa0d535e56125ceb8d96f12447dd3538bf3e5ee992b60b1cd2173bf5f3fa023a9feab12c9963593bf27ed419df929bb413398d
2017-11-17tests: Remove unused mininode functions deser_int_vector(f) and ↵practicalswift
ser_int_vector(l)
2017-11-17Merge #11648: [tests] Add messages.pyWladimir J. van der Laan
1135c79 [tests] Tidy up mininode.py module (John Newbery) f9cd9b1 [tests] Move test_framework Bitcoin primitives into separate module (John Newbery) Pull request description: Second part of #11518. Moves the primitive Bitcoin datastructures and message classes into their own module, and tidies up the mininode.py module. - First commit is almost entirely move-only - Second commit is mostly move-only, but also does a little tidying. Tree-SHA512: 5d74802677f1ab788e43188653106a96fffd9ab1fe3aa6a4eb94e5807de5dd5c8ee212296f45e8d16c7e3d95cfc4891677e812b7944bd3ab604e04b3b88aa06e
2017-11-18Create walletdir if datadir doesn't exist and fix testsMeshCollider
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-14Merge #11641: qa: Only allow disconnecting all NodeConnsWladimir J. van der Laan
faaa7db qa: Only allow disconnecting all NodeConns (MarcoFalke) Pull request description: Disconnecting the connection with `index=0` makes no sense when there are more than one connections, as the list "rotates around" and populates index 0 after `del`. Just disconnect all NodeConns in any case. Tree-SHA512: e5cf540823fccb31634b5a11501f54222be89862e80ccafc28bc06726480f8d2153b8c1b6f859fa6a6d087876251d48a6c6035bccdaaf16831e300bc17ff613d
2017-11-13qa: Remove unused NodeConn membersMarcoFalke
2017-11-13qa: Only allow disconnecting all NodeConnsMarcoFalke
2017-11-10[tests] Tidy up mininode.py moduleJohn Newbery
Mostly move only. Adds a few extra comments.
2017-11-10[tests] Move test_framework Bitcoin primitives into separate moduleJohn Newbery
mininode.py wildcard imports all names from primitives.py. This is to avoid having to change all test scripts that import from mininode.py.
2017-11-10Merge #11468: [tests] Make comp test framework more debuggableMarcoFalke
748157913 [tests] Make comp test framework more debuggable (John Newbery) Pull request description: We should remove the comparison test framework entirely (see #10603). Until we do that, let's make it a bit more debuggable. Currently, if there's an assert in the framework, it's very difficult to track down where we are in the test generator. Make the logging a bit better to help with debugging. Before this PR: ``` → ./p2p-fullblocktest.py 2017-10-09 14:05:11.302000 TestFramework (INFO): Initializing test directory /tmp/user/1000/testzdnax_yr 2017-10-09 14:05:11.557000 TestFramework.mininode (INFO): Connecting to Bitcoin Node: 127.0.0.1:11975 2017-10-09 14:05:11.712000 TestFramework.comptool (INFO): Test 1: PASS 2017-10-09 14:05:11.947000 TestFramework.comptool (INFO): Test 2: PASS 2017-10-09 14:05:12.057000 TestFramework.comptool (INFO): Test 3: PASS 2017-10-09 14:05:12.058000 TestFramework (ERROR): Assertion failed Traceback (most recent call last): File "/home/ubuntu/bitcoin/test/functional/test_framework/test_framework.py", line 117, in main self.run_test() File "./p2p-fullblocktest.py", line 72, in run_test self.test.run() File "/home/ubuntu/bitcoin/test/functional/test_framework/comptool.py", line 306, in run assert test_number != 4 AssertionError 2017-10-09 14:05:12.059000 TestFramework (INFO): Stopping nodes 2017-10-09 14:05:14.203000 TestFramework (WARNING): Not cleaning up dir /tmp/user/1000/testzdnax_yr 2017-10-09 14:05:14.204000 TestFramework (ERROR): Test failed. Test logging available at /tmp/user/1000/testzdnax_yr/test_framework.log ``` With this PR: ``` → ./p2p-fullblocktest.py 2017-10-09 14:03:54.069000 TestFramework (INFO): Initializing test directory /tmp/user/1000/testuey7t3tf 2017-10-09 14:03:54.329000 TestFramework.mininode (INFO): Connecting to Bitcoin Node: 127.0.0.1:11783 2017-10-09 14:03:54.383000 TestFramework.comptool (INFO): Running test 1: ./p2p-fullblocktest.py line 184 2017-10-09 14:03:54.496000 TestFramework.comptool (INFO): Running test 2: ./p2p-fullblocktest.py line 193 2017-10-09 14:03:54.758000 TestFramework.comptool (INFO): Running test 3: ./p2p-fullblocktest.py line 205 2017-10-09 14:03:54.867000 TestFramework.comptool (INFO): Running test 4: ./p2p-fullblocktest.py line 208 2017-10-09 14:03:54.867000 TestFramework (ERROR): Assertion failed Traceback (most recent call last): File "/home/ubuntu/bitcoin/test/functional/test_framework/test_framework.py", line 117, in main self.run_test() File "./p2p-fullblocktest.py", line 72, in run_test self.test.run() File "/home/ubuntu/bitcoin/test/functional/test_framework/comptool.py", line 309, in run assert test_number != 4 AssertionError 2017-10-09 14:03:54.868000 TestFramework (INFO): Stopping nodes 2017-10-09 14:03:56.950000 TestFramework (WARNING): Not cleaning up dir /tmp/user/1000/testuey7t3tf 2017-10-09 14:03:56.950000 TestFramework (ERROR): Test failed. Test logging available at /tmp/user/1000/testuey7t3tf/test_framework.log ``` Tree-SHA512: 5525958b0098d661c281bd955c92c72bf81359464376e96d44e6c88f18aea57ba08270ecd564edda4b47d674e3b27d20e5b1060544bf8dd5c6a68103d2bb35b8
2017-11-08[tests] Explicitly disallow support for p2p versions below 60001John Newbery
The mininode module includes code to support p2p versions below 60001. However, the test_framework does not support versions of Bitcoin Core before V0.13.0. Remove code supporting p2p versions before 60001 (which has never been run).