Skip to content

Commit fa1668b

Browse files
author
MarcoFalke
committed
test: Run pep-8
Can be reviewed with --word-diff-regex=.
1 parent facd97a commit fa1668b

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

test/functional/p2p_blockfilters.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def on_cfilter(self, message):
3939
"""Store cfilters received in a list."""
4040
self.cfilters.append(message)
4141

42+
4243
class CompactFiltersTest(BitcoinTestFramework):
4344
def set_test_params(self):
4445
self.setup_clean_chain = True
@@ -79,7 +80,7 @@ def run_test(self):
7980
self.log.info("get cfcheckpt on chain to be re-orged out.")
8081
request = msg_getcfcheckpt(
8182
filter_type=FILTER_TYPE_BASIC,
82-
stop_hash=int(stale_block_hash, 16)
83+
stop_hash=int(stale_block_hash, 16),
8384
)
8485
peer_0.send_and_ping(message=request)
8586
response = peer_0.last_message['cfcheckpt']
@@ -98,7 +99,7 @@ def run_test(self):
9899
tip_hash = self.nodes[0].getbestblockhash()
99100
request = msg_getcfcheckpt(
100101
filter_type=FILTER_TYPE_BASIC,
101-
stop_hash=int(tip_hash, 16)
102+
stop_hash=int(tip_hash, 16),
102103
)
103104
peer_0.send_and_ping(request)
104105
response = peer_0.last_message['cfcheckpt']
@@ -109,59 +110,59 @@ def run_test(self):
109110
tip_cfcheckpt = self.nodes[0].getblockfilter(tip_hash, 'basic')['header']
110111
assert_equal(
111112
response.headers,
112-
[int(header, 16) for header in (main_cfcheckpt, tip_cfcheckpt)]
113+
[int(header, 16) for header in (main_cfcheckpt, tip_cfcheckpt)],
113114
)
114115

115116
self.log.info("Check that peers can fetch cfcheckpt on stale chain.")
116117
request = msg_getcfcheckpt(
117118
filter_type=FILTER_TYPE_BASIC,
118-
stop_hash=int(stale_block_hash, 16)
119+
stop_hash=int(stale_block_hash, 16),
119120
)
120121
peer_0.send_and_ping(request)
121122
response = peer_0.last_message['cfcheckpt']
122123

123124
stale_cfcheckpt = self.nodes[0].getblockfilter(stale_block_hash, 'basic')['header']
124125
assert_equal(
125126
response.headers,
126-
[int(header, 16) for header in (stale_cfcheckpt,)]
127+
[int(header, 16) for header in (stale_cfcheckpt, )],
127128
)
128129

129130
self.log.info("Check that peers can fetch cfheaders on active chain.")
130131
request = msg_getcfheaders(
131132
filter_type=FILTER_TYPE_BASIC,
132133
start_height=1,
133-
stop_hash=int(main_block_hash, 16)
134+
stop_hash=int(main_block_hash, 16),
134135
)
135136
peer_0.send_and_ping(request)
136137
response = peer_0.last_message['cfheaders']
137138
main_cfhashes = response.hashes
138139
assert_equal(len(main_cfhashes), 1000)
139140
assert_equal(
140141
compute_last_header(response.prev_header, response.hashes),
141-
int(main_cfcheckpt, 16)
142+
int(main_cfcheckpt, 16),
142143
)
143144

144145
self.log.info("Check that peers can fetch cfheaders on stale chain.")
145146
request = msg_getcfheaders(
146147
filter_type=FILTER_TYPE_BASIC,
147148
start_height=1,
148-
stop_hash=int(stale_block_hash, 16)
149+
stop_hash=int(stale_block_hash, 16),
149150
)
150151
peer_0.send_and_ping(request)
151152
response = peer_0.last_message['cfheaders']
152153
stale_cfhashes = response.hashes
153154
assert_equal(len(stale_cfhashes), 1000)
154155
assert_equal(
155156
compute_last_header(response.prev_header, response.hashes),
156-
int(stale_cfcheckpt, 16)
157+
int(stale_cfcheckpt, 16),
157158
)
158159

159160
self.log.info("Check that peers can fetch cfilters.")
160161
stop_hash = self.nodes[0].getblockhash(10)
161162
request = msg_getcfilters(
162163
filter_type=FILTER_TYPE_BASIC,
163164
start_height=1,
164-
stop_hash=int(stop_hash, 16)
165+
stop_hash=int(stop_hash, 16),
165166
)
166167
peer_0.send_message(request)
167168
peer_0.sync_with_ping()
@@ -180,7 +181,7 @@ def run_test(self):
180181
request = msg_getcfilters(
181182
filter_type=FILTER_TYPE_BASIC,
182183
start_height=1000,
183-
stop_hash=int(stale_block_hash, 16)
184+
stop_hash=int(stale_block_hash, 16),
184185
)
185186
peer_0.send_message(request)
186187
peer_0.sync_with_ping()
@@ -197,17 +198,17 @@ def run_test(self):
197198
requests = [
198199
msg_getcfcheckpt(
199200
filter_type=FILTER_TYPE_BASIC,
200-
stop_hash=int(main_block_hash, 16)
201+
stop_hash=int(main_block_hash, 16),
201202
),
202203
msg_getcfheaders(
203204
filter_type=FILTER_TYPE_BASIC,
204205
start_height=1000,
205-
stop_hash=int(main_block_hash, 16)
206+
stop_hash=int(main_block_hash, 16),
206207
),
207208
msg_getcfilters(
208209
filter_type=FILTER_TYPE_BASIC,
209210
start_height=1000,
210-
stop_hash=int(main_block_hash, 16)
211+
stop_hash=int(main_block_hash, 16),
211212
),
212213
]
213214
for request in requests:
@@ -221,18 +222,18 @@ def run_test(self):
221222
msg_getcfilters(
222223
filter_type=FILTER_TYPE_BASIC,
223224
start_height=0,
224-
stop_hash=int(main_block_hash, 16)
225+
stop_hash=int(main_block_hash, 16),
225226
),
226227
# Requesting too many filter headers results in disconnection.
227228
msg_getcfheaders(
228229
filter_type=FILTER_TYPE_BASIC,
229230
start_height=0,
230-
stop_hash=int(tip_hash, 16)
231+
stop_hash=int(tip_hash, 16),
231232
),
232233
# Requesting unknown filter type results in disconnection.
233234
msg_getcfcheckpt(
234235
filter_type=255,
235-
stop_hash=int(main_block_hash, 16)
236+
stop_hash=int(main_block_hash, 16),
236237
),
237238
# Requesting unknown hash results in disconnection.
238239
msg_getcfcheckpt(
@@ -245,12 +246,14 @@ def run_test(self):
245246
peer_0.send_message(request)
246247
peer_0.wait_for_disconnect()
247248

249+
248250
def compute_last_header(prev_header, hashes):
249251
"""Compute the last filter header from a starting header and a sequence of filter hashes."""
250252
header = ser_uint256(prev_header)
251253
for filter_hash in hashes:
252254
header = hash256(ser_uint256(filter_hash) + header)
253255
return uint256_from_str(header)
254256

257+
255258
if __name__ == '__main__':
256259
CompactFiltersTest().main()

0 commit comments

Comments
 (0)