mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-26 14:00:29 +01:00
scripted-diff: Rename mininode_lock to p2p_lock
-BEGIN VERIFY SCRIPT- sed -i 's/mininode_lock/p2p_lock/g' $(git grep -l "mininode_lock") -END VERIFY SCRIPT-
This commit is contained in:
@@ -91,7 +91,7 @@ from test_framework.mininode import (
|
||||
CBlockHeader,
|
||||
NODE_WITNESS,
|
||||
P2PInterface,
|
||||
mininode_lock,
|
||||
p2p_lock,
|
||||
MSG_BLOCK,
|
||||
msg_block,
|
||||
msg_getblocks,
|
||||
@@ -147,7 +147,7 @@ class BaseNode(P2PInterface):
|
||||
|
||||
def wait_for_block_announcement(self, block_hash, timeout=60):
|
||||
test_function = lambda: self.last_blockhash_announced == block_hash
|
||||
wait_until(test_function, timeout=timeout, lock=mininode_lock)
|
||||
wait_until(test_function, timeout=timeout, lock=p2p_lock)
|
||||
|
||||
def on_inv(self, message):
|
||||
self.block_announced = True
|
||||
@@ -163,7 +163,7 @@ class BaseNode(P2PInterface):
|
||||
self.last_blockhash_announced = message.headers[-1].sha256
|
||||
|
||||
def clear_block_announcements(self):
|
||||
with mininode_lock:
|
||||
with p2p_lock:
|
||||
self.block_announced = False
|
||||
self.last_message.pop("inv", None)
|
||||
self.last_message.pop("headers", None)
|
||||
@@ -174,8 +174,8 @@ class BaseNode(P2PInterface):
|
||||
"""Test whether the last headers announcements received are right.
|
||||
Headers may be announced across more than one message."""
|
||||
test_function = lambda: (len(self.recent_headers_announced) >= len(headers))
|
||||
wait_until(test_function, timeout=60, lock=mininode_lock)
|
||||
with mininode_lock:
|
||||
wait_until(test_function, timeout=60, lock=p2p_lock)
|
||||
with p2p_lock:
|
||||
assert_equal(self.recent_headers_announced, headers)
|
||||
self.block_announced = False
|
||||
self.last_message.pop("headers", None)
|
||||
@@ -186,9 +186,9 @@ class BaseNode(P2PInterface):
|
||||
inv should be a list of block hashes."""
|
||||
|
||||
test_function = lambda: self.block_announced
|
||||
wait_until(test_function, timeout=60, lock=mininode_lock)
|
||||
wait_until(test_function, timeout=60, lock=p2p_lock)
|
||||
|
||||
with mininode_lock:
|
||||
with p2p_lock:
|
||||
compare_inv = []
|
||||
if "inv" in self.last_message:
|
||||
compare_inv = [x.hash for x in self.last_message["inv"].inv]
|
||||
@@ -298,7 +298,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||
test_node.send_header_for_blocks([new_block])
|
||||
test_node.wait_for_getdata([new_block.sha256])
|
||||
test_node.send_and_ping(msg_block(new_block)) # make sure this block is processed
|
||||
wait_until(lambda: inv_node.block_announced, timeout=60, lock=mininode_lock)
|
||||
wait_until(lambda: inv_node.block_announced, timeout=60, lock=p2p_lock)
|
||||
inv_node.clear_block_announcements()
|
||||
test_node.clear_block_announcements()
|
||||
|
||||
@@ -456,7 +456,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||
test_node.send_header_for_blocks(blocks)
|
||||
test_node.sync_with_ping()
|
||||
# should not have received any getdata messages
|
||||
with mininode_lock:
|
||||
with p2p_lock:
|
||||
assert "getdata" not in test_node.last_message
|
||||
|
||||
# This time, direct fetch should work
|
||||
@@ -494,7 +494,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||
test_node.last_message.pop("getdata", None)
|
||||
test_node.send_header_for_blocks(blocks[0:1])
|
||||
test_node.sync_with_ping()
|
||||
with mininode_lock:
|
||||
with p2p_lock:
|
||||
assert "getdata" not in test_node.last_message
|
||||
|
||||
# Announcing one more block on fork should trigger direct fetch for
|
||||
@@ -513,7 +513,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||
test_node.last_message.pop("getdata", None)
|
||||
test_node.send_header_for_blocks(blocks[18:19])
|
||||
test_node.sync_with_ping()
|
||||
with mininode_lock:
|
||||
with p2p_lock:
|
||||
assert "getdata" not in test_node.last_message
|
||||
|
||||
self.log.info("Part 4: success!")
|
||||
@@ -536,7 +536,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||
block_time += 1
|
||||
height += 1
|
||||
# Send the header of the second block -> this won't connect.
|
||||
with mininode_lock:
|
||||
with p2p_lock:
|
||||
test_node.last_message.pop("getheaders", None)
|
||||
test_node.send_header_for_blocks([blocks[1]])
|
||||
test_node.wait_for_getheaders()
|
||||
@@ -559,7 +559,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||
|
||||
for i in range(1, MAX_UNCONNECTING_HEADERS):
|
||||
# Send a header that doesn't connect, check that we get a getheaders.
|
||||
with mininode_lock:
|
||||
with p2p_lock:
|
||||
test_node.last_message.pop("getheaders", None)
|
||||
test_node.send_header_for_blocks([blocks[i]])
|
||||
test_node.wait_for_getheaders()
|
||||
@@ -574,7 +574,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||
# before we get disconnected. Should be 5*MAX_UNCONNECTING_HEADERS
|
||||
for i in range(5 * MAX_UNCONNECTING_HEADERS - 1):
|
||||
# Send a header that doesn't connect, check that we get a getheaders.
|
||||
with mininode_lock:
|
||||
with p2p_lock:
|
||||
test_node.last_message.pop("getheaders", None)
|
||||
test_node.send_header_for_blocks([blocks[i % len(blocks)]])
|
||||
test_node.wait_for_getheaders()
|
||||
|
||||
Reference in New Issue
Block a user