Commit Graph

13 Commits

Author SHA1 Message Date
Akira Takizawa 595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09:00
John Newbery 873beca6de [tests] Rename NodeConn and NodeConnCB
NodeConn -> P2PConnection
NodeConnCB -> P2PInterface
2017-11-29 17:14:48 -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
MarcoFalke fafdad0d46 qa: Remove unused NodeConn members 2017-11-13 17:43:39 -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
Pieter Wuille d618458184 Have SegWit active by default 2017-11-06 19:29:20 -08:00
John Newbery f893085325 [tests] Don't subclass from object for Python 3 2017-10-16 21:46:23 -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
MarcoFalke 08ce33f8e9 qa: Move wait_until to util 2017-08-17 15:17:09 +02:00
John Newbery 2a52ae63bf Remove duplicate method definitions in NodeConnCB subclasses
All Node classes in individual test cases subclass from NodeConnCB. Many
have duplicate definitions for methods that are defined in the base
class. This commit removes those duplicate definitions.

This commit removes ~290 lines of duplicate code.
2017-04-18 17:20:09 -04:00
John Newbery 52e15aa4d0 Adds helper functions to NodeConnCB
This commit adds some helper functions to NodeConnCB which are useful
for many tests:

- NodeConnCB now keeps track of the number of each message type that
it's received and the most recent message of each type. Many tests
assert on the most recent block, tx or reject message.
- NodeConnCB now keeps track of its connection state by setting a
connected boolean in on_open() and on_close()
- NodeConnCB now has wait_for_block, wait_for_getdata,
wait_for_getheaders, wait_for_inv and wait_for_verack methods

I have updated the individual test cases to make sure that there are no
namespace problems that cause them to fail with these new definitions.
Future commits will remove the duplicate code.
2017-04-18 15:25:01 -04:00
John Newbery 159fe88abf Remove SingleNodeConnCB
This commit merges the NodeConnCB and SingleNodeConnCB into a single
class (called NodeConnCB). The original intent for the NodeConnCB was to
be able to have a python 'mininode' connect to multiple running
bitcoinds. This has never been used and can be achieved more easily by
having multiple NodeConns backed by a common datastore if it is ever
needed.

The changes in mininode.py are just code moves (and merging the two
classes into a single class). The code changes in the individual test
cases are changing the subclasses to subclass from NodeConnCB instead of
SingleNodeConnCB. There is a lot of duplicate code in the subclasses
that can be removed in future commits.
2017-03-28 14:16:21 -04:00
John Newbery c28ee91db0 Rename rpc-tests directory to functional 2017-03-20 10:40:31 -04:00