Commit Graph

238 Commits

Author SHA1 Message Date
John Newbery 728667b771 scripted-diff: rename TestNode to TestP2PConn in tests
Several test scripts define a subclass of P2PInterface called TestNode.
This commit renames those to TestP2PConn since we already have a
TestNode class in the test framework.

-BEGIN VERIFY SCRIPT-
sed -i s/TestNode/TestP2PConn/ test/functional/*py test/functional/test_framework/comptool.py
_END VERIFY SCRIPT-
2018-03-19 14:58:00 -04:00
John Newbery 265d7c44b1 [tests] Improve assert message when wait_until() fails 2018-03-19 14:26:12 -04:00
MarcoFalke c8330d4216 qa: Use node.datadir instead of tmpdir in test framework 2018-03-19 12:26:00 -04:00
John Newbery 58122736b5 [Tests] Require exact match in assert_start_raises_init_eror() 2018-03-18 13:32:50 -04:00
John Newbery 0ec08a672d [Tests] Move assert_start_raises_init_error method to TestNode 2018-03-18 12:29:02 -04:00
Ben Woosley 81b0822772
test: Use wait_until in tests where time was used for polling 2018-03-15 23:43:53 -07:00
Wladimir J. van der Laan ce6ffe196e
Merge #12638: qa: Cache only chain and wallet for regtest datadir
fa23105 qa: Cache only chain and wallet for regtest datadir (MarcoFalke)

Pull request description:

  mempool.dat should be empty and I don't see a need to copy it around when restoring from the cache.

Tree-SHA512: f11ab69732db4dee0e9a0900570464e49085532b0cebc963877057112a7b985c477da3d32eb2093daabac9ada9e73b7c49881681ec5efa6101919b0af76001cf
2018-03-14 14:21:49 +01:00
Wladimir J. van der Laan 0f0229d0c3
Merge #12643: [qa] util: Remove unused sync_chain
fa1436c42 [qa] util: Remove unused sync_chain (MarcoFalke)

Pull request description:

  The util function `sync_blocks` already checks for equal chains, so we can remove the unused `sync_chain`.

  Also cleaned up the errors that are printed in case of timeout:

  ```
  AssertionError: Block sync timed out:
    '72a3a3e9dcfd0a09204c3447af0f481d19641eeadbe6a91b8e680ed614bc7712'
    '5032af4ae22ae7a21afdc9d9f516877309c4dd8ef2ecadb9354be7088439b4a6'
    '5032af4ae22ae7a21afdc9d9f516877309c4dd8ef2ecadb9354be7088439b4a6'
  ```
  and
  ```
  AssertionError: Mempool sync timed out:
    {'c2af943d9b321c36e0f5a153a9d3d8b11bdd46ceb28e38f5fd2c722e3edb3563'}
    set()
    set()
  ```

Tree-SHA512: cb4ad30e3e3773072f59afa2c81cfa27bd8f389a93f02acb919990298627fcfbaa53a3d3944d827cc8a5d009871e42a47ea09e9bb93e85c22e3af6a24a574e5d
2018-03-13 17:45:48 +01:00
MarcoFalke fa1436c429
[qa] util: Remove unused sync_chain 2018-03-12 20:32:04 -04:00
practicalswift a7324bd799 Format timestamps using ISO 8601 formatting (e.g. "2018-02-28T12:34:56Z")
* Z is the zone designator for the zero UTC offset.
* T is the delimiter used to separate date and time.

This makes it clear for the end-user that the date/time logged is
specified in UTC and not in the local time zone.
2018-03-09 15:02:01 +01:00
MarcoFalke fa2310572f
qa: Cache only chain and wallet for regtest datadir 2018-03-07 15:53:30 -05:00
MarcoFalke 791c3ea61b
Merge #12627: qa: Fix some tests to work on native windows
fa3528a85b qa: Fix some tests to work on native windows (MarcoFalke)

Pull request description:

  This allows some more tests to be run natively on Windows

Tree-SHA512: 8097a82dc046be9f6bb0da634758c9afef7836960ca7a1f88f9acab9512dbf7bc26525b515faae407edab4620846cce2b427940298f822e250f23f924b4c7591
2018-03-07 10:30:04 -05:00
Wladimir J. van der Laan 0f7167989d
Merge #12482: [tests] bind functional test nodes to 127.0.0.1
b156ff7c3 [tests] bind functional test nodes to 127.0.0.1 (Sjors Provoost)

Pull request description:

  Replaces #12200 which broke `rpc_bind.py`.

  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`.

  cc @jnewbery

Tree-SHA512: 5e700124c91bd0cbdee83ca44910071d71d61d8842334755b685d14fbff6454d75de1ea7de67340370386f58b41361e80e90bb4dca5c4d5992f9d2b27985f999
2018-03-07 14:52:42 +01:00
MarcoFalke fa3528a85b
qa: Fix some tests to work on native windows 2018-03-06 18:42:19 -05:00
Sjors Provoost b156ff7c30
[tests] bind functional test nodes to 127.0.0.1
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-03-06 16:48:15 -05:00
Wladimir J. van der Laan 07d2d2a21c
Merge #12475: qa: Fix python TypeError in script.py
fa41d68a2 qa: Fix python TypeError in script.py (MarcoFalke)

Pull request description:

  `__repr__` returns string, so don't mix it with byte strings.

  This fixes

  ```
  TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'str'

Tree-SHA512: fac06e083f245209bc8a36102217580b0f6186842f4e52a686225111b0b96ff93c301640ff5e7ddef6a5b4f1689071b16a9a8dc80f28e2b060ddee29edd24ec7
2018-03-05 17:32:42 +01:00
Wladimir J. van der Laan 5c2aff8d95
Merge #10387: Eventually connect to NODE_NETWORK_LIMITED peers
eb91835 Add setter for g_initial_block_download_completed (Jonas Schnelli)
3f56df5 [QA] add NODE_NETWORK_LIMITED address relay and sync test (Jonas Schnelli)
158e1a6 [QA] fix mininode CAddress ser/deser (Jonas Schnelli)
fa999af [QA] Allow addrman loopback tests (add debug option -addrmantest) (Jonas Schnelli)
6fe57bd Connect to peers signaling NODE_NETWORK_LIMITED when out-of-IBD (Jonas Schnelli)
31c45a9 Accept addresses with NODE_NETWORK_LIMITED flag (Jonas Schnelli)

Pull request description:

  Eventually connect to peers signalling NODE_NETWORK_LIMITED if we are out of IBD.
  Accept and relay NODE_NETWORK_LIMITED peers in addrman.

Tree-SHA512: 8a238fc97f767f81cae1866d6cc061390f23a72af4a711d2f7158c77f876017986abb371d213d1c84019eef7be4ca951e8e6f83fda36769c4e1a1d763f787037
2018-03-01 15:31:15 +01:00
MarcoFalke 07090c5339
Merge #12443: qa: Move common args to bitcoin.conf
face7220b7 qa: Move common args to bitcoin.conf (MarcoFalke)

Pull request description:

  Beside removing duplicates of the same args in the code, this actually helps with debugging after a test failure.

  For example, `bitcoin-qt` has `server` turned off, so you'd have to turn it on every time, if you wanted to debug a temporary test datadir created by the test framework.
  Also, `keypool` would fill up if you forget to specify `-keypool=1`.

Tree-SHA512: 996bec8738dc0fce7297ab1fc5b4fbe3aa31b9b6241f8c4e685db728925363ccaca6145ad1edc6bee2f360e02ac4b9a53fcdff74eb79de90793393742d52b559
2018-02-23 12:37:06 -05:00
Wladimir J. van der Laan 8c33961313
Merge #12486: [test] Round target fee to 8 decimals in assert_fee_amount
42e1b5d [test] Round target fee to 8 decimals in assert_fee_amount (Karl-Johan Alm)

Pull request description:

  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.

Tree-SHA512: ddbff2926a88890d6e34a58db36f0b15a917a80064be6e40e9bcbec3f05ae6202d02adcd7873733945b043fa121d4a56dd930446ec368078fe1935cbfff898ce
2018-02-23 17:07:27 +01:00
Karl-Johan Alm 42e1b5d979
[test] Round target fee to 8 decimals in assert_fee_amount
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.
2018-02-20 13:21:54 +09:00
MarcoFalke fa41d68a2e
qa: Fix python TypeError in script.py 2018-02-18 23:42:01 -05:00
Andrew Chow eefff65a4b scripted-diff: change signrawtransaction to signrawtransactionwithwallet in tests
-BEGIN VERIFY SCRIPT-
sed -i 's/\<signrawtransaction\>/signrawtransactionwithwallet/g' test/functional/*.py
sed -i 's/\<signrawtransaction\>/signrawtransactionwithwallet/g' test/functional/test_framework/*.py
-END VERIFY SCRIPT-
2018-02-17 11:42:01 -05:00
Andrew Chow 1e79c055cd Split signrawtransaction into wallet and non-wallet
Splits signrwatransaction into a wallet version (signrawtransactionwithwallet) and
non-wallet version (signrawtransactionwithkey). signrawtransaction is marked as DEPRECATED
and will call the right signrawtransaction* command as per the parameters in order to
maintain compatibility.

Updated signrawtransactions test to use new RPCs
2018-02-17 11:42:00 -05:00
Jonas Schnelli 8a98dfeebf
Merge #10583: [RPC] Split part of validateaddress into getaddressinfo
b22cce014 scripted-diff: validateaddress to getaddressinfo in tests (Andrew Chow)
b98bfc5ed Create getaddressinfo RPC and deprecate parts of validateaddress (Andrew Chow)
1598f3230 [rpc] Move DescribeAddressVisitor to rpc/util (John Newbery)
39633ecd5 [rpc] split wallet and non-wallet parts of DescribeAddressVisitor (John Newbery)

Pull request description:

  This PR makes a new RPC command called `getaddressinfo` which relies on the wallet. It contains all of `validateaddress`'s address info stuff. Those parts in `validateaddress` have been marked as deprecated. The tests have been updated to use `getaddressinfo` except the `disablewallet` test which is the only test that actually uses `validateaddress` to validate an address.

Tree-SHA512: ce00ed0f2416200b8de1e0a75e8517c024be0b6153457d302c3879b3491cce28191e7c29aed08ec7d2eeeadc62918f5c43a7cb79cd2e4b6d9291bd83ec31c852
2018-02-17 22:27:08 +11:00
John Newbery df47afb600 Revert "[tests] bind functional test nodes to 127.0.0.1"
This reverts commit 65682da7e5.
2018-02-16 15:59:34 -05:00
Andrew Chow b22cce0148 scripted-diff: validateaddress to getaddressinfo in tests
Change all instances of validateaddress to getaddressinfo since it seems that
no test actually uses validateaddress for actually validating addresses.

-BEGIN VERIFY SCRIPT-
find ./test/functional -path '*py' -not -path ./test/functional/wallet_disable.py -not -path ./test/functional/rpc_deprecated.py -not -path ./test/functional/wallet_address_types.py -exec sed -i'' -e 's/validateaddress/getaddressinfo/g' {} \;
-END VERIFY SCRIPT-
2018-02-16 12:09:36 -05:00
MarcoFalke face7220b7
qa: Move common args to bitcoin.conf 2018-02-15 14:00:28 -05:00
Wladimir J. van der Laan d09968f4d0
Merge #12200: Bind functional test nodes to 127.0.0.1
65682da [tests] bind functional test nodes to 127.0.0.1 (Sjors Provoost)

Pull request description:

  Prevents OSX firewall allow-this-application-to-accept-inbound-connections permission popups and is generally safer.

  To test, make an arbitrary whitespace change to `src/bitcoind.cpp` and recompile. This normally resets the firewall's memory.

  Easiest way to reproduce a popup without running the test suite:

  ```sh
  src/bitcoind -regtest -bind=127.0.0.1 # No popup
  src/bitcoind -regtest # Popup
  ```

Tree-SHA512: ffa92f148a2ead2ceca978c285882979639be23eb31ad6a27aa81df9fdddba5d493719c92c09a351a81d638f6f739c351a721e42168d77ead60abe074df773d6
2018-02-15 18:17:19 +01:00
Wladimir J. van der Laan 2dbc4a4740
Merge #11771: [tests] Change invalidtxrequest to use BitcoinTestFramework
95e2e9a [tests] Change invalidtxrequest to use BitcoinTestFramework (John Newbery)
359d067 [tests] Fix flake8 warnings in invalidtxrequest (John Newbery)
c32cf9f [tests] Add P2PDataStore class (John Newbery)
cc046f6 [tests] Reduce NodeConn connection logging from info to debug (John Newbery)

Pull request description:

  Next step in #10603

  - first commit changes log level for an internal log from INFO to DEBUG. (Not really related, but I started finding the INFO level logging annoying when debuging test failures)
  - second commit introduces a `P2PStub` class - a subclass of `NodeConnCB` which has its own block and tx store and responds appropriately to getdata requests. Not all the functionality is used in `invalidtxrequest.py`, but will be used in `invalidblockrequest.py` and `p2p-fullblocktest` when those are changed to use `BitcoinTestFramework`
  - third commit tidies up `invalidtxrequest.py`
  - fourth commit removes usage of `ComparisonTestFramework`

Tree-SHA512: f3085c73c15d6ce894e401490bce8a7fa7cf52b0c9d135ff7e351f1f6f517c99accab8588fcdc443f39ea8315329aaabd66b2baa32499df5a774737882030373
2018-02-13 10:31:06 +01:00
Wladimir J. van der Laan b4d85490f0
Merge #11858: qa: Prepare tests for Windows
faefd29 qa: Prepare functional tests for Windows (MarcoFalke)

Pull request description:

  * Pass `sys.executable` when calling a python script via the subprocess
    module
  * Don't remove the log file while it is still open and written to
  * Properly use os.pathsep and os.path.sep when modifying the PATH
    environment variable
  * util-tests: Use os.path.join for Windows compatibility

  Ref:  #8227

Tree-SHA512: c507a536af104b3bde4366b6634099db826532bd3e7c35d694b5883c550920643b3eab79c76703ca67e1044ed09979e855088f7324321c8d52112514e334d614
2018-02-12 11:31:18 +01:00
Jonas Schnelli 158e1a6f0f
[QA] fix mininode CAddress ser/deser 2018-02-09 19:56:11 +11:00
John Newbery c32cf9f622 [tests] Add P2PDataStore class
P2PDataStore subclasses NodeConnCB. This class keeps a store
of txs and blocks and responds to getdata requests from
the node-under-test.
2018-01-30 09:31:31 -05:00
John Newbery cc046f66a7 [tests] Reduce NodeConn connection logging from info to debug 2018-01-29 09:48:17 -05:00
practicalswift 1340eda3b7 Fix typos 2018-01-28 13:21:25 +01:00
MarcoFalke faefd2923a
qa: Prepare functional tests for Windows
* Pass `sys.executable` when calling a python script via the subprocess
  module
* Don't remove the log file while it is still open and written to
* Properly use os.pathsep and os.path.sep when modifying the PATH
  environment variable
* util-tests: Use os.path.join for Windows compatibility
2018-01-24 15:52:07 -05:00
MarcoFalke 126000ba9e
Merge #12089: qa: Make TestNodeCLI command optional in send_cli
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-24 08:49:54 -05:00
MarcoFalke fae7b14a04 qa: Make TestNodeCLI command optional in send_cli 2018-01-23 13:57:34 -05:00
MarcoFalke ffffb10a9f qa: Rename cli.args to cli.options
That is the name in bitcoin-cli -help
2018-01-23 13:55:40 -05:00
Russell Yanofsky ec527c6c88 Don't allow relative -walletdir paths
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-18 15:09:27 -05:00
MarcoFalke fa1e69e52b qa: Sync with validationinterface queue in sync_mempools 2018-01-17 16:44:32 -05:00
Sjors Provoost 65682da7e5
[tests] bind functional test nodes to 127.0.0.1 2018-01-16 15:46:57 +00:00
Wladimir J. van der Laan 4db16ec827
Merge #11796: [tests] Functional test naming convention
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-15 10:38:01 +01:00
MarcoFalke b7450cdbd8
Merge #11970: Add test coverage for bitcoin-cli multiwallet calls
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-12 17:25:01 -05:00
Jonas Schnelli d889c036cd
Merge #11403: SegWit wallet support
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-10 20:55:41 -10:00
Pieter Wuille 57273f2b30 [test] Serialize CTransaction with witness by default 2018-01-09 15:27:55 -08:00
John Newbery f6ade9ce1a [tests] allow tests to be run with --usecli
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-08 17:35:27 -05:00
Russell Yanofsky ff9a363ff7 TestNodeCLI batch emulation
Support same get_request and batch methods as AuthServiceProxy
2018-01-08 15:17:14 -05:00
Russell Yanofsky ca9085afc5 Prevent TestNodeCLI.args mixups
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-08 15:17:14 -05:00
Russell Yanofsky fcfb952bca Improve TestNodeCLI output parsing
Parse JSONRPCException errors, and avoid JSON decode exception if RPC method
returns a plain string.
2018-01-08 15:17:14 -05:00
Anthony Towns 5fecd842a6 [tests] Remove redundant import in blocktools.py test 2018-01-03 16:16:56 +10:00
Akira Takizawa 595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09:00
John Newbery dbfe294805 [tests] define NODE_NETWORK_LIMITED in test framework 2017-12-19 11:19:55 -05:00
John Newbery 5c8ff26b2f [tests] Add NetworkThread assertions
Check that P2PConnections aren't created after the NetworkThread
has started and that at any time only one NetworkThread is running.
2017-12-11 09:17:21 -05:00
John Newbery 5fc6e71d19 [tests] Add network_thread_ utility functions.
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-11 09:16:44 -05:00
practicalswift c7399e7082 Remove unused Python imports 2017-12-10 11:48:36 +01:00
MarcoFalke 13e31dd654
Merge #11791: [tests] Rename NodeConn and NodeConnCB
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-30 18:01:51 -05:00
Wladimir J. van der Laan 60d739eb49
Merge #11789: [tests] [travis-ci] Combine logs on failure
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-30 13:41:11 +01:00
John Newbery 873beca6de [tests] Rename NodeConn and NodeConnCB
NodeConn -> P2PConnection
NodeConnCB -> P2PInterface
2017-11-29 17:14:48 -05:00
MarcoFalke 9f2c2dba21
Merge #11712: [tests] Split NodeConn from NodeConnCB
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 16:29:19 -05:00
John Newbery dba94ead0c [tests] [travis-ci] Move Travis functional test log post processing to test_runner 2017-11-29 15:10:05 -05:00
John Newbery bba1c54edd [tests] Improve logging shutdown and add hint for combine_logs 2017-11-29 13:29:15 -05:00
John Newbery e9dfa9bccc [tests] Move version message sending from NodeConn to NodeConnCB
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 12:47:02 -05:00
John Newbery dad596fc37 [tests] Make NodeConnCB a subclass of NodeConn
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 12:44:16 -05:00
John Newbery e30d404385 [tests] Move only: move NodeConnCB below NodeConn
This is required since NodeConnCB will inherit from NodeConn
after the next commit.
2017-11-28 12:31:37 -05:00
John Newbery 4d50598569 [tests] Tidy up mininode
Add docstrings and renames some methods.
Also removes the redundant NodeConn.readable() method override.
2017-11-28 12:31:31 -05:00
MarcoFalke a89221873a
Merge #11683: tests: Remove unused mininode functions {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 3858aabbd0. Friendly ping @jnewbery :-)
  * Remove unused imports.

Tree-SHA512: 840c5623eae9f929561f6e86816883c5904ec1af82fc8d5e56dee1c0b1fe22e8600c10f7358ed8b556b3aec8c65c4910f6eee30e8015a573c4df8bef91124d3e
2017-11-25 21:54:45 -05:00
John Newbery f2ae6f32a6 [tests] Remove mininode periodic (half-hour) ping messages 2017-11-23 10:03:22 -05:00
Wladimir J. van der Laan d080a7d503
Merge #11466: Specify custom wallet directory with -walletdir param
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-18 14:41:15 +01:00
practicalswift f522fb7c9c tests: Remove unused mininode functions deser_int_vector(f) and ser_int_vector(l) 2017-11-17 15:35:15 +01:00
Wladimir J. van der Laan ccc70a295f
Merge #11648: [tests] Add messages.py
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-17 13:16:40 +01:00
MeshCollider 8263f6a5ac Create walletdir if datadir doesn't exist and fix tests 2017-11-18 00:50:59 +13:00
MarcoFalke 3bdf242fc6
Merge #11677: qa: Remove unused NodeConn members
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-14 17:44:09 -05:00
Wladimir J. van der Laan 7adeea3b0f
Merge #11641: qa: Only allow disconnecting all NodeConns
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-14 08:56:37 +01:00
MarcoFalke fafdad0d46 qa: Remove unused NodeConn members 2017-11-13 17:43:39 -05:00
MarcoFalke faaa7db25e qa: Only allow disconnecting all NodeConns 2017-11-13 15:27:10 -05:00
John Newbery 1135c796a0 [tests] Tidy up mininode.py module
Mostly move only. Adds a few extra comments.
2017-11-10 11:56:59 -05:00
John Newbery f9cd9b1bfa [tests] Move test_framework Bitcoin primitives into separate module
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-10 11:56:45 -05:00
MarcoFalke 76b3349159
Merge #11468: [tests] Make comp test framework more debuggable
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-10 10:08:24 -05:00
John Newbery fb00c45c32 [tests] Explicitly disallow support for p2p versions below 60001
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).
2017-11-08 15:43:45 -05:00
John Newbery 3858aabbd0 [tests] Remove support for p2p alert messages
Alert messages were removed in p2p version 70013 (Bitcoin Core V0.13.0)
2017-11-08 15:43:24 -05:00
John Newbery c0b1274705 [tests] Remove support for bre-BIP31 ping messages
BIP31 support was added to Bitcoin Core in version 0.6.1. Our test
framework is incompatible with Bitcoin Core versions that old, so remove
all special logic for handling pre-BIP31 pings.
2017-11-08 15:30:44 -05:00
John Newbery 2904e301c5 [tests] Remove dead code from mininode.py
Removes the dead deliver_sleep_time and EarlyDisconnectError code
2017-11-08 15:29:27 -05:00
John Newbery 5e5725cc2b [tests] Add p2p connection to TestNode
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 09:04:02 -05:00
John Newbery b86c1cd208 [tests] fix TestNode.__getattr__() method 2017-11-08 09:04:02 -05:00
Pieter Wuille d618458184 Have SegWit active by default 2017-11-06 19:29:20 -08:00
Wladimir J. van der Laan 6759a24eaa
Merge #11472: qa: Make tmpdir option an absolute path, misc cleanup
fafa003 qa: Remove never used return value of sync_with_ping (MarcoFalke)
fa9de37 qa: Make tmpdir option an absolute path (MarcoFalke)

Pull request description:

  This should fix issues with the multiwallet test and its symlinks
  when the tmpdir is a relative path.

  Rather than fixing os.symlink to work with paths relative to a
  directory descriptor, which does not work on Windows, normalize
  the path instead.

Tree-SHA512: 189690f3d065ea2f0f48e06775c86d513d0916c7c86312432e8e16df160e65539e288c2bd53d49a4180735fa940f6fcd52b506ccd7d9815651a9b1a69850dda6
2017-10-18 16:52:48 +02:00
John Newbery f893085325 [tests] Don't subclass from object for Python 3 2017-10-16 21:46:23 -04:00
John Newbery 8f9e3627ef [tests] authproxy.py: tidy up __init__() 2017-10-16 21:45:49 -04:00
John Newbery 323d8f61e9 [tests] fix flake8 warnings in authproxy.py 2017-10-16 21:45:49 -04:00
John Newbery fc0176d01e [tests] use python3 for authproxy.py 2017-10-16 21:45:49 -04:00
MarcoFalke fafa003970 qa: Remove never used return value of sync_with_ping 2017-10-13 15:29:18 +02:00
MarcoFalke fa9de370b1 qa: Make tmpdir option an absolute path
This should fix issues with the multiwallet test and symlinks
when the tmpdir is a relative path.

Rather than fixing os.symlink to work with paths relative to a
directory descriptor, which does not work on Windows, normalize
the path instead.
2017-10-13 15:28:56 +02:00
Wladimir J. van der Laan f74459dba6
Merge #11277: Fix uninitialized URI in batch RPC requests
4526d21 Add test for multiwallet batch RPC calls (Russell Yanofsky)
74182f2 Add missing batch rpc calls to python coverage logs (Russell Yanofsky)
505530c Add missing multiwallet rpc calls to python coverage logs (Russell Yanofsky)
9f67646 Make AuthServiceProxy._batch method usable (Russell Yanofsky)
e02007a Limit AuthServiceProxyWrapper.__getattr__ wrapping (Russell Yanofsky)
edafc71 Fix uninitialized URI in batch RPC requests (Russell Yanofsky)

Pull request description:

  This fixes "Wallet file not specified" errors when making batch wallet RPC calls with more than one wallet loaded. This issue was reported by @NicolasDorier in https://github.com/bitcoin/bitcoin/issues/11257

  Request URI is not used for anything except multiwallet request dispatching, so this change has no other effect.

Tree-SHA512: b3907af48a6323f864bb045ee2fa56b604188b835025ef82ba3d81673244c04228d796323cec208a676e7cd578a95ec7c7ba1e84d0158b93844d5dda8f6589b9
2017-10-12 14:54:26 +02:00
Wladimir J. van der Laan fef65c4f5e
Merge #11113: [net] Ignore getheaders requests for very old side blocks
eff4bd8 [test] P2P functional test for certain fingerprinting protections (Jim Posen)
a2be3b6 [net] Ignore getheaders requests for very old side blocks (Jim Posen)

Pull request description:

  Sending a getheaders message with an empty locator and a stop hash is a request for a single header by hash. The node will respond with headers for blocks not in the main chain as well as those in the main chain. To avoid fingerprinting, the node should, however, ignore requests for headers on side branches that are too old. This replicates the logic that currently exists for `getdata` requests for blocks.

Tree-SHA512: e04ef61e2b73945be6ec5977b3c5680b6dc3667246f8bfb67afae1ecaba900c0b49b18bbbb74869f7a37ef70b6ed99e78ebe0ea0a1569369fad9e447d720ffc4
2017-10-11 10:54:05 +02:00
John Newbery 82b2712a66 [tests] move witness util functions to blocktools.py
This avoids importing from segwit.py to bumpfee.py
2017-10-10 09:12:01 -04:00
John Newbery 7481579131 [tests] Make comp test framework more debuggable
Add logging so that each test prints the line number of the yield
statement that generated the test.
2017-10-09 10:03:17 -04:00
John Newbery 47ba8cf71e scripted-diff: rename assert_raises_jsonrpc to assert_raises_rpc error
-BEGIN VERIFY SCRIPT-
sed -i 's/assert_raises_jsonrpc/assert_raises_rpc_error/g' test/functional/*py test/functional/test_framework/*py
-END VERIFY SCRIPT-
2017-10-05 09:57:19 -04:00
John Newbery 677d893ff7 [tests] do not allow assert_raises_message to be called with JSONRPCException 2017-10-05 09:48:46 -04:00
John Newbery 5864e9c161 [tests] remove direct testing on JSONRPCException from individual test cases 2017-10-05 09:48:46 -04:00
Russell Yanofsky 74182f235c Add missing batch rpc calls to python coverage logs
Without this change, batch RPC calls are not included in coverage logs.
2017-10-04 03:07:01 -04:00