Skip to content

Commit e564cab

Browse files
committed
test: remove magic number when checking for blocks that have arrived
getpeerinfo provides a list of blocks that are inflight, which can be used instead.
1 parent 64b24b5 commit e564cab

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

test/functional/p2p_ibd_stalling.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ def run_test(self):
8080
peers[-1].block_store = block_dict
8181
peers[-1].send_and_ping(headers_message)
8282

83-
# Need to wait until 1023 blocks are received - the magic total bytes number is a workaround in lack of an rpc
84-
# returning the number of downloaded (but not connected) blocks.
85-
bytes_recv = 172761 if not self.options.v2transport else 169692
86-
self.wait_until(lambda: self.total_bytes_recv_for_blocks() == bytes_recv)
83+
# Wait until all blocks are received (except for stall_block), so that no other blocks are in flight.
84+
self.wait_until(lambda: sum(len(peer['inflight']) for peer in node.getpeerinfo()) == 1)
8785

8886
self.all_sync_send_with_ping(peers)
8987
# If there was a peer marked for stalling, it would get disconnected
@@ -144,12 +142,6 @@ def run_test(self):
144142
self.log.info("Check that all outstanding blocks get connected")
145143
self.wait_until(lambda: node.getblockcount() == NUM_BLOCKS)
146144

147-
def total_bytes_recv_for_blocks(self):
148-
total = 0
149-
for info in self.nodes[0].getpeerinfo():
150-
if ("block" in info["bytesrecv_per_msg"].keys()):
151-
total += info["bytesrecv_per_msg"]["block"]
152-
return total
153145

154146
def all_sync_send_with_ping(self, peers):
155147
for p in peers:

0 commit comments

Comments
 (0)