mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 10:12:28 +02:00
Merge bitcoin/bitcoin#31163: scripted-diff: get rid of remaining "command" terminology in protocol.{h,cpp}
4120c7543escripted-diff: get rid of remaining "command" terminology in protocol.{h,cpp} (Sebastian Falbesoner) Pull request description: The confusing "command" terminology for the 12-byte field in the (v1) p2p message header was replaced with the more proper term "message type" in other modules already years ago, see eg #18533, #18937, #24078, #24141. This PR does the same for the protocol.{h,cpp} module to complete the replacements. Note that "GetCommand" is a method name also used in the `ArgsManager` (there it makes much more sense), so the scripted-diff lists for this replacement the files explicitly, rather than using `$(git grep -l ...)`. ACKs for top commit: maflcko: review ACK4120c7543e🛒 fjahr: Code review ACK4120c7543erkrux: tACK4120c7543eTree-SHA512: 7b4dd30136392a145da95d2f3ba181c18c155ba6f3158e49e622d76811c6a45ef9b5c7539a979a04d8404faf18bb27f11457aa436d4e2998ece3deb2c9e59748
This commit is contained in:
@@ -130,7 +130,7 @@ FUZZ_TARGET(connman, .init = initialize_connman)
|
||||
},
|
||||
[&] {
|
||||
CSerializedNetMsg serialized_net_msg;
|
||||
serialized_net_msg.m_type = fuzzed_data_provider.ConsumeRandomLengthString(CMessageHeader::COMMAND_SIZE);
|
||||
serialized_net_msg.m_type = fuzzed_data_provider.ConsumeRandomLengthString(CMessageHeader::MESSAGE_TYPE_SIZE);
|
||||
serialized_net_msg.data = ConsumeRandomLengthByteVector(fuzzed_data_provider);
|
||||
connman.PushMessage(&random_node, std::move(serialized_net_msg));
|
||||
},
|
||||
|
||||
@@ -263,7 +263,7 @@ FUZZ_TARGET(service_deserialize, .init = initialize_deserialize)
|
||||
FUZZ_TARGET_DESERIALIZE(messageheader_deserialize, {
|
||||
CMessageHeader mh;
|
||||
DeserializeFromFuzzingInput(buffer, mh);
|
||||
(void)mh.IsCommandValid();
|
||||
(void)mh.IsMessageTypeValid();
|
||||
})
|
||||
FUZZ_TARGET(address_deserialize, .init = initialize_deserialize)
|
||||
{
|
||||
|
||||
@@ -81,7 +81,7 @@ FUZZ_TARGET(p2p_transport_serialization, .init = initialize_p2p_transport_serial
|
||||
const std::chrono::microseconds m_time{std::numeric_limits<int64_t>::max()};
|
||||
bool reject_message{false};
|
||||
CNetMessage msg = recv_transport.GetReceivedMessage(m_time, reject_message);
|
||||
assert(msg.m_type.size() <= CMessageHeader::COMMAND_SIZE);
|
||||
assert(msg.m_type.size() <= CMessageHeader::MESSAGE_TYPE_SIZE);
|
||||
assert(msg.m_raw_message_size <= mutable_msg_bytes.size());
|
||||
assert(msg.m_raw_message_size == CMessageHeader::HEADER_SIZE + msg.m_message_size);
|
||||
assert(msg.m_time == m_time);
|
||||
@@ -139,9 +139,9 @@ void SimulationTest(Transport& initiator, Transport& responder, R& rng, FuzzedDa
|
||||
// If v is 0xFF, construct a valid (but possibly unknown) message type from the fuzz
|
||||
// data.
|
||||
std::string ret;
|
||||
while (ret.size() < CMessageHeader::COMMAND_SIZE) {
|
||||
while (ret.size() < CMessageHeader::MESSAGE_TYPE_SIZE) {
|
||||
char c = provider.ConsumeIntegral<char>();
|
||||
// Match the allowed characters in CMessageHeader::IsCommandValid(). Any other
|
||||
// Match the allowed characters in CMessageHeader::IsMessageTypeValid(). Any other
|
||||
// character is interpreted as end.
|
||||
if (c < ' ' || c > 0x7E) break;
|
||||
ret += c;
|
||||
|
||||
@@ -61,7 +61,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
|
||||
|
||||
LOCK(NetEventsInterface::g_msgproc_mutex);
|
||||
|
||||
const std::string random_message_type{fuzzed_data_provider.ConsumeBytesAsString(CMessageHeader::COMMAND_SIZE).c_str()};
|
||||
const std::string random_message_type{fuzzed_data_provider.ConsumeBytesAsString(CMessageHeader::MESSAGE_TYPE_SIZE).c_str()};
|
||||
if (!LIMIT_TO_MESSAGE_TYPE.empty() && random_message_type != LIMIT_TO_MESSAGE_TYPE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ FUZZ_TARGET(process_messages, .init = initialize_process_messages)
|
||||
|
||||
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 30)
|
||||
{
|
||||
const std::string random_message_type{fuzzed_data_provider.ConsumeBytesAsString(CMessageHeader::COMMAND_SIZE).c_str()};
|
||||
const std::string random_message_type{fuzzed_data_provider.ConsumeBytesAsString(CMessageHeader::MESSAGE_TYPE_SIZE).c_str()};
|
||||
|
||||
const auto mock_time = ConsumeTime(fuzzed_data_provider);
|
||||
SetMockTime(mock_time);
|
||||
|
||||
@@ -20,7 +20,7 @@ FUZZ_TARGET(protocol)
|
||||
return;
|
||||
}
|
||||
try {
|
||||
(void)inv->GetCommand();
|
||||
(void)inv->GetMessageType();
|
||||
} catch (const std::out_of_range&) {
|
||||
}
|
||||
(void)inv->ToString();
|
||||
|
||||
Reference in New Issue
Block a user