HomePhabricator

Seeder: make sure nStartingHeight is initialized

Description

Seeder: make sure nStartingHeight is initialized

Summary:
Previously CSeederNode::nStartingHeight was initialized only after receiving the version message. This caused a test in p2p_messaging_tests to intermittently fail on some platforms when nStartingHeight was a random value larger than 0.

FAILED: src/seeder/test/CMakeFiles/check-seeder-p2p_messaging_tests
Running 6 test cases...
../../src/seeder/test/p2p_messaging_tests.cpp:38: error: in "p2p_messaging_tests/ban_too_many_headers": check ret == expectedState has failed [1 != 0]
../../src/seeder/test/p2p_messaging_tests.cpp:178: error: in "p2p_messaging_tests/ban_too_many_headers": check testNode->GetBan() == 0 has failed [100000 != 0]

Also modernize adjacent members with C++ 11 member initialization and remove unused members nHeaderStart and nMessageStart while we are touching this code.

Test Plan:
On a MacOS machine on which I was able to reproduce the error about 10% of the time before this diff:

for i in {1..100}; do ninja check-seeder; done

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D16473

Details

Provenance
PiRKAuthored on Jul 16 2024, 07:53
PiRKPushed on Jul 16 2024, 09:27
Reviewer
Restricted Project
Differential Revision
D16473: Seeder: make sure nStartingHeight is initialized
Parents
rABCe308d2e67b4b: Make PeerManager own a FastRandomContext
Branches
Unknown
Tags
Unknown