18
18
from test_framework .mininode import (
19
19
CInv ,
20
20
NetworkThread ,
21
- NodeConnCB ,
21
+ P2PInterface ,
22
22
mininode_lock ,
23
23
msg_block ,
24
24
msg_getdata ,
25
+ NODE_NETWORK ,
25
26
)
26
27
from test_framework .test_framework import BitcoinTestFramework
27
28
from test_framework .util import (
30
31
wait_until ,
31
32
)
32
33
33
- # NodeConnCB is a class containing callbacks to be executed when a P2P
34
- # message is received from the node-under-test. Subclass NodeConnCB and
34
+ # P2PInterface is a class containing callbacks to be executed when a P2P
35
+ # message is received from the node-under-test. Subclass P2PInterface and
35
36
# override the on_*() methods if you need custom behaviour.
36
- class BaseNode (NodeConnCB ):
37
+ class BaseNode (P2PInterface ):
37
38
def __init__ (self ):
38
- """Initialize the NodeConnCB
39
+ """Initialize the P2PInterface
39
40
40
41
Used to inialize custom properties for the Node that aren't
41
- included by default in the base class. Be aware that the NodeConnCB
42
+ included by default in the base class. Be aware that the P2PInterface
42
43
base class already stores a counter for each P2P message type and the
43
44
last received message of each type, which should be sufficient for the
44
45
needs of most tests.
@@ -174,7 +175,7 @@ def run_test(self):
174
175
block = create_block (self .tip , create_coinbase (height ), self .block_time )
175
176
block .solve ()
176
177
block_message = msg_block (block )
177
- # Send message is used to send a P2P message to the node over our NodeConn connection
178
+ # Send message is used to send a P2P message to the node over our P2PInterface
178
179
self .nodes [0 ].p2p .send_message (block_message )
179
180
self .tip = block .sha256
180
181
blocks .append (self .tip )
@@ -199,12 +200,12 @@ def run_test(self):
199
200
self .nodes [2 ].p2p .send_message (getdata_request )
200
201
201
202
# wait_until() will loop until a predicate condition is met. Use it to test properties of the
202
- # NodeConnCB objects.
203
+ # P2PInterface objects.
203
204
wait_until (lambda : sorted (blocks ) == sorted (list (self .nodes [2 ].p2p .block_receive_map .keys ())), timeout = 5 , lock = mininode_lock )
204
205
205
206
self .log .info ("Check that each block was received only once" )
206
- # The network thread uses a global lock on data access to the NodeConn objects when sending and receiving
207
- # messages. The test thread should acquire the global lock before accessing any NodeConn data to avoid locking
207
+ # The network thread uses a global lock on data access to the P2PConnection objects when sending and receiving
208
+ # messages. The test thread should acquire the global lock before accessing any P2PConnection data to avoid locking
208
209
# and synchronization issues. Note wait_until() acquires this global lock when testing the predicate.
209
210
with mininode_lock :
210
211
for block in self .nodes [2 ].p2p .block_receive_map .values ():
0 commit comments