diff options
author | Pieter Wuille <pieter@wuille.net> | 2020-09-28 12:26:43 -0700 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2020-09-28 12:27:08 -0700 |
commit | 655937ebcbf681ededf86b1f0f60aac45c73393d (patch) | |
tree | 8b0b0bf342ba646a574929b8fbcd094ca05d4f2b /src/test/util | |
parent | 2552702000744ab2c396f1270468fc173d4e8dce (diff) | |
parent | 7be6ff61875a8d5d2335bff5d1f16ba40557adb0 (diff) |
Merge #19845: net: CNetAddr: add support to (un)serialize as ADDRv2
7be6ff61875a8d5d2335bff5d1f16ba40557adb0 net: recognize TORv3/I2P/CJDNS networks (Vasil Dimov)
e0d73573a37bf4b519f6f61e5678572d48a64517 net: CNetAddr: add support to (un)serialize as ADDRv2 (Vasil Dimov)
fe42411b4b07b99c591855f5f00ad45dfeec8e30 test: move HasReason so it can be reused (Vasil Dimov)
d2bb681f96fb327b4c4d5b2b113692ca22fdffbf util: move HasPrefix() so it can be reused (Vasil Dimov)
Pull request description:
(chopped off from #19031 to ease review)
Add an optional support to serialize/unserialize `CNetAddr` in ADDRv2 format (BIP155). The new serialization is engaged by ORing a flag into the stream version.
So far this is only used in tests to ensure the new code works as expected.
ACKs for top commit:
Sjors:
re-tACK 7be6ff61875a8d5d2335bff5d1f16ba40557adb0
sipa:
re-utACK 7be6ff61875a8d5d2335bff5d1f16ba40557adb0
eriknylund:
ACK 7be6ff61875a8d5d2335bff5d1f16ba40557adb0 I built the PR on macOS Catalina 10.15.6, ran both tests and functional tests. I've reviewed the code and think the changes look good and according to BIP155. I verified that the added Base32 encoding test looks as proposed and working. I've run a node for a week only with Onion addresses `-onlynet=onion` without issues and I can connect to other peer reviewers running TorV3 on their nodes and I can connect both of my test nodes to each other.
jonatack:
re-ACK 7be6ff61875a8d5d2335bff5d1f16ba40557adb0 per `git diff b9c46e0 7be6ff6`, debug build, ran/running bitcoind with this change and observed the log and `-netinfo` peer connections while connected as a tor v2 service to both tor v2 peers and also five tor v3 peers.
hebasto:
ACK 7be6ff61875a8d5d2335bff5d1f16ba40557adb0, tested on Linux Mint 20 (x86_64): on top of this pull and #19031 I'm able to connect to onion v3 addresses, and jonatack is able to connect to my created onion v3 address.
Tree-SHA512: dc621411ac4393993aa3ccad10991717ec5f9f2643cae46a24a89802df0a33d6042994fc8ff2f0f397a3dbcd1c0e58fe4724305a2f9eb64d9342c3bdf784d9be
Diffstat (limited to 'src/test/util')
-rw-r--r-- | src/test/util/setup_common.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 22f5d6d936..a09c8c122d 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -153,4 +153,20 @@ CBlock getBlock13b8a(); // define an implicit conversion here so that uint256 may be used directly in BOOST_CHECK_* std::ostream& operator<<(std::ostream& os, const uint256& num); +/** + * BOOST_CHECK_EXCEPTION predicates to check the specific validation error. + * Use as + * BOOST_CHECK_EXCEPTION(code that throws, exception type, HasReason("foo")); + */ +class HasReason { +public: + explicit HasReason(const std::string& reason) : m_reason(reason) {} + template <typename E> + bool operator() (const E& e) const { + return std::string(e.what()).find(m_reason) != std::string::npos; + }; +private: + const std::string m_reason; +}; + #endif |