Page MenuHomePhabricator

Add << operator overload for PeerMessagingState
ClosedPublic

Authored by nakihito on Mar 12 2020, 20:49.

Details

Summary

Not having this causes BOOST_CHECK_EQUAL() to fail on sanitizer builds when comparing
the enum.

Fixes T764, T763, and T762

Test Plan
ninja check

Run sanitizer builds

Diff Detail

Repository
rABC Bitcoin ABC
Branch
fixMaster
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 9818
Build 17506: Default Diff Build & Tests
Build 17505: arc lint + arc unit

Event Timeline

Owners added a reviewer: Restricted Owners Package.Mar 12 2020, 20:49
deadalnix requested changes to this revision.Mar 13 2020, 07:29
deadalnix added a subscriber: deadalnix.
deadalnix added inline comments.
src/seeder/bitcoin.cpp
23 ↗(On Diff #16908)

IMO you should separate the C++ magic from the intent of the code, because right now, that is not very clear.

For instance, you could use something like:

template<typename E>
constexpr std::underlying_type<E>::type to_integral(E e) {
   return static_cast<typename std::underlying_type<E>::type>(e);
}

And then call that. If it turns out to be more generally useful, then it can be moved to a header somewhere.

src/seeder/bitcoin.h
12 ↗(On Diff #16908)

ostream only is suffiscient.

14 ↗(On Diff #16908)

Remove.

This revision now requires changes to proceed.Mar 13 2020, 07:29

Separated C++ magic from operator function as advised.

Removed ostream from seeder/bitcoin.h.

jasonbcox added inline comments.
src/seeder/bitcoin.h
25 ↗(On Diff #16920)

Removed unnecessary underlying value.

Moved to_integral() to a new file. because it is only really used for tests. This makes it easier to include in all (appropriate) test files without having to expose or open up more components.

src/seeder/bitcoin.h
22 ↗(On Diff #16927)

You missed the bool here

Removed underlying bool type.

This revision is now accepted and ready to land.Mar 14 2020, 10:28