Commit graph

200 commits

Author SHA1 Message Date
Wladimir J. van der Laan df7addc4c6
Merge #15990: Add tests and documentation for blocksonly
fa8ced32a6 doc: Mention blocksonly in reduce-traffic.md, unhide option (MarcoFalke)
fa320de79f test: Add test for p2p_blocksonly (MarcoFalke)
fa3872e7b4 test: Format predicate source as multiline on error (MarcoFalke)
fa1dce7329 net: Rename ::fRelayTxes to ::g_relay_txes (MarcoFalke)

Pull request description:

  This is de-facto no longer hidden

ACKs for commit fa8ced:
  jamesob:
    utACK fa8ced32a6

Tree-SHA512: 474fbdee6cbd035ed9068a066b6056c1f909ec7520be0417820fcd1672ab3069b53f55c5147968978d9258fd3a3933fe1a9ef8e4f6e14fb6ebbd79701a0a1245
2019-05-16 19:05:24 +02:00
MarcoFalke fad0ce59e9
tests: Fail if RPC has been added without tests 2019-05-15 14:27:18 -04:00
MarcoFalke fa320de79f
test: Add test for p2p_blocksonly 2019-05-13 10:44:42 -04:00
MarcoFalke fa08c5cb99
test_runner: Move pruning back to extended 2019-05-03 16:16:39 -04:00
MarcoFalke 45d8b71778
Merge #15696: [qa] test_runner: Move feature_pruning to base tests
fafb55e2c2 [qa] test_runner: Move feature_pruning to base tests (MarcoFalke)
8728a66782 [tests] fix block time in feature_pruning.py (John Newbery)

Pull request description:

ACKs for commit fafb55:

Tree-SHA512: 88abef94379fbad6629da11dccb080d5f0644490d6f2cc2756a33fac34bcf72e84245cef596dfae5a40f7a99b3f4da0dd85d306d4c1b452d310d3f36eef75a8b
2019-04-30 10:09:54 -04:00
MarcoFalke fafb55e2c2
[qa] test_runner: Move feature_pruning to base tests 2019-04-30 08:55:28 -04:00
Jim Posen 19308c9e21 rpc: Add getblockfilter RPC method.
Retrieves and returns block filter and header from index.
2019-04-06 12:10:55 -07:00
MarcoFalke 27781b6530
Merge #15466: tests: Print remaining jobs in test_runner.py
2e5d482659 tests: Print remaining jobs in test_runner.py (Steven Roose)

Pull request description:

  This helps finding out which tests fail to finish.

Tree-SHA512: d22beb82beecd33aaa50731c83075e49577842d29fd21aa63bcb859df5da99069eba9cc16eed5d91dbba8fb0fdc317fb88b3b370c4d3917e9da1cd13b0a622dc
2019-03-18 11:26:04 -04:00
Steven Roose 2e5d482659
tests: Print remaining jobs in test_runner.py
This helps finding out which tests fail to finish.
2019-03-05 16:18:50 +00:00
MarcoFalke faa7cdf764
scripted-diff: Update copyright in ./test
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./test/
-END VERIFY SCRIPT-
2019-03-02 10:58:35 -05:00
MarcoFalke f9dbb319d2
Merge #15485: add rpc_misc.py, mv test getmemoryinfo, add test mallocinfo
f13ad1cae0 modify test for memory locked in case locking pages failed at some point (Adam Jonas)
2fa85ebd1c add rpc_misc.py, mv test getmemoryinfo, add test mallocinfo (Adam Jonas)

Pull request description:

  Creating the `rpc_misc.py` functional test file to add space for adding tests to a file that doesn't have a lot of coverage.
    - Removing the `getmemoryinfo()` smoke test from wallet basic rather than moving it to keep the wallet decoupled. Feel like testing for reasonable memory allocation values should suffice.
    - Adding coverage for `mallocinfo()`. Introduced standard lib XML parser since the function exports an XML string that describes the current state of the memory-allocation implementation in the caller.

