mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
[fuzz] Make ConsumeNetAddr produce valid onion addresses
This commit is contained in:
parent
c9ba3f836e
commit
291c8697d4
1 changed files with 5 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <consensus/amount.h>
|
||||
#include <net_processing.h>
|
||||
#include <netaddress.h>
|
||||
#include <netmessagemaker.h>
|
||||
#include <pubkey.h>
|
||||
#include <test/fuzz/util.h>
|
||||
|
@ -524,7 +525,10 @@ CNetAddr ConsumeNetAddr(FuzzedDataProvider& fuzzed_data_provider) noexcept
|
|||
} else if (network == Network::NET_INTERNAL) {
|
||||
net_addr.SetInternal(fuzzed_data_provider.ConsumeBytesAsString(32));
|
||||
} else if (network == Network::NET_ONION) {
|
||||
net_addr.SetSpecial(fuzzed_data_provider.ConsumeBytesAsString(32));
|
||||
auto pub_key{fuzzed_data_provider.ConsumeBytes<uint8_t>(ADDR_TORV3_SIZE)};
|
||||
pub_key.resize(ADDR_TORV3_SIZE);
|
||||
const bool ok{net_addr.SetSpecial(OnionToString(pub_key))};
|
||||
assert(ok);
|
||||
}
|
||||
return net_addr;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue