mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-09 20:59:38 +02:00
test: check for specific disconnect reasons in p2p_blockfilters.py
This ensures that the disconnect happens for the expected reason and also makes it easier to navigate between implementation and test code, i.e. both the questions "do we have test coverage for this disconnect?" (from an implementation reader's perspective) and "where is the code handling this disconnect?" (from a test reader's perspective) can be answered simply by grep-ping the corresponding debug message. Can be easiest reviewed with `-w` (to ignore whitespace changes).
This commit is contained in:
parent
d096743150
commit
63e90e1d3f
@ -211,38 +211,48 @@ class CompactFiltersTest(BitcoinTestFramework):
|
||||
]
|
||||
for request in requests:
|
||||
peer_1 = self.nodes[1].add_p2p_connection(P2PInterface())
|
||||
peer_1.send_message(request)
|
||||
peer_1.wait_for_disconnect()
|
||||
with self.nodes[1].assert_debug_log(expected_msgs=["requested unsupported block filter type"]):
|
||||
peer_1.send_message(request)
|
||||
peer_1.wait_for_disconnect()
|
||||
|
||||
self.log.info("Check that invalid requests result in disconnection.")
|
||||
requests = [
|
||||
# Requesting too many filters results in disconnection.
|
||||
msg_getcfilters(
|
||||
filter_type=FILTER_TYPE_BASIC,
|
||||
start_height=0,
|
||||
stop_hash=int(main_block_hash, 16),
|
||||
(
|
||||
msg_getcfilters(
|
||||
filter_type=FILTER_TYPE_BASIC,
|
||||
start_height=0,
|
||||
stop_hash=int(main_block_hash, 16),
|
||||
), "requested too many cfilters/cfheaders"
|
||||
),
|
||||
# Requesting too many filter headers results in disconnection.
|
||||
msg_getcfheaders(
|
||||
filter_type=FILTER_TYPE_BASIC,
|
||||
start_height=0,
|
||||
stop_hash=int(tip_hash, 16),
|
||||
(
|
||||
msg_getcfheaders(
|
||||
filter_type=FILTER_TYPE_BASIC,
|
||||
start_height=0,
|
||||
stop_hash=int(tip_hash, 16),
|
||||
), "requested too many cfilters/cfheaders"
|
||||
),
|
||||
# Requesting unknown filter type results in disconnection.
|
||||
msg_getcfcheckpt(
|
||||
filter_type=255,
|
||||
stop_hash=int(main_block_hash, 16),
|
||||
(
|
||||
msg_getcfcheckpt(
|
||||
filter_type=255,
|
||||
stop_hash=int(main_block_hash, 16),
|
||||
), "requested unsupported block filter type"
|
||||
),
|
||||
# Requesting unknown hash results in disconnection.
|
||||
msg_getcfcheckpt(
|
||||
filter_type=FILTER_TYPE_BASIC,
|
||||
stop_hash=123456789,
|
||||
(
|
||||
msg_getcfcheckpt(
|
||||
filter_type=FILTER_TYPE_BASIC,
|
||||
stop_hash=123456789,
|
||||
), "requested invalid block hash"
|
||||
),
|
||||
]
|
||||
for request in requests:
|
||||
for request, expected_log_msg in requests:
|
||||
peer_0 = self.nodes[0].add_p2p_connection(P2PInterface())
|
||||
peer_0.send_message(request)
|
||||
peer_0.wait_for_disconnect()
|
||||
with self.nodes[0].assert_debug_log(expected_msgs=[expected_log_msg]):
|
||||
peer_0.send_message(request)
|
||||
peer_0.wait_for_disconnect()
|
||||
|
||||
self.log.info("Test -peerblockfilters without -blockfilterindex raises an error")
|
||||
self.stop_node(0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user