Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
signet.cpp
Go to the documentation of this file.
1// Copyright (c) 2020-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <chainparams.h>
7#include <primitives/block.h>
8#include <signet.h>
9#include <streams.h>
11#include <test/fuzz/fuzz.h>
12#include <test/fuzz/util.h>
14#include <util/chaintype.h>
15
16#include <cstdint>
17#include <optional>
18#include <vector>
19
21{
22 static const auto testing_setup = MakeNoLogFileContext<>(ChainType::SIGNET);
23}
24
26{
27 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
28 const std::optional<CBlock> block = ConsumeDeserializable<CBlock>(fuzzed_data_provider, TX_WITH_WITNESS);
29 if (!block) {
30 return;
31 }
32 (void)CheckSignetBlockSolution(*block, Params().GetConsensus());
33 (void)SignetTxs::Create(*block, ConsumeScript(fuzzed_data_provider));
34}
const CChainParams & Params()
Return the currently selected parameters.
static std::optional< SignetTxs > Create(const CBlock &block, const CScript &challenge)
Definition signet.cpp:70
#define FUZZ_TARGET(...)
Definition fuzz.h:35
static constexpr TransactionSerParams TX_WITH_WITNESS
std::unique_ptr< T > MakeNoLogFileContext(const ChainType chain_type=ChainType::REGTEST, TestOpts opts={})
Make a test setup that has disk access to the debug.log file disabled.
bool CheckSignetBlockSolution(const CBlock &block, const Consensus::Params &consensusParams)
Extract signature and check whether a block has a valid solution.
Definition signet.cpp:126
void initialize_signet()
Definition signet.cpp:20
CScript ConsumeScript(FuzzedDataProvider &fuzzed_data_provider, const bool maybe_p2wsh) noexcept
Definition util.cpp:98
std::optional< T > ConsumeDeserializable(FuzzedDataProvider &fuzzed_data_provider, const P &params, const std::optional< size_t > &max_length=std::nullopt) noexcept
Definition util.h:100