Tree-SHA512: ced30115622916c88d1e729969ee331272ec9f2881eb36dee4bb7331bf633a6810a57fed63a0cfaf86de698edb5162e6a035efd07c89ece1df56b69d61288072
2019-03-01 13:54:20 -05:00
Adam Jonas 2fa85ebd1c add rpc_misc.py, mv test getmemoryinfo, add test mallocinfo 2019-02-26 15:08:36 -05:00
Chun Kuan Lee ae892adceb tests: accept unicode characters on Windows 2019-02-12 05:17:15 +08:00
MeshCollider 6f4e0d1542
Merge #15226: Allow creating blank (empty) wallets (alternative)
7687f7873 [wallet] Support creating a blank wallet (Andrew Chow)

Pull request description:

  Alternative (kind of) to #14938

  This PR adds a `blank` parameter to the `createwallet` RPC to create a wallet that has no private keys initially. `sethdseed` can then be used to make a clean wallet with a custom seed. `encryptwallet` can also be used to make a wallet that is born encrypted.

  Instead of changing the version number as done in #14938, a wallet flag is used to indicate that the wallet should be blank. This flag is set at creation, and then unset when the wallet is no longer blank. A wallet becomes non-blank when a HD seed is set or anything is imported. The main change to create a blank wallet is primarily taken from #14938.

  Also with this, the term "blank wallet" is used instead of "empty wallet" to avoid confusion with wallets that have balance which would also be referred to as "empty".

  This is built on top of #15225 in order to fix GUI issues.

Tree-SHA512: 824d685e11ac2259a26b5ece99c67a7bda94a570cd921472c464243ee356b7734595ad35cc439b34357135df041ed9cba951e6edac194935c3a55a1dc4fcbdea
2019-02-11 08:08:33 +13:00
Andrew Chow 7687f7873b [wallet] Support creating a blank wallet
A blank wallet is a wallet that has no keys, script or watch only things.
A new wallet flag indicating that it is blank will be set when the wallet
is blank. Once it is no longer blank (a seed has been generated, keys or
scripts imported, etc), the flag will be unset.
2019-02-10 12:24:53 -05:00
MarcoFalke 1477933f28
Merge #15370: test_runner: Remove unused --force option
fae8b8bb1a qa: Add tool-prefix to functional test readme (MarcoFalke)
faf3d22725 test_runner: Remove unused --force option (MarcoFalke)

Pull request description:

  When someone calls the script they already have all intention to call it, no need to specify a redundant `--force`.

  The functional tests are still disabled on the travis windows cross builds, where they'd run into issues when run under Wine.

Tree-SHA512: ada0dd9b3c0cd28c5832a12c5e04c029dc3bfe5ddf366fd0abc24fb7914d2e0f0a873fe756ade7ba780a561abe9bc731838c289accc421deda481269e08514cd
2019-02-08 10:40:34 -05:00
MarcoFalke faf3d22725
test_runner: Remove unused --force option 2019-02-07 19:16:57 -05:00
MeshCollider 1933e38c1a
Merge #14667: Add deriveaddresses RPC util method
595283851 [rpc] util: add deriveaddresses method (Sjors Provoost)

Pull request description:

  Usage:

  ```sh
  bitcoin-cli deriveaddresses "wpkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/0)"
  [
    "bc1qg6ucjz7kgdedam7v5yarecy54uqw82yym06z3q"
  ] // part of the BIP32 test vector
  ```

  Avoids the need for external (BIP32) libraries to derive an address. Can be used in conjunction with `scantxoutset` as a poor mans wallet. Might be useful to test more complicated future descriptors.

  ~To keep it as simple as possible it only supports descriptors that result in a single address, so no `combo()` and ranges.~

  As discussed recently on IRC it might make sense to put this in a separate utility along with other descriptor and psbt utility functions which don't need a chain or wallet context. However I prefer to leave that to another PR.

