This commit is contained in:
maflcko 2024-05-16 03:18:16 +02:00 committed by GitHub
commit 579635ed77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 71 additions and 68 deletions

View File

@ -10,6 +10,6 @@ export CONTAINER_NAME=ci_native_nowallet_libbitcoinkernel
export CI_IMAGE_NAME_TAG="docker.io/ubuntu:22.04"
# Use minimum supported python3.9 (or best-effort 3.10) and clang-15, see doc/dependencies.md
export PACKAGES="python3-zmq clang-15 llvm-15 libc++abi-15-dev libc++-15-dev"
export DEP_OPTS="NO_WALLET=1 CC=clang-15 CXX='clang++-15 -stdlib=libc++'"
export DEP_OPTS="NO_WALLET=1 CC=clang-15 CXX='clang++-15 -stdlib=libstdc++'"
export GOAL="install"
export BITCOIN_CONFIG="--enable-reduce-exports --enable-experimental-util-chainstate --with-experimental-kernel-lib --enable-shared"

View File

@ -80,10 +80,10 @@ bool ExternalSigner::SignTransaction(PartiallySignedTransaction& psbtx, std::str
// Check if signer fingerprint matches any input master key fingerprint
auto matches_signer_fingerprint = [&](const PSBTInput& input) {
for (const auto& entry : input.hd_keypaths) {
if (parsed_m_fingerprint == MakeUCharSpan(entry.second.fingerprint)) return true;
if (std::ranges::equal(parsed_m_fingerprint, entry.second.fingerprint)) return true;
}
for (const auto& entry : input.m_tap_bip32_paths) {
if (parsed_m_fingerprint == MakeUCharSpan(entry.second.second.fingerprint)) return true;
if (std::ranges::equal(parsed_m_fingerprint, entry.second.second.fingerprint)) return true;
}
return false;
};

View File

@ -46,13 +46,12 @@
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <functional>
#include <optional>
#include <unordered_map>
#include <math.h>
/** Maximum number of block-relay-only anchor connections */
static constexpr size_t MAX_BLOCK_RELAY_ONLY_ANCHORS = 2;
static_assert (MAX_BLOCK_RELAY_ONLY_ANCHORS <= static_cast<size_t>(MAX_BLOCK_RELAY_ONLY_CONNECTIONS), "MAX_BLOCK_RELAY_ONLY_ANCHORS must not exceed MAX_BLOCK_RELAY_ONLY_CONNECTIONS.");
@ -1152,7 +1151,7 @@ bool V2Transport::ProcessReceivedGarbageBytes() noexcept
Assume(m_recv_state == RecvState::GARB_GARBTERM);
Assume(m_recv_buffer.size() <= MAX_GARBAGE_LEN + BIP324Cipher::GARBAGE_TERMINATOR_LEN);
if (m_recv_buffer.size() >= BIP324Cipher::GARBAGE_TERMINATOR_LEN) {
if (MakeByteSpan(m_recv_buffer).last(BIP324Cipher::GARBAGE_TERMINATOR_LEN) == m_cipher.GetReceiveGarbageTerminator()) {
if (std::ranges::equal(MakeByteSpan(m_recv_buffer).last(BIP324Cipher::GARBAGE_TERMINATOR_LEN), m_cipher.GetReceiveGarbageTerminator())) {
// Garbage terminator received. Store garbage to authenticate it as AAD later.
m_recv_aad = std::move(m_recv_buffer);
m_recv_aad.resize(m_recv_aad.size() - BIP324Cipher::GARBAGE_TERMINATOR_LEN);

View File

@ -242,14 +242,14 @@ bool CNetAddr::SetTor(const std::string& addr)
Span<const uint8_t> input_checksum{input->data() + ADDR_TORV3_SIZE, torv3::CHECKSUM_LEN};
Span<const uint8_t> input_version{input->data() + ADDR_TORV3_SIZE + torv3::CHECKSUM_LEN, sizeof(torv3::VERSION)};
if (input_version != torv3::VERSION) {
if (!std::ranges::equal(input_version, torv3::VERSION)) {
return false;
}
uint8_t calculated_checksum[torv3::CHECKSUM_LEN];
torv3::Checksum(input_pubkey, calculated_checksum);
if (input_checksum != calculated_checksum) {
if (!std::ranges::equal(input_checksum, calculated_checksum)) {
return false;
}

View File

@ -21,6 +21,7 @@
#include <util/strencodings.h>
#include <util/vector.h>
#include <algorithm>
#include <memory>
#include <numeric>
#include <optional>
@ -1405,11 +1406,11 @@ std::unique_ptr<PubkeyProvider> ParsePubkeyInner(uint32_t key_exp_index, const S
}
KeyPath path;
DeriveType type = DeriveType::NO;
if (split.back() == Span{"*"}.first(1)) {
if (std::ranges::equal(split.back(), Span{"*"}.first(1))) {
split.pop_back();
type = DeriveType::UNHARDENED;
} else if (split.back() == Span{"*'"}.first(2) || split.back() == Span{"*h"}.first(2)) {
apostrophe = split.back() == Span{"*'"}.first(2);
} else if (std::ranges::equal(split.back(), Span{"*'"}.first(2)) || std::ranges::equal(split.back(), Span{"*h"}.first(2))) {
apostrophe = std::ranges::equal(split.back(), Span{"*'"}.first(2));
split.pop_back();
type = DeriveType::HARDENED;
}

View File

@ -4,10 +4,6 @@
#include <signet.h>
#include <array>
#include <cstdint>
#include <vector>
#include <common/system.h>
#include <consensus/merkle.h>
#include <consensus/params.h>
@ -23,6 +19,11 @@
#include <uint256.h>
#include <util/strencodings.h>
#include <algorithm>
#include <array>
#include <cstdint>
#include <vector>
static constexpr uint8_t SIGNET_HEADER[4] = {0xec, 0xc7, 0xda, 0xa2};
static constexpr unsigned int BLOCK_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_NULLDUMMY;
@ -38,7 +39,7 @@ static bool FetchAndClearCommitmentSection(const Span<const uint8_t> header, CSc
std::vector<uint8_t> pushdata;
while (witness_commitment.GetOp(pc, opcode, pushdata)) {
if (pushdata.size() > 0) {
if (!found_header && pushdata.size() > (size_t)header.size() && Span{pushdata}.first(header.size()) == header) {
if (!found_header && pushdata.size() > header.size() && std::ranges::equal(Span{pushdata}.first(header.size()), header)) {
// pushdata only counts if it has the header _and_ some data
result.insert(result.end(), pushdata.begin() + header.size(), pushdata.end());
pushdata.erase(pushdata.begin() + header.size(), pushdata.end());

View File

@ -213,13 +213,6 @@ public:
return Span<C>(m_data + m_size - count, count);
}
friend constexpr bool operator==(const Span& a, const Span& b) noexcept { return a.size() == b.size() && std::equal(a.begin(), a.end(), b.begin()); }
friend constexpr bool operator!=(const Span& a, const Span& b) noexcept { return !(a == b); }
friend constexpr bool operator<(const Span& a, const Span& b) noexcept { return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end()); }
friend constexpr bool operator<=(const Span& a, const Span& b) noexcept { return !(b < a); }
friend constexpr bool operator>(const Span& a, const Span& b) noexcept { return (b < a); }
friend constexpr bool operator>=(const Span& a, const Span& b) noexcept { return !(a < b); }
template <typename O> friend class Span;
};

View File

@ -5,6 +5,8 @@
#include <util/strencodings.h>
#include <boost/test/unit_test.hpp>
#include <algorithm>
#include <string>
using namespace std::literals;
@ -24,7 +26,7 @@ BOOST_AUTO_TEST_CASE(base32_testvectors)
BOOST_CHECK_EQUAL(strEnc, vstrOutNoPadding[i]);
auto dec = DecodeBase32(vstrOut[i]);
BOOST_REQUIRE(dec);
BOOST_CHECK_MESSAGE(MakeByteSpan(*dec) == MakeByteSpan(vstrIn[i]), vstrOut[i]);
BOOST_CHECK_MESSAGE(std::ranges::equal(*dec, vstrIn[i]), vstrOut[i]);
}
// Decoding strings with embedded NUL characters should fail

View File

@ -5,6 +5,8 @@
#include <util/strencodings.h>
#include <boost/test/unit_test.hpp>
#include <algorithm>
#include <string>
using namespace std::literals;
@ -21,7 +23,7 @@ BOOST_AUTO_TEST_CASE(base64_testvectors)
BOOST_CHECK_EQUAL(strEnc, vstrOut[i]);
auto dec = DecodeBase64(strEnc);
BOOST_REQUIRE(dec);
BOOST_CHECK_MESSAGE(MakeByteSpan(*dec) == MakeByteSpan(vstrIn[i]), vstrOut[i]);
BOOST_CHECK_MESSAGE(std::ranges::equal(*dec, vstrIn[i]), vstrOut[i]);
}
{

View File

@ -11,6 +11,7 @@
#include <test/util/setup_common.h>
#include <util/strencodings.h>
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
@ -62,9 +63,9 @@ void TestBIP324PacketVector(
BOOST_CHECK(cipher);
// Compare session variables.
BOOST_CHECK(Span{out_session_id} == cipher.GetSessionID());
BOOST_CHECK(Span{mid_send_garbage} == cipher.GetSendGarbageTerminator());
BOOST_CHECK(Span{mid_recv_garbage} == cipher.GetReceiveGarbageTerminator());
BOOST_CHECK(std::ranges::equal(out_session_id, cipher.GetSessionID()));
BOOST_CHECK(std::ranges::equal(mid_send_garbage, cipher.GetSendGarbageTerminator()));
BOOST_CHECK(std::ranges::equal(mid_recv_garbage, cipher.GetReceiveGarbageTerminator()));
// Vector of encrypted empty messages, encrypted in order to seek to the right position.
std::vector<std::vector<std::byte>> dummies(in_idx);
@ -89,7 +90,7 @@ void TestBIP324PacketVector(
BOOST_CHECK(out_ciphertext == ciphertext);
} else {
BOOST_CHECK(ciphertext.size() >= out_ciphertext_endswith.size());
BOOST_CHECK(Span{out_ciphertext_endswith} == Span{ciphertext}.last(out_ciphertext_endswith.size()));
BOOST_CHECK(std::ranges::equal(out_ciphertext_endswith, Span{ciphertext}.last(out_ciphertext_endswith.size())));
}
for (unsigned error = 0; error <= 12; ++error) {
@ -109,9 +110,9 @@ void TestBIP324PacketVector(
BOOST_CHECK(dec_cipher);
// Compare session variables.
BOOST_CHECK((Span{out_session_id} == dec_cipher.GetSessionID()) == (error != 1));
BOOST_CHECK((Span{mid_send_garbage} == dec_cipher.GetSendGarbageTerminator()) == (error != 1));
BOOST_CHECK((Span{mid_recv_garbage} == dec_cipher.GetReceiveGarbageTerminator()) == (error != 1));
BOOST_CHECK(std::ranges::equal(out_session_id, dec_cipher.GetSessionID()) == (error != 1));
BOOST_CHECK(std::ranges::equal(mid_send_garbage, dec_cipher.GetSendGarbageTerminator()) == (error != 1));
BOOST_CHECK(std::ranges::equal(mid_recv_garbage, dec_cipher.GetReceiveGarbageTerminator()) == (error != 1));
// Seek to the numbered packet.
if (in_idx == 0 && error == 12) continue;

View File

@ -21,6 +21,7 @@
#include <test/util/setup_common.h>
#include <util/strencodings.h>
#include <algorithm>
#include <vector>
#include <boost/test/unit_test.hpp>
@ -833,9 +834,9 @@ BOOST_AUTO_TEST_CASE(chacha20_midblock)
c20.Keystream(b2);
c20.Keystream(b3);
BOOST_CHECK(Span{block}.first(5) == Span{b1});
BOOST_CHECK(Span{block}.subspan(5, 7) == Span{b2});
BOOST_CHECK(Span{block}.last(52) == Span{b3});
BOOST_CHECK(std::ranges::equal(Span{block}.first(5), b1));
BOOST_CHECK(std::ranges::equal(Span{block}.subspan(5, 7), b2));
BOOST_CHECK(std::ranges::equal(Span{block}.last(52), b3));
}
BOOST_AUTO_TEST_CASE(poly1305_testvector)

View File

@ -10,6 +10,7 @@
#include <test/fuzz/util.h>
#include <test/util/xoroshiro128plusplus.h>
#include <algorithm>
#include <cstdint>
#include <vector>
@ -59,9 +60,9 @@ FUZZ_TARGET(bip324_cipher_roundtrip, .init=Initialize)
XoRoShiRo128PlusPlus rng(provider.ConsumeIntegral<uint64_t>());
// Compare session IDs and garbage terminators.
assert(initiator.GetSessionID() == responder.GetSessionID());
assert(initiator.GetSendGarbageTerminator() == responder.GetReceiveGarbageTerminator());
assert(initiator.GetReceiveGarbageTerminator() == responder.GetSendGarbageTerminator());
assert(std::ranges::equal(initiator.GetSessionID(), responder.GetSessionID()));
assert(std::ranges::equal(initiator.GetSendGarbageTerminator(), responder.GetReceiveGarbageTerminator()));
assert(std::ranges::equal(initiator.GetReceiveGarbageTerminator(), responder.GetSendGarbageTerminator()));
LIMITED_WHILE(provider.remaining_bytes(), 1000) {
// Mode:

View File

@ -11,6 +11,7 @@
#include <univalue.h>
#include <util/strencodings.h>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <string>
@ -21,7 +22,7 @@ FUZZ_TARGET(hex)
const std::string random_hex_string(buffer.begin(), buffer.end());
const std::vector<unsigned char> data = ParseHex(random_hex_string);
const std::vector<std::byte> bytes{ParseHex<std::byte>(random_hex_string)};
assert(AsBytes(Span{data}) == Span{bytes});
assert(std::ranges::equal(AsBytes(Span{data}), bytes));
const std::string hex_data = HexStr(data);
if (IsHex(random_hex_string)) {
assert(ToLower(random_hex_string) == hex_data);

View File

@ -13,6 +13,8 @@
#include <test/fuzz/util.h>
#include <util/strencodings.h>
#include <algorithm>
namespace {
using Fragment = miniscript::Fragment;
@ -293,7 +295,7 @@ const struct CheckerContext: BaseSignatureChecker {
XOnlyPubKey pk{pubkey};
auto it = TEST_DATA.schnorr_sigs.find(pk);
if (it == TEST_DATA.schnorr_sigs.end()) return false;
return it->second.first == sig;
return std::ranges::equal(it->second.first, sig);
}
bool CheckLockTime(const CScriptNum& nLockTime) const override { return nLockTime.GetInt64() & 1; }
bool CheckSequence(const CScriptNum& nSequence) const override { return nSequence.GetInt64() & 1; }

View File

@ -13,6 +13,7 @@
#include <test/util/xoroshiro128plusplus.h>
#include <util/chaintype.h>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <limits>
@ -188,12 +189,12 @@ void SimulationTest(Transport& initiator, Transport& responder, R& rng, FuzzedDa
// Compare with expected more.
if (expect_more[side].has_value()) assert(!bytes.empty() == *expect_more[side]);
// Verify consistency between the two results.
assert(bytes == bytes_next);
assert(std::ranges::equal(bytes, bytes_next));
assert(msg_type == msg_type_next);
if (more_nonext) assert(more_next);
// Compare with previously reported output.
assert(to_send[side].size() <= bytes.size());
assert(to_send[side] == Span{bytes}.first(to_send[side].size()));
assert(std::ranges::equal(to_send[side], Span{bytes}.first(to_send[side].size())));
to_send[side].resize(bytes.size());
std::copy(bytes.begin(), bytes.end(), to_send[side].begin());
// Remember 'more' results.
@ -281,7 +282,7 @@ void SimulationTest(Transport& initiator, Transport& responder, R& rng, FuzzedDa
// The m_type must match what is expected.
assert(received.m_type == expected[side].front().m_type);
// The data must match what is expected.
assert(MakeByteSpan(received.m_recv) == MakeByteSpan(expected[side].front().data));
assert(std::ranges::equal(received.m_recv, MakeByteSpan(expected[side].front().data)));
expected[side].pop_front();
progress = true;
}

View File

@ -30,10 +30,4 @@ FUZZ_TARGET(span)
(void)span.subspan(idx, span.size() - idx);
(void)span[idx];
}
std::string another_str = fuzzed_data_provider.ConsumeBytesAsString(32);
const Span<const char> another_span{another_str};
assert((span <= another_span) != (span > another_span));
assert((span == another_span) != (span != another_span));
assert((span >= another_span) != (span < another_span));
}

View File

@ -10,12 +10,13 @@
#include <script/script.h>
#include <test/util/json.h>
#include <test/util/setup_common.h>
#include <univalue.h>
#include <util/chaintype.h>
#include <util/strencodings.h>
#include <boost/test/unit_test.hpp>
#include <univalue.h>
#include <algorithm>
BOOST_FIXTURE_TEST_SUITE(key_io_tests, BasicTestingSetup)
@ -46,7 +47,7 @@ BOOST_AUTO_TEST_CASE(key_io_valid_parse)
privkey = DecodeSecret(exp_base58string);
BOOST_CHECK_MESSAGE(privkey.IsValid(), "!IsValid:" + strTest);
BOOST_CHECK_MESSAGE(privkey.IsCompressed() == isCompressed, "compressed mismatch:" + strTest);
BOOST_CHECK_MESSAGE(Span{privkey} == Span{exp_payload}, "key mismatch:" + strTest);
BOOST_CHECK_MESSAGE(std::ranges::equal(privkey, exp_payload), "key mismatch:" + strTest);
// Private key must be invalid public key
destination = DecodeDestination(exp_base58string);

View File

@ -2,10 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <stdint.h>
#include <string>
#include <vector>
#include <test/util/random.h>
#include <test/util/setup_common.h>
#include <boost/test/unit_test.hpp>
@ -22,6 +18,12 @@
#include <script/script_error.h>
#include <script/signingprovider.h>
#include <algorithm>
#include <cstdint>
#include <string>
#include <vector>
namespace {
/** TestData groups various kinds of precomputed data necessary in this test. */
@ -274,7 +276,7 @@ public:
XOnlyPubKey pk{pubkey};
auto it = g_testdata->schnorr_signatures.find(pk);
if (it == g_testdata->schnorr_signatures.end()) return false;
return sig == it->second;
return std::ranges::equal(sig, it->second);
}
bool CheckLockTime(const CScriptNum& locktime) const override {

View File

@ -1254,7 +1254,7 @@ public:
for (garblen = 0; garblen <= V2Transport::MAX_GARBAGE_LEN; ++garblen) {
BOOST_REQUIRE(m_received.size() >= garblen + BIP324Cipher::GARBAGE_TERMINATOR_LEN);
auto term_span = MakeByteSpan(Span{m_received}.subspan(garblen, BIP324Cipher::GARBAGE_TERMINATOR_LEN));
if (term_span == m_cipher.GetReceiveGarbageTerminator()) break;
if (std::ranges::equal(term_span, m_cipher.GetReceiveGarbageTerminator())) break;
}
// Copy the garbage to a buffer.
m_recv_garbage.assign(m_received.begin(), m_received.begin() + garblen);
@ -1279,7 +1279,7 @@ public:
auto ret = ReceivePacket();
BOOST_CHECK(ret.size() == payload.size() + 1);
BOOST_CHECK(ret[0] == short_id);
BOOST_CHECK(Span{ret}.subspan(1) == payload);
BOOST_CHECK(std::ranges::equal(Span{ret}.subspan(1), payload));
}
/** Expect application packet to have been received, with specified 12-char message type and
@ -1296,7 +1296,7 @@ public:
BOOST_CHECK(ret[1 + i] == 0);
}
}
BOOST_CHECK(Span{ret}.subspan(1 + CMessageHeader::COMMAND_SIZE) == payload);
BOOST_CHECK(std::ranges::equal(Span{ret}.subspan(1 + CMessageHeader::COMMAND_SIZE), payload));
}
/** Schedule an encrypted packet with specified message type and payload to be sent to
@ -1364,9 +1364,9 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
tester.SendMessage("tx", msg_data_2); // 12-character encoded message type
ret = tester.Interact();
BOOST_REQUIRE(ret && ret->size() == 3);
BOOST_CHECK((*ret)[0] && (*ret)[0]->m_type == "cmpctblock" && Span{(*ret)[0]->m_recv} == MakeByteSpan(msg_data_1));
BOOST_CHECK((*ret)[0] && (*ret)[0]->m_type == "cmpctblock" && std::ranges::equal((*ret)[0]->m_recv, MakeByteSpan(msg_data_1)));
BOOST_CHECK(!(*ret)[1]);
BOOST_CHECK((*ret)[2] && (*ret)[2]->m_type == "tx" && Span{(*ret)[2]->m_recv} == MakeByteSpan(msg_data_2));
BOOST_CHECK((*ret)[2] && (*ret)[2]->m_type == "tx" && std::ranges::equal((*ret)[2]->m_recv, MakeByteSpan(msg_data_2)));
// Then send a message with a bit error, expecting failure. It's possible this failure does
// not occur immediately (when the length descriptor was modified), but it should come
@ -1404,8 +1404,8 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
tester.SendMessage(uint8_t(19), msg_data_2); // pong short id
ret = tester.Interact();
BOOST_REQUIRE(ret && ret->size() == 2);
BOOST_CHECK((*ret)[0] && (*ret)[0]->m_type == "inv" && Span{(*ret)[0]->m_recv} == MakeByteSpan(msg_data_1));
BOOST_CHECK((*ret)[1] && (*ret)[1]->m_type == "pong" && Span{(*ret)[1]->m_recv} == MakeByteSpan(msg_data_2));
BOOST_CHECK((*ret)[0] && (*ret)[0]->m_type == "inv" && std::ranges::equal((*ret)[0]->m_recv, MakeByteSpan(msg_data_1)));
BOOST_CHECK((*ret)[1] && (*ret)[1]->m_type == "pong" && std::ranges::equal((*ret)[1]->m_recv, MakeByteSpan(msg_data_2)));
// Then send a too-large message.
auto msg_data_3 = g_insecure_rand_ctx.randbytes<uint8_t>(4005000);
@ -1470,8 +1470,8 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
tester.AddMessage("barfoo", {}); // test sending unknown message type
ret = tester.Interact();
BOOST_REQUIRE(ret && ret->size() == 4);
BOOST_CHECK((*ret)[0] && (*ret)[0]->m_type == "addrv2" && Span{(*ret)[0]->m_recv} == MakeByteSpan(msg_data_1));
BOOST_CHECK((*ret)[1] && (*ret)[1]->m_type == "headers" && Span{(*ret)[1]->m_recv} == MakeByteSpan(msg_data_2));
BOOST_CHECK((*ret)[0] && (*ret)[0]->m_type == "addrv2" && std::ranges::equal((*ret)[0]->m_recv, MakeByteSpan(msg_data_1)));
BOOST_CHECK((*ret)[1] && (*ret)[1]->m_type == "headers" && std::ranges::equal((*ret)[1]->m_recv, MakeByteSpan(msg_data_2)));
BOOST_CHECK(!(*ret)[2]);
BOOST_CHECK((*ret)[3] && (*ret)[3]->m_type == "foobar" && (*ret)[3]->m_recv.empty());
tester.ReceiveMessage("barfoo", {});
@ -1538,7 +1538,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
ret = tester.Interact();
BOOST_REQUIRE(ret && ret->size() == 2);
BOOST_CHECK(!(*ret)[0]);
BOOST_CHECK((*ret)[1] && (*ret)[1]->m_type == "block" && Span{(*ret)[1]->m_recv} == MakeByteSpan(msg_data_1));
BOOST_CHECK((*ret)[1] && (*ret)[1]->m_type == "block" && std::ranges::equal((*ret)[1]->m_recv, MakeByteSpan(msg_data_1)));
tester.ReceiveMessage(uint8_t(3), msg_data_2); // "blocktxn" short id
}

View File

@ -14,6 +14,7 @@
#include <wallet/wallet.h>
#include <wallet/walletdb.h>
#include <algorithm>
#include <memory>
namespace wallet {
@ -95,8 +96,8 @@ CTxDestination getNewDestination(CWallet& w, OutputType output_type)
// BytePrefix compares equality with other byte spans that begin with the same prefix.
struct BytePrefix { Span<const std::byte> prefix; };
bool operator<(BytePrefix a, Span<const std::byte> b) { return a.prefix < b.subspan(0, std::min(a.prefix.size(), b.size())); }
bool operator<(Span<const std::byte> a, BytePrefix b) { return a.subspan(0, std::min(a.size(), b.prefix.size())) < b.prefix; }
bool operator<(BytePrefix a, Span<const std::byte> b) { return std::ranges::lexicographical_compare(a.prefix, b.subspan(0, std::min(a.prefix.size(), b.size()))); }
bool operator<(Span<const std::byte> a, BytePrefix b) { return std::ranges::lexicographical_compare(a.subspan(0, std::min(a.size(), b.prefix.size())), b.prefix); }
MockableCursor::MockableCursor(const MockableData& records, bool pass, Span<const std::byte> prefix)
{