Page MenuHomePhabricator

Seeder: make sure nStartingHeight is initialized
ClosedPublic

Authored by PiRK on Jul 16 2024, 08:01.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCca55ad7ecea2: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Jul 16 2024, 08:01
PiRK added inline comments.
src/seeder/bitcoin.h
42–43 ↗(On Diff #48647)

These two would require additional includes to be initialized here, so we keep initializing them in the cpp file.

This revision is now accepted and ready to land.Jul 16 2024, 08:05