Tree-SHA512: b8e53db11a8fd87638cc98766270cc3be9adc4b3e5085798a6a4e2e6ad252bf6d2189346bbb2da72d04d13f7f1e80b5cb88e8039653bea1f150602a876ef7f34
2019-02-08 08:21:52 +13:00
João Barbosa 3c3e31c3a4 [tests] Add wallet-tool test
Original tests by João Barbosa <joao.paulo.barbosa@gmail.com>

Additional contribution by John Newbery <john@johnnewbery.com>
2019-01-30 16:26:56 -05:00
Sjors Provoost 595283851d
[rpc] util: add deriveaddresses method 2019-01-29 18:14:23 +01:00
MarcoFalke fa48baf23e
wallet: Avoid leaking locktime fingerprint when anti-fee-sniping 2018-12-27 13:03:10 +01:00
MarcoFalke 86e0a33f5c
Merge #14653: rpcwallet: Add missing transaction categories to rpc helptexts
f3f6dde56e Test coinbase category in wallet rpcs (andrewtoth)
e982f0b682 Add all category options to wallet rpc help (andrewtoth)

Pull request description:

  The current helptext for `listtransactions`, `listsinceblock` and `gettransaction` only list two of the five possible options for `category`. This incorrectly implies that these are the only two options, and can cause problems if the other three options aren't accounted for. Also, some of the documentation is incorrect when specifying which options are returned for which categories.

  This PR updates the helptext for these RPCs and adds a functional regression test for the cases when the other three categories are returned.

Tree-SHA512: 67dd7ff6269a3b0f17f5d1a61b0ae1fb1f3778f05e1c440bfbb9b3a005c9c6d740abcace20f3d597cf2bd6779c494448690f13fab0bd2340f206213bc7890b51
2018-12-21 05:57:25 +13:00
MarcoFalke 9390217044
Merge #14795: test: allows test_runner command line to receive parameters for each test
5c40e7b91a test: allows test_runner command line to receive parameters for each test (marcoagner)

Pull request description:

  Fixes #14791.
  Seems to address the asked behaviour in a simple way, but could address more if a more complex behaviour is found to be needed (e.g. call `rpc_bind --ipv4` without the ".py" and have it added).

Tree-SHA512: d7e21dd0ada36dd97dac71196bb97702a92986b181beb3753e37e3294b899fb65129aff5f9a45fe92b06fbf7c74e605ccb87a422f874f7a85d30401f4c2228c8
2018-12-07 11:26:15 -05:00
Wladimir J. van der Laan a88bd3186d
Merge #14670: http: Fix HTTP server shutdown
28479f926f qa: Test bitcond shutdown (João Barbosa)
8d3f46ec39 http: Remove timeout to exit event loop (João Barbosa)
e98a9eede2 http: Remove unnecessary event_base_loopexit call (João Barbosa)
6b13580f4e http: Unlisten sockets after all workers quit (João Barbosa)
18e9685816 http: Send "Connection: close" header if shutdown is requested (João Barbosa)
02e1e4eff6 rpc: Add wait argument to stop (João Barbosa)

