mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
test: check misbehavior more independently in p2p_filter.py
This commit is contained in:
parent
65276c7737
commit
cd543d9193
1 changed files with 26 additions and 5 deletions
|
@ -64,19 +64,40 @@ class FilterTest(BitcoinTestFramework):
|
|||
def skip_test_if_missing_module(self):
|
||||
self.skip_if_no_wallet()
|
||||
|
||||
def run_test(self):
|
||||
filter_node = self.nodes[0].add_p2p_connection(FilterNode())
|
||||
|
||||
def test_size_limits(self, filter_node):
|
||||
self.log.info('Check that too large filter is rejected')
|
||||
with self.nodes[0].assert_debug_log(['Misbehaving']):
|
||||
filter_node.send_and_ping(msg_filterload(data=b'\xaa', nHashFuncs=MAX_BLOOM_HASH_FUNCS+1))
|
||||
with self.nodes[0].assert_debug_log(['Misbehaving']):
|
||||
filter_node.send_and_ping(msg_filterload(data=b'\xbb'*(MAX_BLOOM_FILTER_SIZE+1)))
|
||||
|
||||
self.log.info('Check that max size filter is accepted')
|
||||
with self.nodes[0].assert_debug_log([], unexpected_msgs=['Misbehaving']):
|
||||
filter_node.send_and_ping(msg_filterload(data=b'\xbb'*(MAX_BLOOM_FILTER_SIZE)))
|
||||
filter_node.send_and_ping(msg_filterclear())
|
||||
|
||||
self.log.info('Check that filter with too many hash functions is rejected')
|
||||
with self.nodes[0].assert_debug_log(['Misbehaving']):
|
||||
filter_node.send_and_ping(msg_filterload(data=b'\xaa', nHashFuncs=MAX_BLOOM_HASH_FUNCS+1))
|
||||
|
||||
self.log.info('Check that filter with max hash functions is accepted')
|
||||
with self.nodes[0].assert_debug_log([], unexpected_msgs=['Misbehaving']):
|
||||
filter_node.send_and_ping(msg_filterload(data=b'\xaa', nHashFuncs=MAX_BLOOM_HASH_FUNCS))
|
||||
# Don't send filterclear until next two filteradd checks are done
|
||||
|
||||
self.log.info('Check that max size data element to add to the filter is accepted')
|
||||
with self.nodes[0].assert_debug_log([], unexpected_msgs=['Misbehaving']):
|
||||
filter_node.send_and_ping(msg_filteradd(data=b'\xcc'*(MAX_SCRIPT_ELEMENT_SIZE)))
|
||||
|
||||
self.log.info('Check that too large data element to add to the filter is rejected')
|
||||
with self.nodes[0].assert_debug_log(['Misbehaving']):
|
||||
filter_node.send_and_ping(msg_filteradd(data=b'\xcc'*(MAX_SCRIPT_ELEMENT_SIZE+1)))
|
||||
|
||||
filter_node.send_and_ping(msg_filterclear())
|
||||
|
||||
def run_test(self):
|
||||
filter_node = self.nodes[0].add_p2p_connection(FilterNode())
|
||||
|
||||
self.test_size_limits(filter_node)
|
||||
|
||||
self.log.info('Add filtered P2P connection to the node')
|
||||
filter_node.send_and_ping(filter_node.watch_filter_init)
|
||||
filter_address = self.nodes[0].decodescript(filter_node.watch_script_pubkey)['addresses'][0]
|
||||
|
|
Loading…
Add table
Reference in a new issue