mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
[fuzz] Make RandAddr() a free function in fuzz/addrman.cpp
It doesn't require access to CAddrManDeterministic
This commit is contained in:
@@ -36,20 +36,10 @@ FUZZ_TARGET_INIT(data_stream_addr_man, initialize_addrman)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddrManDeterministic : public AddrMan
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit AddrManDeterministic(std::vector<bool> asmap, FuzzedDataProvider& fuzzed_data_provider)
|
|
||||||
: AddrMan(std::move(asmap), /* deterministic */ true, /* consistency_check_ratio */ 0)
|
|
||||||
{
|
|
||||||
WITH_LOCK(m_impl->cs, m_impl->insecure_rand = FastRandomContext{ConsumeUInt256(fuzzed_data_provider)});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a random address. Always returns a valid address.
|
* Generate a random address. Always returns a valid address.
|
||||||
*/
|
*/
|
||||||
CNetAddr RandAddr(FuzzedDataProvider& fuzzed_data_provider, FastRandomContext& fast_random_context)
|
CNetAddr RandAddr(FuzzedDataProvider& fuzzed_data_provider, FastRandomContext& fast_random_context)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(m_impl->cs)
|
|
||||||
{
|
{
|
||||||
CNetAddr addr;
|
CNetAddr addr;
|
||||||
if (fuzzed_data_provider.remaining_bytes() > 1 && fuzzed_data_provider.ConsumeBool()) {
|
if (fuzzed_data_provider.remaining_bytes() > 1 && fuzzed_data_provider.ConsumeBool()) {
|
||||||
@@ -84,6 +74,15 @@ public:
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AddrManDeterministic : public AddrMan
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit AddrManDeterministic(std::vector<bool> asmap, FuzzedDataProvider& fuzzed_data_provider)
|
||||||
|
: AddrMan(std::move(asmap), /* deterministic */ true, /* consistency_check_ratio */ 0)
|
||||||
|
{
|
||||||
|
WITH_LOCK(m_impl->cs, m_impl->insecure_rand = FastRandomContext{ConsumeUInt256(fuzzed_data_provider)});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill this addrman with lots of addresses from lots of sources.
|
* Fill this addrman with lots of addresses from lots of sources.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user