Pull request description:

  Fixes #11777. Reverts #11006. Replaces #13501.

  With this change the HTTP server will exit gracefully, meaning that all requests will finish processing and sending the response, even if this means to wait more than 2 seconds (current time allowed to exit the event loop).

  Another small change is that connections are accepted even when the server is stopping, but HTTP requests are rejected. This can be improved later, especially if chunked replies are implemented.

  Briefly, before this PR, this is the order or events when a request arrives (RPC `stop`):
   1. `bufferevent_disable(..., EV_READ)`
   2. `StartShutdown()`
   3. `evhttp_del_accept_socket(...)`
   4. `ThreadHTTP` terminates (event loop exits) because there are no active or pending events thanks to 1. and 3.
   5. client doesn't get the response thanks to 4.

  This can be verified by applying
  ```diff
       // Event loop will exit after current HTTP requests have been handled, so
       // this reply will get back to the client.
       StartShutdown();
  +    MilliSleep(2000);
       return "Bitcoin server stopping";
   }
  ```
  and checking the log output:
  ```
      Received a POST request for / from 127.0.0.1:62443
      ThreadRPCServer method=stop user=__cookie__
      Interrupting HTTP server
  **  Exited http event loop
      Interrupting HTTP RPC server
      Interrupting RPC
      tor: Thread interrupt
      Shutdown: In progress...
      torcontrol thread exit
      Stopping HTTP RPC server
      addcon thread exit
      opencon thread exit
      Unregistering HTTP handler for / (exactmatch 1)
      Unregistering HTTP handler for /wallet/ (exactmatch 0)
      Stopping RPC
      RPC stopped.
      Stopping HTTP server
      Waiting for HTTP worker threads to exit
      msghand thread exit
      net thread exit

      ... sleep 2 seconds ...

      Waiting for HTTP event thread to exit
      Stopped HTTP server
  ```

  For this reason point 3. is moved right after all HTTP workers quit. In that moment HTTP replies are queued in the event loop which keeps spinning util all connections are closed. In order to trigger the server side close with keep alive connections (implicit in HTTP/1.1) the header `Connection: close` is sent if shutdown was requested. This can be tested by
  ```
  bitcoind -regtest
  nc localhost 18443
  POST / HTTP/1.1
  Authorization: Basic ...
  Content-Type: application/json
  Content-Length: 44

  {"jsonrpc": "2.0","method":"stop","id":123}
  ```

  Summing up, this PR:
   - removes explicit event loop exit — event loop exits once there are no active or pending events
   - changes the moment the listening sockets are removed — explained above
   - sends header `Connection: close` on active requests when shutdown was requested which is relevant when it's a persistent connection (default in HTTP 1.1) — libevent is aware of this header and closes the connection gracefully
   - removes event loop explicit break after 2 seconds timeout

Tree-SHA512: 4dac1e86abe388697c1e2dedbf31fb36a394cfafe5e64eadbf6ed01d829542785a8c3b91d1ab680d3f03f912d14fc87176428041141441d25dcb6c98a1e069d8
2018-12-06 17:43:07 +01:00
andrewtoth f3f6dde56e Test coinbase category in wallet rpcs 2018-12-01 13:00:38 -05:00
John Newbery c1825b9d39 [tests] Add wallet_balance.py
Adds a test specifically to test the wallet's getbalance and
getunconfirmedbalance RPCs.
2018-11-30 10:28:01 -05:00
marcoagner 5c40e7b91a
test: allows test_runner command line to receive parameters for each test 2018-11-23 17:02:24 +00:00
João Barbosa 28479f926f qa: Test bitcond shutdown 2018-11-23 16:54:22 +00:00
Daniel Kraft 3d2c7d6f94 Add regtest for JSON-RPC batch calls.
This adds a new regtest file 'interface_rpc.py', containing a test for
batch JSON-RPC requests.  Those were previously not tested at all.  Tests
for basic requests are not really necessary, as those are used anyway
in lots of other regtests.

The existing interface_http.py file is more about the underlying HTTP
connection, so adding a new interface file for the JSON-RPC specific
things makes sense.
2018-11-21 19:43:06 +01:00
MarcoFalke e0c6bb7823
Merge #14705: travis: Avoid timeout on verify-commits check
fa5a6ce102 qa: Raise ci test_runner timeout to 40 mins (MarcoFalke)
fa3df025e1 travis: Avoid timeout on verify-commits check (MarcoFalke)

Pull request description:

  The verify-commits check is too expensive to run in full (calculate Tree-SHA512 and clean-merge for every single merge commit in history) every day (the cron job runs every ~24h). Since the cron job is running every day, it is also redundant to redo most of the work on the next day.

  So, only check two days worth of commits and assume that travis checked the Tree-SHA512 and clean-merge for all other commits already. The script will still check all the signatures, since the check-result for them depends on external inputs such as current time or the public keys we got from the server.

  [Note that travis is not meant to do the verification for anyone or is meant to be trusted in any way. This check only serves as a belt-and-suspender to notify maintainers in case of a technical issue or script malfunction. But since the script is timing out for months now, its purpose is diminished right now.]

