Skip to content

Commit dd8447f

Browse files
committed
test: fix catchup loop in outbound eviction functional test
The catchup loop in the outbound eviction functional test currently has a small flaw, as the contained waiting for a `getheaders` message just waits for any such message instead of one with the intended block hash. The reason is that the `prev_prev_hash` variable is set incorrectly, since the `tip_header` instance is not updated and its field `.hash` is None. Fix that by updating `tip_header` and use the correct field -- we want the tip header's previous hash (`.hashPrevBlock`).
1 parent 5757de4 commit dd8447f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

test/functional/p2p_outbound_eviction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def test_outbound_eviction_unprotected(self):
8888
# Generate an additional block so the peers is 2 blocks behind
8989
prev_header = from_hex(CBlockHeader(), node.getblockheader(best_block_hash, False))
9090
best_block_hash = self.generateblock(node, output="raw(42)", transactions=[])["hash"]
91+
tip_header = from_hex(CBlockHeader(), node.getblockheader(best_block_hash, False))
9192
peer.sync_with_ping()
9293

9394
# Advance time but not enough to evict the peer
@@ -100,7 +101,7 @@ def test_outbound_eviction_unprotected(self):
100101

101102
# Send a header with the previous tip (so we go back to 1 block behind)
102103
peer.send_and_ping(msg_headers([prev_header]))
103-
prev_prev_hash = tip_header.hash
104+
prev_prev_hash = tip_header.hashPrevBlock
104105

105106
self.log.info("Create an outbound connection and take some time to catch up, but do it in time")
106107
# Check that if the peer manages to catch up within time, the timeouts are removed (and the peer is not disconnected)

0 commit comments

Comments
 (0)