test: make p2p_eviction actually exercise block-time protection #36470

pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2026-10-test-p2p-eviction-block-protection changing 1 files +16 −13
  1. brunoerg commented at 11:54 AM on October 8, 2026: contributor

    p2p_eviction.py tests that 4 inbound peers that recently sent us a novel block are protected from eviction. However, the test currently passes even when that protection is not in effect.

    The block-sending peers are connected first, so they are the oldest connections. When block-time protection doesn't apply, CompareNodeBlockTime falls back to connection time and protects the 4 oldest peers, which are these same peers. Then the youngest remaining peer gets evicted. The check evicted_peers[0] not in protected_peers therefore holds whether or not block-time protection works.

    This can be shown by deleting the line where the peers send their block (L71 on master):

    block_peer.send_blocks_and_test([block], node, success=True)
    
  2. test: make p2p_eviction actually exercise block-time protection
    The 4 peers that send us a block were connected first, making them the
    oldest connections. When block-time protection doesn't apply,
    CompareNodeBlockTime falls through to connection time and protects the
    oldest peers anyway, and the youngest remaining peer gets evicted. So the
    test kept passing with the block-time protection removed from
    SelectNodeToEvict, or with the peers never sending a block.
    
    Connect the block-sending peers last, so only a working block-time
    protection keeps them from being evicted. With this change the test
    fails if the CompareNodeBlockTime protection in SelectNodeToEvict is
    removed.
    c75cdce1f9
  3. DrahtBot added the label Tests on Oct 8, 2026
  4. DrahtBot commented at 11:54 AM on October 8, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

Contributors
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-08 23:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me