Tree-SHA512: 336c5cbcc03cdf50be96cd61412471be9078d862da8ba2054f337441e062a6067c95fbbd03912e3de6a116f3caa75fd3f01a04864d34aae1489faa3154572815
2018-11-13 12:25:25 -05:00
Jonas Schnelli b60f4e3f09
Merge #13381: RPC: creates possibility to preserve labels on importprivkey
a6b5ec18f rpc: creates possibility to preserve labels on importprivkey (marcoagner)

Pull request description:

  Closes #13087.

  As discussed in the issue, this is a feature request instead of a bug report since the behaviour was as intended (i.e. label with default: `''`). With this, the old behaviour is kept while the possibility to achieve the preservation of labels, as expected in the open issue, is added.

Tree-SHA512: b33be50e1e7f62f7ddfae953177ba0926e2d848961f9fac7501c2b513322c0cb95787745d07d137488267bad1104ecfdbe800c6747f94162eb07c976835c1386
2018-11-13 14:52:01 +07:00
MarcoFalke fa5a6ce102
qa: Raise ci test_runner timeout to 40 mins 2018-11-10 13:12:40 -05:00
practicalswift 590a57fdec tests: Remove unused testing code 2018-11-07 18:07:49 +01:00
MarcoFalke 6af27b8157
Merge #14619: tests: Fix value display name in test_runner help text
5a05aa2db2 Add metavar to match var name in help text + Change wording for better readability (Martin Erlandsson)

