diff:
diff --git a/src/test/fuzz/p2p_transport_serialization.cpp b/src/test/fuzz/p2p_transport_serialization.cpp
index 852994afe..d6e0bd5c5 100644
--- a/src/test/fuzz/p2p_transport_serialization.cpp
+++ b/src/test/fuzz/p2p_transport_serialization.cpp
@@ -429,34 +429,33 @@ FUZZ_TARGET(p2p_transport_v2_receive, .init = initialize_p2p_transport_serializa
peer.Initialize(BIP324Cipher{key, ent}.GetOurPubKey(), /*initiator=*/!initiating);
// Build the byte stream.
- std::vector<uint8_t> stream;
+ std::vector<std::byte> stream;
// Garbage appended since the last key, which the first packet after the terminator must
// authenticate.
- std::vector<uint8_t> aad;
+ std::vector<std::byte> aad;
auto append_fn = [&](std::span<const std::byte> bytes) {
- stream.insert(stream.end(), UCharCast(bytes.data()), UCharCast(bytes.data() + bytes.size()));
+ stream.insert(stream.end(), bytes.begin(), bytes.end());
};
// Flip a bit in stream, at or after position start.
auto flip_fn = [&](size_t start) {
- stream[provider.ConsumeIntegralInRange<size_t>(start, stream.size() - 1)] ^= 1 << provider.ConsumeIntegralInRange<unsigned>(0, 7);
+ stream[provider.ConsumeIntegralInRange<size_t>(start, stream.size() - 1)] ^= std::byte{1} << provider.ConsumeIntegralInRange<unsigned>(0, 7);
};
LIMITED_WHILE (provider.remaining_bytes(), 100) {
CallOneOf(provider,
// Arbitrary bytes.
[&] {
- auto bytes = provider.ConsumeBytes<uint8_t>(provider.ConsumeIntegralInRange<size_t>(0, 256));
- stream.insert(stream.end(), bytes.begin(), bytes.end());
+ append_fn(provider.ConsumeBytes<std::byte>(provider.ConsumeIntegralInRange<size_t>(0, 256)));
},
// The peer's key.
[&] {
- append_fn(std::span{peer.GetOurPubKey().data(), EllSwiftPubKey::size()});
+ append_fn(peer.GetOurPubKey());
aad.clear();
},
// Garbage.
[&] {
- auto bytes = provider.ConsumeBytes<uint8_t>(provider.ConsumeIntegralInRange<size_t>(0, V2Transport::MAX_GARBAGE_LEN));
- stream.insert(stream.end(), bytes.begin(), bytes.end());
- aad.insert(aad.end(), bytes.begin(), bytes.end());
+ const auto garbage{provider.ConsumeBytes<std::byte>(provider.ConsumeIntegralInRange<size_t>(0, V2Transport::MAX_GARBAGE_LEN))};
+ append_fn(garbage);
+ aad.insert(aad.end(), garbage.begin(), garbage.end());
},
// The garbage terminator, possibly corrupted.
[&] {
@@ -471,7 +470,7 @@ FUZZ_TARGET(p2p_transport_v2_receive, .init = initialize_p2p_transport_serializa
const bool corrupt = provider.ConsumeBool();
const auto start = stream.size();
stream.resize(start + contents.size() + BIP324Cipher::EXPANSION);
- peer.Encrypt(contents, MakeByteSpan(aad), ignore, MakeWritableByteSpan(stream).subspan(start));
+ peer.Encrypt(contents, aad, ignore, std::span{stream}.subspan(start));
aad.clear();
if (corrupt) flip_fn(start);
}
@@ -479,7 +478,7 @@ FUZZ_TARGET(p2p_transport_v2_receive, .init = initialize_p2p_transport_serializa
}
// Receive the stream in pieces, and send what the transport wants to send in between.
- std::span<const uint8_t> to_recv{stream};
+ std::span<const uint8_t> to_recv{MakeUCharSpan(stream)};
while (!to_recv.empty()) {
const size_t piece_len = provider.ConsumeIntegralInRange<size_t>(1, to_recv.size());
std::span<const uint8_t> piece = to_recv.first(piece_len);