Commit graph

58 commits

Author SHA1 Message Date
practicalswift 68400d8b96 tests: Use explicit imports 2018-08-13 14:13:39 +02:00
MarcoFalke a04888a075
Merge #13915: [qa] Add test for max number of entries in locator
fa85c985ed qa: Add p2p_invalid_locator test (MarcoFalke)

Pull request description:

  Should not be merged *before* #13907

Tree-SHA512: a67ca407854c421ed20a184d0b0dc90085aed3e3431d9652a107fa3022244767e67f67e50449b7e95721f56906836b134615875f28a21e8a012eb22cfe6a66a5
2018-08-11 06:59:14 -04:00
MarcoFalke fa85c985ed
qa: Add p2p_invalid_locator test 2018-08-10 14:09:19 -04:00
DrahtBot eb7daf4d60 Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
Daniel Kraft 64b9f27e0e Skip is_closing() check when not available.
https://github.com/bitcoin/bitcoin/pull/13715 introduced a new check
for _transport.is_closing() in mininode's P2PConnection's.  This function
is only available from Python 3.4.4, though, while Bitcoin is supposed
to support all Python 3.4 versions.

In this change, we make the check conditional on is_closing() being
available.  If it is not, then we revert to the behaviour before the
check was introduced; this means that
https://github.com/bitcoin/bitcoin/issues/13579 is not fixed for old
systems, but at least the tests work as they used to do before.

This includes a small refactoring from a one-line lambda to an
inline function, because this makes the code easier to read with more
and more conditions being added.

Fixes https://github.com/bitcoin/bitcoin/issues/13745.
2018-07-23 15:44:58 +02:00
marcoagner ea5340c9d2
tests: fixes mininode's P2PConnection sending messages on closing transport
- checks if  _transport.is_closing() (added in python3.4.4/python3.5.1)
before attempting to send messages on P2PConnection's send_message
method.
2018-07-19 12:24:31 +01:00
MarcoFalke fa87da2f17
qa: Avoid start/stop of the network thread mid-test 2018-06-25 14:06:41 -04:00
MarcoFalke fa1eac9cdb
[qa] mininode: Expose connection state through is_connected 2018-06-22 12:00:00 -04:00
MarcoFalke fa02c5b38b
qa: Clarify documentation for send_txs_and_test 2018-04-24 13:39:08 -04:00
MarcoFalke fadfbd33ab
qa: Add test for orphan handling 2018-04-16 23:11:27 -04:00
John Newbery 89fe5feea2 [tests] Stop feature_block.py from blowing up memory.
The new P2PDataStore class was sending full blocks in headers messages,
which meant that calls to send_blocks_and_test() would blow up memory if
called with a large number of blocks. Fix that by only sending headers
in headers messages.
2018-04-02 15:40:40 -04:00
Dimitris Apostolou 4d9b4256d8 Fix typos 2018-03-21 08:34:44 +02: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
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
Akira Takizawa 595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09: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
John Newbery 873beca6de [tests] Rename NodeConn and NodeConnCB
NodeConn -> P2PConnection
NodeConnCB -> P2PInterface
2017-11-29 17:14:48 -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
John Newbery f2ae6f32a6 [tests] Remove mininode periodic (half-hour) ping messages 2017-11-23 10:03:22 -05: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
MarcoFalke fafdad0d46 qa: Remove unused NodeConn members 2017-11-13 17:43:39 -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
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
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
MarcoFalke fafa003970 qa: Remove never used return value of sync_with_ping 2017-10-13 15:29:18 +02:00
Jim Posen eff4bd8ab2 [test] P2P functional test for certain fingerprinting protections 2017-10-03 10:28:00 -07:00
MarcoFalke ff4cd6075b
Merge #11319: [qa] Fix error introduced into p2p-segwit.py, and prevent future similar errors
f97ab35fa qa: Fix bug introduced in p2p-segwit.py (Suhas Daftuar)
a7820422e qa: Treat mininode p2p exceptions as fatal (Suhas Daftuar)

Pull request description:

  #11121 inadvertently broke the constructor for the `TestNode()` object in `p2p-segwit.py`, silently breaking at least one of the tests.

  Although the python code was raising exceptions due to a `TestNode()` object not existing (or having the right type), mininode was masking these from anyone running the test through the test_runner (like travis), because it catches all exceptions during message delivery and just prints a log message and continues.  Such "graceful" handling of errors is almost certainly something we don't want in our test suite, so the first commit here attempts to prevent that type of failure from ever being masked.

  The second commit fixes the particular bug in `p2p-segwit.py`.

