Commit Graph

235 Commits

Author SHA1 Message Date
UdjinM6
bad3243b8e
Bump mocktime before generating new blocks and generate a few blocks at the end of test_mempool_doublespend in p2p-instantsend.py (#3125)
* Cleanup p2p-instantsend.py

Bump mocktime before generating new blocks and generate a few blocks at the end of test_mempool_doublespend to clean things up

* Update test/functional/p2p-instantsend.py

Co-Authored-By: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
2019-10-01 17:15:28 +03:00
UdjinM6
82ebba18f4
Few fixes for wait_for_instantlock (#3123)
* Fix `wait_for_instantlock` to make it fail if instantlock wasn't aquired, use `wait_until`

Currently it simply returns False if islock failed but that's not the way we use it (we never check results).

* Wait for txes to propagate before checking for instantlock
2019-10-01 17:14:26 +03:00
UdjinM6
7ba50d93f6
Merge pull request #3116 from codablock/pr_backports_v15_v16_4
Backport remaining PRs which were also backported into Bitcoin 0.15
2019-10-01 17:13:15 +03:00
Alexander Block
2ca2138fc8
Whitelist nodes in llmq-dkgerrors.py (#3112)
This avoids banning due to invalid sigs
2019-10-01 09:25:12 +02:00
Alexander Block
a8fa5cff9c
Make orphan TX map limiting dependent on total TX size instead of TX count (#3121) 2019-09-30 15:34:13 +02:00
Wladimir J. van der Laan
d7119e6487 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
2019-09-30 08:33:16 +02:00
Alexander Block
55550b8dd7 Add missing comment
To align with bitcoin#11538
2019-09-30 08:33:16 +02:00
Wladimir J. van der Laan
46373f5ee2 Merge #11565: Make listsinceblock refuse unknown block hash
659b206 Make listsinceblock refuse unknown block hash (Russell Yanofsky)

Pull request description:

  Change suggested by @theuni  who noticed listsinceblock would ignore invalid block hashes causing it to return a completely unfiltered list of transactions.

Tree-SHA512: 3c8fb160265780d1334e856e853ab48e2e18372b8f1fc71ae480c3f45317048cc1fee0055d5c58031981a91b9c2bdbeb8e49a889d04ecba61729ce8109f2ce3f
2019-09-30 08:33:16 +02:00
Alexander Block
424ed32dbb Few assert_raises_jsonrpc -> assert_raises_rpc_error fixes 2019-09-29 12:48:49 +02:00
Alexander Block
438a972a72 Fix minchainwork.py 2019-09-29 12:42:14 +02:00
Wladimir J. van der Laan
7d21a78fa1 Merge #11531: Check that new headers are not a descendant of an invalid block (more effeciently)
f3d4adf Make p2p-acceptablock not an extended test (Matt Corallo)
00dcda6 [qa] test that invalid blocks on an invalid chain get a disconnect (Matt Corallo)
015a525 Reject headers building on invalid chains by tracking invalidity (Matt Corallo)
932f118 Accept unrequested blocks with work equal to our tip (Matt Corallo)
3d9c70c Stop always storing blocks from whitelisted peers (Matt Corallo)
3b4ac43 Rewrite p2p-acceptblock in preparation for slight behavior changes (Matt Corallo)

Pull request description:

  @sdaftuar pointed out that the version in #11487 was somewhat DoS-able as someone could feed you a valid chain that forked off the the last checkpoint block and force you to do lots of work just walking backwards across blocks for each new block they gave you. We came up with a few proposals but settled on the one implemented here as likely the simplest without obvious DoS issues. It uses our existing on-load mapBlockIndex walk to make sure everything that descends from an invalid block is marked as such, and then simply caches blocks which we attempted to connect but which were found to be invalid. To avoid DoS issues during IBD, this will need to depend on #11458.

  Includes tests from #11487.

Tree-SHA512: 46aff8332908e122dae72ceb5fe8cd241902c2281a87f58a5fb486bf69d46458d84a096fdcb5f3e8e07fbcf7466232b10c429f4d67855425f11b38ac0bf612e1
2019-09-29 12:42:14 +02:00
Wladimir J. van der Laan
b451094e2e Merge #11490: Disconnect from outbound peers with bad headers chains
e065249 Add unit test for outbound peer eviction (Suhas Daftuar)
5a6d00c Permit disconnection of outbound peers on bad/slow chains (Suhas Daftuar)
c60fd71 Disconnecting from bad outbound peers in IBD (Suhas Daftuar)

Pull request description:

  The first commit will disconnect an outbound peer that serves us a headers chain with insufficient work while we're in IBD.

  The second commit introduces a way to disconnect outbound peers whose chains fall out of sync with ours:

  For a given outbound peer, we check whether their best known block (which is known from the blocks they announce to us) has at least as much work as our tip.  If it doesn't, we set a 20 minute timeout, and if we still haven't heard about a block with as much work as our tip had when we set the timeout, then we send a single getheaders message, and wait 2 more minutes.  If after two minutes their best known block has insufficient work, we disconnect that peer.

  We protect 4 of our outbound peers (who provide some "good" headers chains, ie a chain with at least as much work as our tip at some point) from being subject to this logic, to prevent excessive network topology changes as a result of this algorithm, while still ensuring that we have a reasonable number of nodes not known to be on bogus chains.

  We also don't require our peers to be on the same chain as us, to prevent accidental partitioning of the network in the event of a chain split.  Note that if our peers are ever on a more work chain than our tip, then we will download and validate it, and then either reorg to it, or learn of a consensus incompatibility with that peer and disconnect.  This PR is designed to protect against peers that are on a less work chain which we may never try to download and validate.

Tree-SHA512: 2e0169a1dd8a7fb95980573ac4a201924bffdd724c19afcab5efcef076fdbe1f2cec7dc5f5d7e0a6327216f56d3828884f73642e00c8534b56ec2bb4c854a656
2019-09-29 12:42:14 +02:00
Wladimir J. van der Laan
35d60de2b5 Merge #11458: Don't process unrequested, low-work blocks
01b52ce Add comment explaining forced processing of compact blocks (Suhas Daftuar)
08fd822 qa: add test for minchainwork use in acceptblock (Suhas Daftuar)
ce8cd7a Don't process unrequested, low-work blocks (Suhas Daftuar)

Pull request description:

  A peer could try to waste our resources by sending us unrequested blocks with
  low work (eg to fill up our disk).  Since e265200 we no longer request blocks until we
  know we're on a chain with more than nMinimumChainWork (our anti-DoS
  threshold), but we would still process unrequested blocks that had more work
  than our tip (which generally has low-work during IBD), even though we may not
  yet have found a headers chain with sufficient work.

  Fix this and add a test.

Tree-SHA512: 1a4fb0bbd78054b84683f995c8c3194dd44fa914dc351ae4379c7c1a6f83224f609f8b9c2d9dde28741426c6af008ffffea836d21aa31a5ebaa00f8e0f81229e
2019-09-29 12:42:14 +02:00
Wladimir J. van der Laan
9938dd83d4 Merge #10357: Allow setting nMinimumChainWork on command line
eac64bb7a [qa] Test nMinimumChainWork (Suhas Daftuar)
0311836f6 Allow setting nMinimumChainWork on command line (Suhas Daftuar)

Pull request description:

  As discussed briefly here: https://botbot.me/freenode/bitcoin-core-dev/2017-02-28/?msg=81712308&page=4

  This adds a hidden command line option for setting `nMinimumChainWork`, which allows us to test this parameter in our functional tests, as well as allowing for niche use cases like syncing nodes that are otherwise disconnected from the network.

  See also #10345, which proposes a new use of `nMinimumChainWork`.

Tree-SHA512: fe4d8f4f289697615c98d8760f1cc74c076110310ea0b5b875fcab78c127da9195b4eb84148aebacc7606c246e5773d3f13bd5d9559d0a8bffac20a3a28c62df
2019-09-29 12:42:14 +02:00
Wladimir J. van der Laan
f18fa576b9 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
2019-09-29 12:42:14 +02:00
Wladimir J. van der Laan
b155130224 Merge #11476: Avoid opening copied wallet databases simultaneously
478a89c Avoid opening copied wallet databases simultaneously (Russell Yanofsky)

Pull request description:

  Make sure wallet databases have unique fileids. If they don't, throw an error. BDB caches do not work properly when more than one open database has the same fileid, because values written to one database may show up in reads to other databases.

  Bitcoin will never create different databases with the same fileid, but users can create them by manually copying database files.

  BDB caching bug was reported by @dooglus in https://github.com/bitcoin/bitcoin/issues/11429

Tree-SHA512: e7635dc81a181801f42324b72fe9e0a2a7dd00b1dcf5abcbf27fa50938eb9a1fc3065c2321326c3456c48c29ae6504353b02f3d46e6eb2f7b09e46d8fe24388d
2019-09-29 12:42:14 +02:00
MarcoFalke
b6116b20c0 Merge #11376: Ensure backupwallet fails when attempting to backup to source file
5d465e396 Ensure backupwallet fails when attempting to backup to source file (Tomas van der Wansem)

Pull request description:

  Previous behaviour was to destroy the wallet (to zero-length)

  This fixes #11375

Tree-SHA512: bfd1738659b15e3f23b6bbdf55ec12269c62c820bf701daec19500b52bd5845bb5516733c6f76f36197eb155182a8a35dc239ad4de2ef1e59bbb0f124a455759
2019-09-29 12:42:14 +02:00
Alexander Block
fa57eafd00 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-
2019-09-29 12:42:13 +02:00
John Newbery
58a946c6bc [tests] do not allow assert_raises_message to be called with JSONRPCException 2019-09-29 12:40:33 +02:00
John Newbery
3602d31395 [tests] remove direct testing on JSONRPCException from individual test cases 2019-09-29 12:40:33 +02:00
UdjinM6
3712f8d053
Merge pull request #3111 from codablock/pr_backports_v15_v16_3
Backport same PRs as done in bitcoin#11447
2019-09-28 00:47:12 +03:00
UdjinM6
ed82988445
Merge pull request #3110 from codablock/pr_backports_v15_v16_2
Backport same PRs as done in bitcoin#11445
2019-09-28 00:46:43 +03:00
UdjinM6
43b7c31d96 Wait for the actual best block chainlock in llmq-chainlocks.py (#3109)
* Wait for the actual best block chainlock in llmq-chainlocks.py

* Increase timeout for the final wait_for_chainlock
2019-09-27 20:21:22 +02:00
UdjinM6
22ac6ba4ef Make sure chainlocks and blocks are propagated in llmq-is-cl-conflicts.py before moving to next steps (#3108)
* Make sure chainlocks and blocks are propagated in llmq-is-cl-conflicts.py before moving to next steps

Add few comments here and there to clarify what's actually going on under the hood

* Simplify
2019-09-27 20:20:22 +02:00
Alexander Block
f76d53d730 Dashify a few strings in tests 2019-09-26 15:50:24 +02:00
Alexander Block
1c65e08595 Fix "os" import in wallet-dump.py
This is now needed as we don't use "from test_framework.util import *" anymore.
2019-09-25 10:45:53 +02:00
MarcoFalke
f616989371 Merge #11483: Fix importmulti bug when importing an already imported key
a44a21517 Fix importmulti bug when importing an already imported key (Pedro Branco)

Pull request description:

  This PR fixes a bug in `importmulti` RPC call where it returns an invalid response when importing an already imported key.

  Before:
  ```sh
  ❯ bitcoin-cli -regtest importmulti '[{ "keys": ["cNcMUunXhVK1dXJ5riixtpYSxPXZnUAMGS4vpzwChdKmYY3Rz99v"], "scriptPubKey": { "address": "n4YZAf4WE2XF3t4BfeYS2nHAhb8CVx91BR" }, "timestamp": 1507655239 }]'
  [{ "success": true }]

  ❯ bitcoin-cli -regtest importmulti '[{ "keys": ["cNcMUunXhVK1dXJ5riixtpYSxPXZnUAMGS4vpzwChdKmYY3Rz99v"], "scriptPubKey": { "address": "n4YZAf4WE2XF3t4BfeYS2nHAhb8CVx91BR" }, "timestamp": 1507655239 }]' '{ "rescan": false }'
  [ false ]

  ❯ bitcoin-cli -regtest importmulti '[{ "keys": ["cNcMUunXhVK1dXJ5riixtpYSxPXZnUAMGS4vpzwChdKmYY3Rz99v"], "scriptPubKey": { "address": "n4YZAf4WE2XF3t4BfeYS2nHAhb8CVx91BR" }, "timestamp": 1507655239 }]' '{ "rescan": true }'
  error code: -1
  error message:
  JSON value is not a boolean as expected
  ```

  After this fix:
  ```sh
  ❯ bitcoin-cli -rpcuser=u -rpcpassword=p -regtest importmulti '[{ "keys": ["cNcMUunXhVK1dXJ5riixtpYSxPXZnUAMGS4vpzwChdKmYY3Rz99v"], "scriptPubKey": { "address": "n4YZAf4WE2XF3t4BfeYS2nHAhb8CVx91BR" }, "timestamp": 1507655139 }]'
  [{ "success": true }]

  ❯ bitcoin-cli -rpcuser=u -rpcpassword=p -regtest importmulti '[{ "keys": ["cNcMUunXhVK1dXJ5riixtpYSxPXZnUAMGS4vpzwChdKmYY3Rz99v"], "scriptPubKey": { "address": "n4YZAf4WE2XF3t4BfeYS2nHAhb8CVx91BR" }, "timestamp": 1507655139 }]'
  [{ "success": false, "error": { "code": -4, "message": "The wallet already contains the private key for this address or script" } }]
  ```

Tree-SHA512: 4acebdfb7d0ebd7cd48e943b93ed1cec072db1ace5c42b3f5cc225603764b6e804e4b823b0710965826aafc2f0c615c53d5aefcfdb9bc9c379f5221b798a318c
2019-09-25 10:33:21 +02:00
MarcoFalke
f8f55c25c8 Merge #11465: rpc: Update named args documentation for importprivkey
aa57590d7 Update importprivkey named args documentation (Dusty Williams)

Pull request description:

  Addresses issue #11462 by updating the documentation for the importprivkey arguments to the correct names, and updates the functional test importprunedfunds.py to use named arguments when calling importprivkey.

Tree-SHA512: 64e14bf89c8c6eec9c37f6ec0c9fc0012fdb035d9ec32cd652110c75abaa922ec5c7523d6ec5098c8a7b42124159b5e330e070974eb79b8b92816f8d61074523
2019-09-25 10:33:21 +02:00
Wladimir J. van der Laan
9e3cb7599e Merge #9937: rpc: Prevent dumpwallet from overwriting files
0cd9273 rpc: Prevent `dumpwallet` from overwriting files (Wladimir J. van der Laan)

Pull request description:

  Prevent arbitrary files from being overwritten by `dumpwallet`. There have been reports that users have overwritten wallet files this way. It may also avoid other security issues.

  Fixes #9934. Adds mention to release notes and adds a test.

Tree-SHA512: 268c98636d40924d793b55a685a0b419bafd834ad369edaec08227ebe26ed4470ddea73008d1c4beb10ea445db1b0bb8e3546ba8fc2d1a411ebd4a0de8ce9120
2019-09-25 10:33:21 +02:00
Alexander Block
b93785d8dc Fix maxuploadtarget.py
start_node() calls TestNode.start, which internally uses the old mocktime
value. We need to pass the current value manually.
2019-09-24 17:47:35 +02:00
Alexander Block
e37bd6d96c Fix zmq_test.py 2019-09-24 17:47:35 +02:00
Alexander Block
7a44dc1956 Fix hash256() imports
Importing util.* results in the wrong version of hash256 being imported
2019-09-24 17:47:35 +02:00
Alexander Block
7b80cc8040 Allow ignoring of known messages in mininode.py
Instead of throwing an exception.
2019-09-24 17:47:35 +02:00
Alexander Block
9ef73e6add Fix mining.py 2019-09-24 17:47:35 +02:00
MarcoFalke
c8e17f1c37 Merge #11433: qa: Restore bitcoin-util-test py2 compatibility
fafff1220 qa: Restore bitcoin-util-test py2 compatibility (MarcoFalke)

Pull request description:

  Currently `./configure && make check` will look for python3, then python2. As long as we support python2 (and use it as fallback), `make check` should run fine with both python2 and python3.

  Fixes #11352 by @Zenitur

Tree-SHA512: a335ebdd224328d6f924fe52a9b97de196926476c9ee04ce3280743ea93bcae355eb2d5d4bed4050c01b2e904105595eac7db2eaa9307207581caa0a98ebcc0b
2019-09-24 17:47:35 +02:00
Wladimir J. van der Laan
377a8fae2e Merge #11399: Fix bip68-sequence rpc test
49f869f Fix bip68-sequence rpc test (Johnson Lau)

Pull request description:

  The test mined 1 extra block for the ACTIVE state. Test added to catch the right moment of LOCKED_IN->ACTIVE transaction

Tree-SHA512: a42477cf0b137e7e3b7c6c7b2530101cfad4e4f59866170b8fc0d655c43b3144aad6bca4287a4a8df4c28d7cf08d3f8df166975ad2e8dcb7d2cc15de60cf11cd
2019-09-24 17:47:35 +02:00
Suhas Daftuar
8855f4b97d qa: Treat mininode p2p exceptions as fatal 2019-09-24 17:47:35 +02:00
MarcoFalke
7ddd169212 Merge #10552: [Test] Tests for zmqpubrawtx and zmqpubrawblock
d3677ab75 Tests for zmqpubrawtx and zmqpubrawblock (Andrew Chow)

Pull request description:

Tree-SHA512: 9e367fd8936514bfb567ef3f3d83770d374287354b59c9187e844056dd086e8aa2de32ce55d35486cecd706e7c93cd1c1e2709ee82d3dddb805827be8d2bcb14
2019-09-24 17:47:35 +02:00
MarcoFalke
bc5918aa1b Merge #11310: [tests] Test listwallets RPC
fb1f32582 Add listwallets RPC test to multiwallet.py (Cristian Mircea Messel)

Pull request description:

Tree-SHA512: acf3377ac86fcc4e7fe36e3b97120f3e51b7bd94cb7136ce22e7e2043ce8ec5555c246c41f8501272aeb1e56ad16d05eb8c4eeb6acf3315a218c1ed4e5844871
2019-09-24 17:47:35 +02:00
MarcoFalke
797b474608 Merge #11230: [tests] fixup dbcrash interaction with add_nodes()
8fdb6f912 [tests] fixup dbcrash interaction with add_nodes() (John Newbery)

Pull request description:

  Another conflict with #11121. Apologies - this is entirely my fault. I didn't run the extended test suite after rebasing on master.

  @MarcoFalke @sdaftuar

Tree-SHA512: eefce1d1c63dc4a63c5e030a541e046ad4832e8a709c0a8aad40ffdc4712b2065486778b406dfa57cfd34e66db86064278ee3fea8f2c2afd2390772875e6fa3e
2019-09-24 17:47:35 +02:00
João Barbosa
102c3f2cec [test] Replace check_output with low level version 2019-09-24 17:47:35 +02:00
João Barbosa
654815456e [test] Add assert_raises_process_error to assert process errors 2019-09-24 17:47:35 +02:00
João Barbosa
6245ce95e1 [test] Add support for custom arguments to TestNodeCLI 2019-09-24 17:47:35 +02:00
João Barbosa
d446cc57aa [test] Improve assert_raises_jsonrpc docstring 2019-09-24 17:47:35 +02:00
Alexander Block
b9599c297f Partially backport bitcoin#10838 for bitcoin_cli.py
This allows further backports while postponing removal of "getinfo"
2019-09-24 17:47:35 +02:00
MarcoFalke
ded01879d0 Merge #11067: [qa] TestNode: Add wait_until_stopped helper method
faa8d9581 [qa] TestNode: Add wait_until_stopped helper method (MarcoFalke)

Pull request description:

  This adds a helper method `wait_until_stopped` to the `TestNode` class. This should prevent numerous `time.sleep()` over all places.

  Additionally, the timeout behavior is restored. (Was removed by the introduction of `TestNode`.)
  This should prevent tests from running indefinitely by accident.

Tree-SHA512: 7133fc64d55711869c4e372e9d30625c98f1237fb3578c24a26900d9319831f10eb95592d7b08e536fa706158dffb0abf9197f11c5d9ef605c880628e1a6533f
2019-09-24 17:47:35 +02:00
Wladimir J. van der Laan
d643ada802 Merge #11241: [tests] Improve signmessages functional test
b3d6fc654 Improve signmessages functional test (Cristian Mircea Messel)

Pull request description:

  This patch improves branch coverage of the test, making sure a message can not be verified with the wrong address or signature.

Tree-SHA512: 984eb66af8ba1caaccfb8ce2c5cc89c634a50d2fa587bfaf6e196aaf5b89e77accd76522ac33105621ead795521ec6d90f0afcb3b6064d22e53b54d2b41c7991
2019-09-24 17:47:35 +02:00
Pieter Wuille
b9ce8480df Merge #11215: [tests] fixups from set_test_params()
3918d93f3 [tests] fixups from set_test_params() (John Newbery)

Pull request description:

  #11121 had a silent merge conflict in `bitcoin_cli.py`. This fixes it.

  Also fixes a comment in `example_test.py`

Tree-SHA512: f22a645c51c9aeda005526338ad6f2ee07f2bab172847fc54f51fecf1c79e778970be61e5e637d4e0aba3a02e5aba0737b0b57f1bc11a514a1acd94c221b54d6
2019-09-24 17:47:35 +02:00
Alexander Block
a304d4d47c Fix DashTestFramework and tests depending on it 2019-09-24 17:47:35 +02:00
Alexander Block
ac0f483d85 Fix issues with set_test_params and start/stop_node 2019-09-24 17:47:35 +02:00