Pull request description:

  The help text given by `test/functional/test_runner.py -h` refers to the value `n`, which is defined as `COMBINEDLOGSLEN` in the list of commands.

  To make the help text consistent, this PR changes the display name `COMBINEDLOGSLEN` to `n` by setting the argparse [`metavar`](https://docs.python.org/3/library/argparse.html#metavar) attribute. (`metavar` only changes the _displayed_ name)

  Alternatively: Do the opposite and change the help text to use `COMBINEDLOGSLEN`.

  ---

  Before PR:
  ```
  ➜  bitcoin > test/functional/test_runner.py -h | grep -A 1 combinedlogslen
    --combinedlogslen COMBINEDLOGSLEN, -c COMBINEDLOGSLEN
                          print a combined log (of length n lines) from all test nodes and test framework to the console on failure.
  ```

  After PR:
  ```
  ➜  bitcoin > test/functional/test_runner.py -h | grep -A 1 combinedlogslen
    --combinedlogslen n, -c n
                          print a combined log (of length n lines) from all test nodes and test frameworks to the console on failure.
  ```
  ---
  Also, fixed pluralization typo.

Tree-SHA512: a1124a4976d29fae1e8ecd7fa2ac523b7f05d541c611166532f44692995691a96faf797fa71582d78634f328b500cbee49c6ef296c8f1a898a57c050cc4e721d
2018-11-06 10:44:40 -05:00
Wladimir J. van der Laan 024816d6cf
Merge #14522: tests: add invalid P2P message tests
d20a9fa13d tests: add tests for invalid P2P messages (James O'Beirne)
62f94d39f8 tests: add P2PConnection.send_raw_message (James O'Beirne)
5aa31f6ef2 tests: add utility to assert node memory usage hasn't increased (James O'Beirne)

Pull request description:

  - Adds `p2p_invalid_messages.py`: tests based on behavior for dealing with invalid and malformed P2P messages. Includes a test verifying that we can't DoS a node by spamming it with large invalid messages.
  - Adds `TestNode.assert_memory_usage_stable`: a context manager that allows us to ensure memory usage doesn't significantly increase on a node during some test.
  - Adds `P2PConnection.send_raw_message`: which allows us to construct and send messages with tweaked headers.

Tree-SHA512: 720a4894c1e6d8f1551b2ae710e5b06c9e4f281524623957cb01599be9afea82671dc26d6152281de0acb87720f0c53b61e2b27d40434d30e525dd9e31fa671f
2018-11-06 11:48:14 +01:00
Martin Erlandsson 5a05aa2db2 Add metavar to match var name in help text + Change wording for better readability 2018-11-06 07:54:52 +01:00
MarcoFalke fa43626611
test_runner: Remove travis specific code 2018-11-01 18:03:26 -04:00
James O'Beirne d20a9fa13d tests: add tests for invalid P2P messages
E.g., ensure that we can't DoS a node by sending it a bunch of large,
unrecognized messages.
2018-11-01 14:52:49 -04:00
Chun Kuan Lee 4bd125fff0 tests: Print dots by default 2018-10-30 21:19:43 +08:00
MarcoFalke fa78a2fc67
[tests] Test that nodes respond to getdata with notfound
If a node has not announced a tx at all, then it should respond to
getdata messages for that tx with notfound, to avoid leaking tx
origination privacy.
2018-10-26 07:45:12 -04:00
MarcoFalke 6241eb3224
Merge #14504: tests: show the progress of functional tests
96c509e4d0 show the progress of functional test (Isidoro Ghezzi)

Pull request description:

  example: (added the progress index `n/m`)
  ```
  1/107 - wallet_hd.py passed, Duration: 27 s
  .........................................................................................
  2/107 - mining_getblocktemplate_longpoll.py passed, Duration: 72 s
  ..................................................................
  3/107 - feature_maxuploadtarget.py passed, Duration: 78 s
  ```

Tree-SHA512: 17b840048222e2c3676a92041b491521fee3b86049b2f2467a225aece40717732341801872d9867fcb7260e904e322c7184b76fca16d2dc687aa75dd741484ad
2018-10-24 11:14:09 -04:00
Isidoro Ghezzi 96c509e4d0
show the progress of functional test
example (added the progress index `n/m`)
```
1/107 - wallet_hd.py passed, Duration: 27 s
.........................................................................................
2/107 - mining_getblocktemplate_longpoll.py passed, Duration: 72 s
..................................................................
3/107 - feature_maxuploadtarget.py passed, Duration: 78 s
```

- clear dots line
```
$ test/functional/test_runner.py -t can_trash
Temporary test directory at can_trash/test_runner_₿_🏃_20181018_220600
1/105 - wallet_hd.py passed, Duration: 21 s
2/105 - mining_getblocktemplate_longpoll.py passed, Duration: 71 s
3/105 - feature_maxuploadtarget.py passed, Duration: 68 s
..................
```

- don't print the `dot` progressive if `--quiet`

- done_str
- nothing commit to check again travis tests
2018-10-22 01:12:42 +02:00
Chun Kuan Lee 369244f654 utils: Fix broken Windows filelock 2018-10-19 02:29:25 +08:00
John Newbery 42a995ae48 [tests] Remove rpc_zmq.py
rpc_zmq.py is racy and fails intermittently. Remove that test file and
move the getzmqnotifications RPC test into interface_zmq.py
2018-10-07 09:32:50 +09:00
marcoagner a6b5ec18ff
rpc: creates possibility to preserve labels on importprivkey
- changes importprivkey behavior to overwrite existent label if one
is passed and keep existing ones if no label is passed

- tests behavior of importprivkey on existing address labels and
different same key destination
2018-10-05 13:33:21 +01:00
Chun Kuan Lee c7b3e487f2 tests: exclude all tests with difference parameters 2018-09-26 04:25:31 +08:00
Chun Kuan Lee 2148c36b6e tests: Make it possible to run functional tests on Windows 2018-09-17 09:56:49 +08:00
Chun Kuan Lee c0d947d725 tests: Reorder tests and move most of extended tests up to normal tests 2018-09-16 08:06:11 +08:00
MarcoFalke fac9539836
qa: Run all tests even if wallet is not compiled 2018-09-10 17:53:21 -04:00
João Barbosa 6af6d9b23d test: Add tests for RPC help 2018-08-23 01:37:43 +01:00