test: zero-pad the port in feature_anchors' expected hex #36559

pull kravens wants to merge 1 commits into bitcoin:master from kravens:test-anchors-port-hex changing 1 files +4 −3
  1. kravens commented at 5:50 PM on October 17, 2026: none

    feature_anchors.py builds the expected anchors.dat substring from each peer's port with hex(port)[2:], which is not zero-padded. The port is serialized as two bytes, so for ports below 4096 the expected string is one hex digit short and assert ip_port in anchors_hex fails.

    This only shows up with a non-default port range, for example when avoiding local listeners:

    TEST_RUNNER_PORT_MIN=1100 test/functional/feature_anchors.py
    

    fails on master with AssertionError at the assert ip_port in anchors_hex line and passes with this change; the default range still passes.


    Disclosure: AI (Claude Fable 5.1) was used to find this issue and to draft this PR.

  2. test: zero-pad the port in feature_anchors' expected hex
    The test builds the expected anchors.dat substring from the peer's port
    with hex(port)[2:], which is not zero-padded. The port is serialized as
    two bytes, so for ports below 4096 the expected string is one hex digit
    short and the assertion fails:
    
        TEST_RUNNER_PORT_MIN=1100 test/functional/feature_anchors.py
    
    Format the port as four hex digits instead.
    2f7622e3f6
  3. DrahtBot added the label Tests on Oct 17, 2026
  4. DrahtBot commented at 5:50 PM on October 17, 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.

    Type Reviewers
    ACK l0rinc

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. pinheadmz commented at 10:44 PM on October 17, 2026: member

    Please review our AI policy, and then you can comment here if you'd still like to contribute to the project in a meaningful way.

    https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md

  6. pinheadmz closed this on Oct 17, 2026

  7. kravens commented at 10:55 PM on October 17, 2026: none

    Yep, also here I added the disclosure after reading the policy. Again a fix for a non-default configuration, so ignore if you don't want to review AI-generated code at all.

  8. l0rinc commented at 1:52 AM on October 18, 2026: contributor

    lightly tested ACK 2f7622e3f6f7ef431a7d5ec522958da62f33cec4

    I don't see a problem here, the formatting matches the serialization, the fix seems narrow.

  9. pinheadmz commented at 1:55 AM on October 18, 2026: member

    Ok

  10. fanquake reopened this on Oct 18, 2026


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-19 03:51 UTC

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