aboutsummaryrefslogtreecommitdiff
path: root/test/functional/example_test.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2017-11-30 17:58:58 -0500
committerMarcoFalke <falke.marco@gmail.com>2017-11-30 18:01:51 -0500
commit13e31dd6548d64a5992f439e74bb424bf88aca04 (patch)
treee6ffed59782502920d90a4189be727f5cf6ad239 /test/functional/example_test.py
parentfbce66a982679b5409a295be5c99a2eef429cabf (diff)
parent873beca6deda119077f53921f0d19c3ebfc7cc44 (diff)
Merge #11791: [tests] Rename NodeConn and NodeConnCB
873beca6d [tests] Rename NodeConn and NodeConnCB (John Newbery) Pull request description: Final step in #11518 NodeConn -> P2PConnection NodeConnCB -> P2PInterface This is basically just a rename. Should be an easy review. Tree-SHA512: fe1204b2b3d8182c5e324ffa7cb4099a47ef8536380e0bb9d37a5fccf76a24f548d1f1a7988ab8f830986a3058b670696de3fc891af5e5f75dbeb4e3273005d7
Diffstat (limited to 'test/functional/example_test.py')
-rwxr-xr-xtest/functional/example_test.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/test/functional/example_test.py b/test/functional/example_test.py
index 54cabee51c..289fa248e0 100755
--- a/test/functional/example_test.py
+++ b/test/functional/example_test.py
@@ -18,10 +18,11 @@ from test_framework.blocktools import (create_block, create_coinbase)
from test_framework.mininode import (
CInv,
NetworkThread,
- NodeConnCB,
+ P2PInterface,
mininode_lock,
msg_block,
msg_getdata,
+ NODE_NETWORK,
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
@@ -30,15 +31,15 @@ from test_framework.util import (
wait_until,
)
-# NodeConnCB is a class containing callbacks to be executed when a P2P
-# message is received from the node-under-test. Subclass NodeConnCB and
+# P2PInterface is a class containing callbacks to be executed when a P2P
+# message is received from the node-under-test. Subclass P2PInterface and
# override the on_*() methods if you need custom behaviour.
-class BaseNode(NodeConnCB):
+class BaseNode(P2PInterface):
def __init__(self):
- """Initialize the NodeConnCB
+ """Initialize the P2PInterface
Used to inialize custom properties for the Node that aren't
- included by default in the base class. Be aware that the NodeConnCB
+ included by default in the base class. Be aware that the P2PInterface
base class already stores a counter for each P2P message type and the
last received message of each type, which should be sufficient for the
needs of most tests.
@@ -174,7 +175,7 @@ class ExampleTest(BitcoinTestFramework):
block = create_block(self.tip, create_coinbase(height), self.block_time)
block.solve()
block_message = msg_block(block)
- # Send message is used to send a P2P message to the node over our NodeConn connection
+ # Send message is used to send a P2P message to the node over our P2PInterface
self.nodes[0].p2p.send_message(block_message)
self.tip = block.sha256
blocks.append(self.tip)
@@ -199,12 +200,12 @@ class ExampleTest(BitcoinTestFramework):
self.nodes[2].p2p.send_message(getdata_request)
# wait_until() will loop until a predicate condition is met. Use it to test properties of the
- # NodeConnCB objects.
+ # P2PInterface objects.
wait_until(lambda: sorted(blocks) == sorted(list(self.nodes[2].p2p.block_receive_map.keys())), timeout=5, lock=mininode_lock)
self.log.info("Check that each block was received only once")
- # The network thread uses a global lock on data access to the NodeConn objects when sending and receiving
- # messages. The test thread should acquire the global lock before accessing any NodeConn data to avoid locking
+ # The network thread uses a global lock on data access to the P2PConnection objects when sending and receiving
+ # messages. The test thread should acquire the global lock before accessing any P2PConnection data to avoid locking
# and synchronization issues. Note wait_until() acquires this global lock when testing the predicate.
with mininode_lock:
for block in self.nodes[2].p2p.block_receive_map.values():