@@ -64,19 +64,40 @@ def set_test_params(self):
64
64
def skip_test_if_missing_module (self ):
65
65
self .skip_if_no_wallet ()
66
66
67
- def run_test (self ):
68
- filter_node = self .nodes [0 ].add_p2p_connection (FilterNode ())
69
-
67
+ def test_size_limits (self , filter_node ):
70
68
self .log .info ('Check that too large filter is rejected' )
71
- with self .nodes [0 ].assert_debug_log (['Misbehaving' ]):
72
- filter_node .send_and_ping (msg_filterload (data = b'\xaa ' , nHashFuncs = MAX_BLOOM_HASH_FUNCS + 1 ))
73
69
with self .nodes [0 ].assert_debug_log (['Misbehaving' ]):
74
70
filter_node .send_and_ping (msg_filterload (data = b'\xbb ' * (MAX_BLOOM_FILTER_SIZE + 1 )))
75
71
72
+ self .log .info ('Check that max size filter is accepted' )
73
+ with self .nodes [0 ].assert_debug_log ([], unexpected_msgs = ['Misbehaving' ]):
74
+ filter_node .send_and_ping (msg_filterload (data = b'\xbb ' * (MAX_BLOOM_FILTER_SIZE )))
75
+ filter_node .send_and_ping (msg_filterclear ())
76
+
77
+ self .log .info ('Check that filter with too many hash functions is rejected' )
78
+ with self .nodes [0 ].assert_debug_log (['Misbehaving' ]):
79
+ filter_node .send_and_ping (msg_filterload (data = b'\xaa ' , nHashFuncs = MAX_BLOOM_HASH_FUNCS + 1 ))
80
+
81
+ self .log .info ('Check that filter with max hash functions is accepted' )
82
+ with self .nodes [0 ].assert_debug_log ([], unexpected_msgs = ['Misbehaving' ]):
83
+ filter_node .send_and_ping (msg_filterload (data = b'\xaa ' , nHashFuncs = MAX_BLOOM_HASH_FUNCS ))
84
+ # Don't send filterclear until next two filteradd checks are done
85
+
86
+ self .log .info ('Check that max size data element to add to the filter is accepted' )
87
+ with self .nodes [0 ].assert_debug_log ([], unexpected_msgs = ['Misbehaving' ]):
88
+ filter_node .send_and_ping (msg_filteradd (data = b'\xcc ' * (MAX_SCRIPT_ELEMENT_SIZE )))
89
+
76
90
self .log .info ('Check that too large data element to add to the filter is rejected' )
77
91
with self .nodes [0 ].assert_debug_log (['Misbehaving' ]):
78
92
filter_node .send_and_ping (msg_filteradd (data = b'\xcc ' * (MAX_SCRIPT_ELEMENT_SIZE + 1 )))
79
93
94
+ filter_node .send_and_ping (msg_filterclear ())
95
+
96
+ def run_test (self ):
97
+ filter_node = self .nodes [0 ].add_p2p_connection (FilterNode ())
98
+
99
+ self .test_size_limits (filter_node )
100
+
80
101
self .log .info ('Add filtered P2P connection to the node' )
81
102
filter_node .send_and_ping (filter_node .watch_filter_init )
82
103
filter_address = self .nodes [0 ].decodescript (filter_node .watch_script_pubkey )['addresses' ][0 ]
0 commit comments