aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_filter.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2020-04-16 18:48:32 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2020-04-20 18:22:21 +0200
commitc7437185589926ec8def2af6bede6a407b3d2e4a (patch)
tree629a14263638c5b030e9d76afab328c85c7b7790 /test/functional/p2p_filter.py
parentfc00e651e407200da1eb0ae61f6448e22d1b6d8d (diff)
downloadbitcoin-c7437185589926ec8def2af6bede6a407b3d2e4a.tar.xz
test: add further BIP37 size limit checks to p2p_filter.py
also unified method of detecting misbehaviour (using assert_debug_log instead of checking peer's banscore)
Diffstat (limited to 'test/functional/p2p_filter.py')
-rwxr-xr-xtest/functional/p2p_filter.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/test/functional/p2p_filter.py b/test/functional/p2p_filter.py
index 3879f4ffe6..83c019bc3d 100755
--- a/test/functional/p2p_filter.py
+++ b/test/functional/p2p_filter.py
@@ -8,6 +8,8 @@ Test BIP 37
from test_framework.messages import (
CInv,
+ MAX_BLOOM_FILTER_SIZE,
+ MAX_BLOOM_HASH_FUNCS,
MSG_BLOCK,
MSG_FILTERED_BLOCK,
msg_filteradd,
@@ -16,6 +18,7 @@ from test_framework.messages import (
msg_getdata,
)
from test_framework.mininode import P2PInterface
+from test_framework.script import MAX_SCRIPT_ELEMENT_SIZE
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
@@ -67,7 +70,13 @@ class FilterTest(BitcoinTestFramework):
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=51, nTweak=0, nFlags=1))
+ 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 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)))
self.log.info('Add filtered P2P connection to the node')
filter_node.send_and_ping(filter_node.watch_filter_init)
@@ -116,10 +125,9 @@ class FilterTest(BitcoinTestFramework):
assert not filter_node.merkleblock_received
assert not filter_node.tx_received
- self.log.info('Check that sending "filteradd" if no filter is set is treated as misbehavior (+100)')
- assert_equal(self.nodes[0].getpeerinfo()[0]['banscore'], 0)
- filter_node.send_and_ping(msg_filteradd(data=b'letsmisbehave'))
- assert_equal(self.nodes[0].getpeerinfo()[0]['banscore'], 100)
+ self.log.info('Check that sending "filteradd" if no filter is set is treated as misbehavior')
+ with self.nodes[0].assert_debug_log(['Misbehaving']):
+ filter_node.send_and_ping(msg_filteradd(data=b'letsmisbehave'))
self.log.info("Check that division-by-zero remote crash bug [CVE-2013-5700] is fixed")
filter_node.send_and_ping(msg_filterload(data=b'', nHashFuncs=1))