Page MenuHomePhabricator

D9575.diff
No OneTemporary

D9575.diff

diff --git a/doc/functional-tests.md b/doc/functional-tests.md
--- a/doc/functional-tests.md
+++ b/doc/functional-tests.md
@@ -362,8 +362,8 @@
#### [test_framework/util.py](/test/functional/test_framework/util.py)
Generally useful functions.
-#### [test_framework/mininode.py](/test/functional/test_framework/mininode.py)
-Basic code to support P2P connectivity to a bitcoind.
+#### [test_framework/p2p.py](/test/functional/test_framework/p2p.py)
+Test objects for interacting with a bitcoind node over the p2p interface.
#### [test_framework/script.py](/test/functional/test_framework/script.py)
Utilities for manipulating transaction scripts (originally from python-bitcoinlib)
diff --git a/test/functional/example_test.py b/test/functional/example_test.py
--- a/test/functional/example_test.py
+++ b/test/functional/example_test.py
@@ -176,8 +176,8 @@
height = self.nodes[0].getblockcount()
- for i in range(10):
- # Use the mininode and blocktools functionality to manually build a block
+ for _ in range(10):
+ # Use the blocktools functionality to manually build a block.
# Calling the generate() rpc is easier, but this allows us to exactly
# control the blocks and transactions.
block = create_block(
diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py
--- a/test/functional/feature_block.py
+++ b/test/functional/feature_block.py
@@ -46,7 +46,7 @@
from data import invalid_txs
-# Use this class for tests that require behavior other than normal "mininode" behavior.
+# Use this class for tests that require behavior other than normal p2p behavior.
# For now, it is used to serialize a bloated varint (b64).
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
--- a/test/functional/test_framework/messages.py
+++ b/test/functional/test_framework/messages.py
@@ -37,7 +37,7 @@
MIN_VERSION_SUPPORTED = 60001
# past bip-31 for ping/pong
MY_VERSION = 70014
-MY_SUBVERSION = b"/python-mininode-tester:0.0.3/"
+MY_SUBVERSION = b"/python-p2p-tester:0.0.3/"
# from version 70001 onwards, fRelay should be appended to version
# messages (BIP37)
MY_RELAY = 1
diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py
--- a/test/functional/test_framework/p2p.py
+++ b/test/functional/test_framework/p2p.py
@@ -4,10 +4,14 @@
# Copyright (c) 2010-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
-"""Bitcoin P2P network half-a-node.
-
-This python code was modified from ArtForz' public domain half-a-node, as
-found in the mini-node branch of http://github.com/jgarzik/pynode.
+"""Test objects for interacting with a bitcoind node over the p2p protocol.
+
+The P2PInterface objects interact with the bitcoind nodes under test using the
+node's p2p interface. They can be used to send messages to the node, and
+callbacks can be registered that execute when messages are received from the
+node. Messages are sent to/received from the node on an asyncio event loop.
+State held inside the objects must be guarded by the p2p_lock to avoid data
+races between the main testing thread and the event loop.
P2PConnection: A low-level connection object to a node's P2P interface
P2PInterface: A high-level interface object for communicating to a node over P2P
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -704,17 +704,17 @@
assert self.p2ps, self._node_msg("No p2p connection")
return self.p2ps[0]
- def num_connected_mininodes(self):
+ def num_test_p2p_connections(self):
"""Return number of test framework p2p connections to the node."""
return len([peer for peer in self.getpeerinfo()
- if peer['subver'] == MY_SUBVERSION])
+ if peer['subver'] == MY_SUBVERSION])
def disconnect_p2ps(self):
"""Close all p2p connections to the node."""
for p in self.p2ps:
p.peer_disconnect()
del self.p2ps[:]
- wait_until(lambda: self.num_connected_mininodes() == 0)
+ wait_until(lambda: self.num_test_p2p_connections() == 0)
class TestNodeCLIAttr:

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 12:37 (26 m, 53 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187863
Default Alt Text
D9575.diff (4 KB)

Event Timeline