24
24
assert_equal ,
25
25
)
26
26
27
- class CFiltersClient (P2PInterface ):
27
+ class FiltersClient (P2PInterface ):
28
28
def __init__ (self ):
29
29
super ().__init__ ()
30
30
# Store the cfilters received.
@@ -51,8 +51,8 @@ def set_test_params(self):
51
51
52
52
def run_test (self ):
53
53
# Node 0 supports COMPACT_FILTERS, node 1 does not.
54
- node0 = self .nodes [0 ].add_p2p_connection (CFiltersClient ())
55
- node1 = self .nodes [1 ].add_p2p_connection (CFiltersClient ())
54
+ peer_0 = self .nodes [0 ].add_p2p_connection (FiltersClient ())
55
+ peer_1 = self .nodes [1 ].add_p2p_connection (FiltersClient ())
56
56
57
57
# Nodes 0 & 1 share the same first 999 blocks in the chain.
58
58
self .nodes [0 ].generate (999 )
@@ -69,8 +69,8 @@ def run_test(self):
69
69
self .wait_until (lambda : self .nodes [1 ].getblockcount () == 2000 )
70
70
71
71
# Check that nodes have signalled NODE_COMPACT_FILTERS correctly.
72
- assert node0 .nServices & NODE_COMPACT_FILTERS != 0
73
- assert node1 .nServices & NODE_COMPACT_FILTERS == 0
72
+ assert peer_0 .nServices & NODE_COMPACT_FILTERS != 0
73
+ assert peer_1 .nServices & NODE_COMPACT_FILTERS == 0
74
74
75
75
# Check that the localservices is as expected.
76
76
assert int (self .nodes [0 ].getnetworkinfo ()['localservices' ], 16 ) & NODE_COMPACT_FILTERS != 0
@@ -81,8 +81,8 @@ def run_test(self):
81
81
filter_type = FILTER_TYPE_BASIC ,
82
82
stop_hash = int (stale_block_hash , 16 )
83
83
)
84
- node0 .send_and_ping (message = request )
85
- response = node0 .last_message ['cfcheckpt' ]
84
+ peer_0 .send_and_ping (message = request )
85
+ response = peer_0 .last_message ['cfcheckpt' ]
86
86
assert_equal (response .filter_type , request .filter_type )
87
87
assert_equal (response .stop_hash , request .stop_hash )
88
88
assert_equal (len (response .headers ), 1 )
@@ -100,8 +100,8 @@ def run_test(self):
100
100
filter_type = FILTER_TYPE_BASIC ,
101
101
stop_hash = int (tip_hash , 16 )
102
102
)
103
- node0 .send_and_ping (request )
104
- response = node0 .last_message ['cfcheckpt' ]
103
+ peer_0 .send_and_ping (request )
104
+ response = peer_0 .last_message ['cfcheckpt' ]
105
105
assert_equal (response .filter_type , request .filter_type )
106
106
assert_equal (response .stop_hash , request .stop_hash )
107
107
@@ -117,8 +117,8 @@ def run_test(self):
117
117
filter_type = FILTER_TYPE_BASIC ,
118
118
stop_hash = int (stale_block_hash , 16 )
119
119
)
120
- node0 .send_and_ping (request )
121
- response = node0 .last_message ['cfcheckpt' ]
120
+ peer_0 .send_and_ping (request )
121
+ response = peer_0 .last_message ['cfcheckpt' ]
122
122
123
123
stale_cfcheckpt = self .nodes [0 ].getblockfilter (stale_block_hash , 'basic' )['header' ]
124
124
assert_equal (
@@ -132,8 +132,8 @@ def run_test(self):
132
132
start_height = 1 ,
133
133
stop_hash = int (main_block_hash , 16 )
134
134
)
135
- node0 .send_and_ping (request )
136
- response = node0 .last_message ['cfheaders' ]
135
+ peer_0 .send_and_ping (request )
136
+ response = peer_0 .last_message ['cfheaders' ]
137
137
main_cfhashes = response .hashes
138
138
assert_equal (len (main_cfhashes ), 1000 )
139
139
assert_equal (
@@ -147,8 +147,8 @@ def run_test(self):
147
147
start_height = 1 ,
148
148
stop_hash = int (stale_block_hash , 16 )
149
149
)
150
- node0 .send_and_ping (request )
151
- response = node0 .last_message ['cfheaders' ]
150
+ peer_0 .send_and_ping (request )
151
+ response = peer_0 .last_message ['cfheaders' ]
152
152
stale_cfhashes = response .hashes
153
153
assert_equal (len (stale_cfhashes ), 1000 )
154
154
assert_equal (
@@ -163,9 +163,9 @@ def run_test(self):
163
163
start_height = 1 ,
164
164
stop_hash = int (stop_hash , 16 )
165
165
)
166
- node0 .send_message (request )
167
- node0 .sync_with_ping ()
168
- response = node0 .pop_cfilters ()
166
+ peer_0 .send_message (request )
167
+ peer_0 .sync_with_ping ()
168
+ response = peer_0 .pop_cfilters ()
169
169
assert_equal (len (response ), 10 )
170
170
171
171
self .log .info ("Check that cfilter responses are correct." )
@@ -182,9 +182,9 @@ def run_test(self):
182
182
start_height = 1000 ,
183
183
stop_hash = int (stale_block_hash , 16 )
184
184
)
185
- node0 .send_message (request )
186
- node0 .sync_with_ping ()
187
- response = node0 .pop_cfilters ()
185
+ peer_0 .send_message (request )
186
+ peer_0 .sync_with_ping ()
187
+ response = peer_0 .pop_cfilters ()
188
188
assert_equal (len (response ), 1 )
189
189
190
190
cfilter = response [0 ]
@@ -211,9 +211,9 @@ def run_test(self):
211
211
),
212
212
]
213
213
for request in requests :
214
- node1 = self .nodes [1 ].add_p2p_connection (P2PInterface ())
215
- node1 .send_message (request )
216
- node1 .wait_for_disconnect ()
214
+ peer_1 = self .nodes [1 ].add_p2p_connection (P2PInterface ())
215
+ peer_1 .send_message (request )
216
+ peer_1 .wait_for_disconnect ()
217
217
218
218
self .log .info ("Check that invalid requests result in disconnection." )
219
219
requests = [
@@ -241,9 +241,9 @@ def run_test(self):
241
241
),
242
242
]
243
243
for request in requests :
244
- node0 = self .nodes [0 ].add_p2p_connection (P2PInterface ())
245
- node0 .send_message (request )
246
- node0 .wait_for_disconnect ()
244
+ peer_0 = self .nodes [0 ].add_p2p_connection (P2PInterface ())
245
+ peer_0 .send_message (request )
246
+ peer_0 .wait_for_disconnect ()
247
247
248
248
def compute_last_header (prev_header , hashes ):
249
249
"""Compute the last filter header from a starting header and a sequence of filter hashes."""
0 commit comments