Page MenuHomePhabricator

Add << operator overload for PeerMessagingState
ClosedPublic

Authored by nakihito on Thu, Mar 12, 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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

nakihito created this revision.Thu, Mar 12, 20:49
Owners added a reviewer: Restricted Owners Package.Thu, Mar 12, 20:49
Herald added a reviewer: Restricted Project. · View Herald TranscriptThu, Mar 12, 20:49
nakihito planned changes to this revision.Thu, Mar 12, 20:49
nakihito requested review of this revision.Thu, Mar 12, 21:27
deadalnix requested changes to this revision.Fri, Mar 13, 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.Fri, Mar 13, 07:29
nakihito updated this revision to Diff 16918.Fri, Mar 13, 17:12

Separated C++ magic from operator function as advised.

nakihito planned changes to this revision.Fri, Mar 13, 17:12
nakihito updated this revision to Diff 16920.Fri, Mar 13, 17:21

Removed ostream from seeder/bitcoin.h.

jasonbcox added inline comments.
src/seeder/bitcoin.h
25 ↗(On Diff #16920)
nakihito updated this revision to Diff 16923.Fri, Mar 13, 18:55

Removed unnecessary underlying value.

nakihito updated this revision to Diff 16927.Fri, Mar 13, 20:17

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.

jasonbcox added inline comments.Fri, Mar 13, 23:49
src/seeder/bitcoin.h
22 ↗(On Diff #16927)

You missed the bool here

nakihito updated this revision to Diff 16936.Sat, Mar 14, 01:01

Removed underlying bool type.

deadalnix accepted this revision.Sat, Mar 14, 10:28
This revision is now accepted and ready to land.Sat, Mar 14, 10:28
This revision was automatically updated to reflect the committed changes.