mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-20 12:39:47 +01:00
net: merge V2Transport constructors, move key gen
This removes the ability for BIP324Cipher to generate its own key, moving that responsibility to the caller (mostly, V2Transport). This allows us to write the random-key V2Transport constructor by delegating to the explicit-key one.
This commit is contained in:
@@ -1008,6 +1008,14 @@ BOOST_AUTO_TEST_CASE(advertise_local_address)
|
||||
|
||||
namespace {
|
||||
|
||||
CKey GenerateRandomTestKey() noexcept
|
||||
{
|
||||
CKey key;
|
||||
uint256 key_data = InsecureRand256();
|
||||
key.Set(key_data.begin(), key_data.end(), true);
|
||||
return key;
|
||||
}
|
||||
|
||||
/** A class for scenario-based tests of V2Transport
|
||||
*
|
||||
* Each V2TransportTester encapsulates a V2Transport (the one being tested), and can be told to
|
||||
@@ -1031,6 +1039,7 @@ public:
|
||||
/** Construct a tester object. test_initiator: whether the tested transport is initiator. */
|
||||
V2TransportTester(bool test_initiator) :
|
||||
m_transport(0, test_initiator, SER_NETWORK, INIT_PROTO_VERSION),
|
||||
m_cipher{GenerateRandomTestKey(), MakeByteSpan(InsecureRand256())},
|
||||
m_test_initiator(test_initiator) {}
|
||||
|
||||
/** Data type returned by Interact:
|
||||
|
||||
Reference in New Issue
Block a user