scripted-diff: Renames

-BEGIN VERIFY SCRIPT-

 ren() { sed -i "s/\<$1\>/$2/g" test/functional/p2p_blockfilters.py ; }

 # Rename from "node" to "peer" to avoid confusion with self.nodes
 ren node0 peer_0
 ren node1 peer_1

 # Remove the confusing "C" prefix
 ren CFiltersClient FiltersClient

-END VERIFY SCRIPT-
pull/22311/head
MarcoFalke 3 years ago
parent 327e2691f6
commit facd97ae0f
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

@ -24,7 +24,7 @@ from test_framework.util import (
assert_equal, assert_equal,
) )
class CFiltersClient(P2PInterface): class FiltersClient(P2PInterface):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
# Store the cfilters received. # Store the cfilters received.
@ -51,8 +51,8 @@ class CompactFiltersTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
# Node 0 supports COMPACT_FILTERS, node 1 does not. # Node 0 supports COMPACT_FILTERS, node 1 does not.
node0 = self.nodes[0].add_p2p_connection(CFiltersClient()) peer_0 = self.nodes[0].add_p2p_connection(FiltersClient())
node1 = self.nodes[1].add_p2p_connection(CFiltersClient()) peer_1 = self.nodes[1].add_p2p_connection(FiltersClient())
# Nodes 0 & 1 share the same first 999 blocks in the chain. # Nodes 0 & 1 share the same first 999 blocks in the chain.
self.nodes[0].generate(999) self.nodes[0].generate(999)
@ -69,8 +69,8 @@ class CompactFiltersTest(BitcoinTestFramework):
self.wait_until(lambda: self.nodes[1].getblockcount() == 2000) self.wait_until(lambda: self.nodes[1].getblockcount() == 2000)
# Check that nodes have signalled NODE_COMPACT_FILTERS correctly. # Check that nodes have signalled NODE_COMPACT_FILTERS correctly.
assert node0.nServices & NODE_COMPACT_FILTERS != 0 assert peer_0.nServices & NODE_COMPACT_FILTERS != 0
assert node1.nServices & NODE_COMPACT_FILTERS == 0 assert peer_1.nServices & NODE_COMPACT_FILTERS == 0
# Check that the localservices is as expected. # Check that the localservices is as expected.
assert int(self.nodes[0].getnetworkinfo()['localservices'], 16) & NODE_COMPACT_FILTERS != 0 assert int(self.nodes[0].getnetworkinfo()['localservices'], 16) & NODE_COMPACT_FILTERS != 0
@ -81,8 +81,8 @@ class CompactFiltersTest(BitcoinTestFramework):
filter_type=FILTER_TYPE_BASIC, filter_type=FILTER_TYPE_BASIC,
stop_hash=int(stale_block_hash, 16) stop_hash=int(stale_block_hash, 16)
) )
node0.send_and_ping(message=request) peer_0.send_and_ping(message=request)
response = node0.last_message['cfcheckpt'] response = peer_0.last_message['cfcheckpt']
assert_equal(response.filter_type, request.filter_type) assert_equal(response.filter_type, request.filter_type)
assert_equal(response.stop_hash, request.stop_hash) assert_equal(response.stop_hash, request.stop_hash)
assert_equal(len(response.headers), 1) assert_equal(len(response.headers), 1)
@ -100,8 +100,8 @@ class CompactFiltersTest(BitcoinTestFramework):
filter_type=FILTER_TYPE_BASIC, filter_type=FILTER_TYPE_BASIC,
stop_hash=int(tip_hash, 16) stop_hash=int(tip_hash, 16)
) )
node0.send_and_ping(request) peer_0.send_and_ping(request)
response = node0.last_message['cfcheckpt'] response = peer_0.last_message['cfcheckpt']
assert_equal(response.filter_type, request.filter_type) assert_equal(response.filter_type, request.filter_type)
assert_equal(response.stop_hash, request.stop_hash) assert_equal(response.stop_hash, request.stop_hash)
@ -117,8 +117,8 @@ class CompactFiltersTest(BitcoinTestFramework):
filter_type=FILTER_TYPE_BASIC, filter_type=FILTER_TYPE_BASIC,
stop_hash=int(stale_block_hash, 16) stop_hash=int(stale_block_hash, 16)
) )
node0.send_and_ping(request) peer_0.send_and_ping(request)
response = node0.last_message['cfcheckpt'] response = peer_0.last_message['cfcheckpt']
stale_cfcheckpt = self.nodes[0].getblockfilter(stale_block_hash, 'basic')['header'] stale_cfcheckpt = self.nodes[0].getblockfilter(stale_block_hash, 'basic')['header']
assert_equal( assert_equal(
@ -132,8 +132,8 @@ class CompactFiltersTest(BitcoinTestFramework):
start_height=1, start_height=1,
stop_hash=int(main_block_hash, 16) stop_hash=int(main_block_hash, 16)
) )
node0.send_and_ping(request) peer_0.send_and_ping(request)
response = node0.last_message['cfheaders'] response = peer_0.last_message['cfheaders']
main_cfhashes = response.hashes main_cfhashes = response.hashes
assert_equal(len(main_cfhashes), 1000) assert_equal(len(main_cfhashes), 1000)
assert_equal( assert_equal(
@ -147,8 +147,8 @@ class CompactFiltersTest(BitcoinTestFramework):
start_height=1, start_height=1,
stop_hash=int(stale_block_hash, 16) stop_hash=int(stale_block_hash, 16)
) )
node0.send_and_ping(request) peer_0.send_and_ping(request)
response = node0.last_message['cfheaders'] response = peer_0.last_message['cfheaders']
stale_cfhashes = response.hashes stale_cfhashes = response.hashes
assert_equal(len(stale_cfhashes), 1000) assert_equal(len(stale_cfhashes), 1000)
assert_equal( assert_equal(
@ -163,9 +163,9 @@ class CompactFiltersTest(BitcoinTestFramework):
start_height=1, start_height=1,
stop_hash=int(stop_hash, 16) stop_hash=int(stop_hash, 16)
) )
node0.send_message(request) peer_0.send_message(request)
node0.sync_with_ping() peer_0.sync_with_ping()
response = node0.pop_cfilters() response = peer_0.pop_cfilters()
assert_equal(len(response), 10) assert_equal(len(response), 10)
self.log.info("Check that cfilter responses are correct.") self.log.info("Check that cfilter responses are correct.")
@ -182,9 +182,9 @@ class CompactFiltersTest(BitcoinTestFramework):
start_height=1000, start_height=1000,
stop_hash=int(stale_block_hash, 16) stop_hash=int(stale_block_hash, 16)
) )
node0.send_message(request) peer_0.send_message(request)
node0.sync_with_ping() peer_0.sync_with_ping()
response = node0.pop_cfilters() response = peer_0.pop_cfilters()
assert_equal(len(response), 1) assert_equal(len(response), 1)
cfilter = response[0] cfilter = response[0]
@ -211,9 +211,9 @@ class CompactFiltersTest(BitcoinTestFramework):
), ),
] ]
for request in requests: for request in requests:
node1 = self.nodes[1].add_p2p_connection(P2PInterface()) peer_1 = self.nodes[1].add_p2p_connection(P2PInterface())
node1.send_message(request) peer_1.send_message(request)
node1.wait_for_disconnect() peer_1.wait_for_disconnect()
self.log.info("Check that invalid requests result in disconnection.") self.log.info("Check that invalid requests result in disconnection.")
requests = [ requests = [
@ -241,9 +241,9 @@ class CompactFiltersTest(BitcoinTestFramework):
), ),
] ]
for request in requests: for request in requests:
node0 = self.nodes[0].add_p2p_connection(P2PInterface()) peer_0 = self.nodes[0].add_p2p_connection(P2PInterface())
node0.send_message(request) peer_0.send_message(request)
node0.wait_for_disconnect() peer_0.wait_for_disconnect()
def compute_last_header(prev_header, hashes): def compute_last_header(prev_header, hashes):
"""Compute the last filter header from a starting header and a sequence of filter hashes.""" """Compute the last filter header from a starting header and a sequence of filter hashes."""

Loading…
Cancel
Save