Files
thehub/testing/common/MockBlockValidation.h
T

78 lines
2.7 KiB
C++
Raw Permalink Normal View History

2018-08-14 19:01:37 +02:00
/*
* This file is part of the Flowee project
* Copyright (c) 2015 The Bitcoin Core developers
* Copyright (C) 2017-2018 Tom Zander <tomz@freedommail.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MOCKBLOCKVALIDATION_H
#define MOCKBLOCKVALIDATION_H
2019-03-13 14:50:11 +01:00
#include <primitives/key.h>
2018-08-14 19:01:37 +02:00
#include <txmempool.h>
#include <validation/Engine.h>
#include <primitives/script.h>
2018-08-14 19:01:37 +02:00
#include <primitives/FastBlock.h>
class MockBlockValidation : public Validation::Engine {
public:
MockBlockValidation();
~MockBlockValidation();
void initSingletons();
FastBlock createBlock(CBlockIndex *parent, const CScript& scriptPubKey, const std::vector<CTransaction>& txns = std::vector<CTransaction>()) const;
/// short version of the above
FastBlock createBlock(CBlockIndex *parent);
/**
* @brief appendGenesis creates the standard reg-test genesis and appends.
* This will only succeed if the current chain (Params()) is REGTEST
*/
void appendGenesis();
enum OutputType {
EmptyOutScript,
2018-12-28 12:10:28 +01:00
StandardOutScript,
FullOutScript // full p2pkh output script
2018-08-14 19:01:37 +02:00
};
/**
* @brief Append a list of blocks to the block-validator and wait for them to be validated.
* @param blocks the amount of blocks to add to the blockchain-tip.
* @param coinbaseKey [out] an empty key we will initialize and use as coinbase.
* @param out one of the OutputType members.
*/
std::vector<FastBlock> appendChain(int blocks, CKey &coinbaseKey, OutputType out = StandardOutScript);
inline std::vector<FastBlock> appendChain(int blocks, OutputType out = StandardOutScript) {
CKey key;
return appendChain(blocks, key, out);
}
/**
* @brief This creates a chain of blocks on top of a random index.
* @param parent the index that is to be extended
* @param blocks the amount of blocks to build.
* @return The full list of blocks.
* This method doesn't add the blocks, use appendChain() for that.
*/
std::vector<FastBlock> createChain(CBlockIndex *parent, int blocks) const;
CTxMemPool mp;
};
#endif