|
8 | 8 |
|
9 | 9 | from test_framework.messages import (
|
10 | 10 | CInv,
|
| 11 | + MAX_BLOOM_FILTER_SIZE, |
| 12 | + MAX_BLOOM_HASH_FUNCS, |
11 | 13 | MSG_BLOCK,
|
12 | 14 | MSG_FILTERED_BLOCK,
|
13 | 15 | msg_filteradd,
|
|
16 | 18 | msg_getdata,
|
17 | 19 | )
|
18 | 20 | from test_framework.mininode import P2PInterface
|
| 21 | +from test_framework.script import MAX_SCRIPT_ELEMENT_SIZE |
19 | 22 | from test_framework.test_framework import BitcoinTestFramework
|
20 | 23 | from test_framework.util import assert_equal
|
21 | 24 |
|
@@ -67,7 +70,13 @@ def run_test(self):
|
67 | 70 |
|
68 | 71 | self.log.info('Check that too large filter is rejected')
|
69 | 72 | with self.nodes[0].assert_debug_log(['Misbehaving']):
|
70 |
| - filter_node.send_and_ping(msg_filterload(data=b'\xaa', nHashFuncs=51, nTweak=0, nFlags=1)) |
| 73 | + filter_node.send_and_ping(msg_filterload(data=b'\xaa', nHashFuncs=MAX_BLOOM_HASH_FUNCS+1)) |
| 74 | + with self.nodes[0].assert_debug_log(['Misbehaving']): |
| 75 | + filter_node.send_and_ping(msg_filterload(data=b'\xbb'*(MAX_BLOOM_FILTER_SIZE+1))) |
| 76 | + |
| 77 | + self.log.info('Check that too large data element to add to the filter is rejected') |
| 78 | + with self.nodes[0].assert_debug_log(['Misbehaving']): |
| 79 | + filter_node.send_and_ping(msg_filteradd(data=b'\xcc'*(MAX_SCRIPT_ELEMENT_SIZE+1))) |
71 | 80 |
|
72 | 81 | self.log.info('Add filtered P2P connection to the node')
|
73 | 82 | filter_node.send_and_ping(filter_node.watch_filter_init)
|
@@ -116,10 +125,9 @@ def run_test(self):
|
116 | 125 | assert not filter_node.merkleblock_received
|
117 | 126 | assert not filter_node.tx_received
|
118 | 127 |
|
119 |
| - self.log.info('Check that sending "filteradd" if no filter is set is treated as misbehavior (+100)') |
120 |
| - assert_equal(self.nodes[0].getpeerinfo()[0]['banscore'], 0) |
121 |
| - filter_node.send_and_ping(msg_filteradd(data=b'letsmisbehave')) |
122 |
| - assert_equal(self.nodes[0].getpeerinfo()[0]['banscore'], 100) |
| 128 | + self.log.info('Check that sending "filteradd" if no filter is set is treated as misbehavior') |
| 129 | + with self.nodes[0].assert_debug_log(['Misbehaving']): |
| 130 | + filter_node.send_and_ping(msg_filteradd(data=b'letsmisbehave')) |
123 | 131 |
|
124 | 132 | self.log.info("Check that division-by-zero remote crash bug [CVE-2013-5700] is fixed")
|
125 | 133 | filter_node.send_and_ping(msg_filterload(data=b'', nHashFuncs=1))
|
|
0 commit comments