Tree-SHA512: b6646e3cb1e05c35c28e8899c44104bf2e2d0384643ca87042ab7f6ec0960d89f5bf25a7b95bab6e32d401c20a6018226160500f6ddceb923e81ffb04adb4f2f
2017-09-29 20:23:59 +02:00
MarcoFalke 4ce2f3d0d3
Merge #11323: mininode: add an optimistic write and disable nagle
1817398b3 mininode: add an optimistic write and disable nagle (Cory Fields)

Pull request description:

  Disclaimer: I'm not familiar with asyncore, so I'm unclear how safe this is. It works for me (tm).

  Because the poll/select loop may pause for 100msec before actually doing a send, and we have no way to force the loop awake, try sending from the calling thread if the queue is empty.

  Also, disable nagle as all sends should be either full messages or unfinished sends.

  This shaves an average of ~1 minute or so off of my accumulated runtime, and 10-15 seconds off of actual runtime.

Tree-SHA512: 6b61b8058e621dacf0b4dd353c10e3666fbda0691440eb6ebc432491ebada80a781dcd09291bf03e70112a41d3c2a0c91775ed08824b79bf8d0ebed11595c28b
2017-09-18 21:10:21 +02:00
Cory Fields 1817398b39 mininode: add an optimistic write and disable nagle
Because the poll/select loop may pause for 100msec before actually doing a
send, and we have no way to force the loop awake, try sending from the calling
thread if the queue is empty.

Also, disable nagle as all sends should be either full messages or unfinished
sends.

This shaves an average of ~1 minute or so off of my accumulated runtime, and
10-15 seconds off of actual runtime.
2017-09-13 13:31:44 -04:00
MarcoFalke 42973f8344
Merge #11078: [tests] Make p2p-leaktests.py more robust
0063d2c3d [tests] Make p2p-leaktests.py more robust (John Newbery)

Pull request description:

  There has been an example of p2p-leaktests.py failing on travis in the new service bits test (introduced in #11001 . It appeared to me that the previous p2p connections had not been fully disconnected before attempting to add new p2p connections.

  I've added a sleep and restarted the NetworkThread, but I don't know whether this will fix the problem, since I'm unable to reproduce the failure locally.

  @MarcoFalke - not sure what you want to do here? I don't think this change could make things any worse.

Tree-SHA512: f5427c26267185a903c9b75bb3925bf153b8afce70c8e493bf8f585f57d809d20643b4ee69081300b211d22e960242aecc3d719f4ddd230aa08fdc5484b55055
2017-09-13 18:54:50 +02:00
Suhas Daftuar a7820422e0 qa: Treat mininode p2p exceptions as fatal 2017-09-13 09:17:15 -04:00
practicalswift 2e6080bbf3 Remove unused variables and/or function calls 2017-08-28 15:18:14 +02:00
John Newbery 0063d2c3dc [tests] Make p2p-leaktests.py more robust 2017-08-24 17:28:13 -04:00
MarcoFalke 08ce33f8e9 qa: Move wait_until to util 2017-08-17 15:17:09 +02:00
John Newbery 5e35cd94c1 [tests] Test disconnecting unsupported service bits logic.
In v0.15, we disconnect nodes that send us version messages with
unsupported service bits (1 << 5 and 1 << 7). This commit adds a test
that bitcoind will disconnect those nodes before August 1st 2018, and won't
disconnect those nodes after August 1st 2018.
2017-08-07 11:37:54 -04:00
Dimitris Tsapakidis 0a5a6b90bc Fixed multiple typos
A few "a->an" and "an->a".
"Shows, if the supplied default SOCKS5 proxy" -> "Shows if the supplied default SOCKS5 proxy". Change made on 3 occurrences.
"without fully understanding the ramification of a command" -> "without fully understanding the ramifications of a command".
Removed duplicate words such as "the the".
2017-06-22 19:18:10 +03:00
John Newbery b0bfa233a1 [tests] Make wait_until timeout 60 seconds by default 2017-05-09 08:55:13 -04:00
John Newbery 3e3c22f09d [tests] fix wait_for_inv() 2017-05-03 09:08:29 -04:00