Bitcoin Core  22.99.0
P2P Digital Currency
signet.cpp
Go to the documentation of this file.
1 // Copyright (c) 2020-2021 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>
6 #include <consensus/validation.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>
13 #include <test/util/setup_common.h>
14 
15 #include <cstdint>
16 #include <optional>
17 #include <vector>
18 
20 {
21  static const auto testing_setup = MakeNoLogFileContext<>(CBaseChainParams::SIGNET);
22 }
23 
25 {
26  FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
27  const std::optional<CBlock> block = ConsumeDeserializable<CBlock>(fuzzed_data_provider);
28  if (!block) {
29  return;
30  }
31  (void)CheckSignetBlockSolution(*block, Params().GetConsensus());
32  (void)SignetTxs::Create(*block, ConsumeScript(fuzzed_data_provider));
33 }
block.h
SignetTxs::Create
static std::optional< SignetTxs > Create(const CBlock &block, const CScript &challenge)
Definition: signet.cpp:68
streams.h
setup_common.h
validation.h
util.h
CheckSignetBlockSolution
bool CheckSignetBlockSolution(const CBlock &block, const Consensus::Params &consensusParams)
Extract signature and check whether a block has a valid solution.
Definition: signet.cpp:124
CChainParams::GetConsensus
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:82
chainparams.h
ConsumeScript
CScript ConsumeScript(FuzzedDataProvider &fuzzed_data_provider, const std::optional< size_t > &max_length, const bool maybe_p2wsh) noexcept
Definition: util.cpp:285
FuzzedDataProvider.h
FUZZ_TARGET_INIT
FUZZ_TARGET_INIT(signet, initialize_signet)
Definition: signet.cpp:24
signet.h
fuzz.h
FuzzedDataProvider
Definition: FuzzedDataProvider.h:31
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:561
initialize_signet
void initialize_signet()
Definition: signet.cpp:19
CBaseChainParams::SIGNET
static const std::string SIGNET
Definition: chainparamsbase.h:24