53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
// Copyright (c) 2011-2016 The Cryptonote developers
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#pragma once
|
|
|
|
#include "TestNode.h"
|
|
#include "NetworkConfiguration.h"
|
|
|
|
#include <future>
|
|
#include <memory>
|
|
#include <thread>
|
|
|
|
#include <System/Dispatcher.h>
|
|
|
|
|
|
namespace CryptoNote {
|
|
class core;
|
|
class CryptoNoteProtocolHandler;
|
|
class NodeServer;
|
|
class Currency;
|
|
}
|
|
|
|
namespace Tests {
|
|
|
|
class InProcTestNode : public TestNode {
|
|
public:
|
|
InProcTestNode(const TestNodeConfiguration& cfg, const CryptoNote::Currency& currency);
|
|
~InProcTestNode();
|
|
|
|
virtual bool startMining(size_t threadsCount, const std::string &address) override;
|
|
virtual bool stopMining() override;
|
|
virtual bool stopDaemon() override;
|
|
virtual bool getBlockTemplate(const std::string &minerAddress, CryptoNote::Block &blockTemplate, uint64_t &difficulty) override;
|
|
virtual bool submitBlock(const std::string& block) override;
|
|
virtual bool getTailBlockId(Crypto::Hash &tailBlockId) override;
|
|
virtual bool makeINode(std::unique_ptr<CryptoNote::INode>& node) override;
|
|
virtual uint64_t getLocalHeight() override;
|
|
|
|
private:
|
|
|
|
void workerThread(std::promise<std::string>& initPromise);
|
|
|
|
std::unique_ptr<CryptoNote::core> core;
|
|
std::unique_ptr<CryptoNote::CryptoNoteProtocolHandler> protocol;
|
|
std::unique_ptr<CryptoNote::NodeServer> p2pNode;
|
|
|
|
std::thread m_thread;
|
|
const CryptoNote::Currency& m_currency;
|
|
TestNodeConfiguration m_cfg;
|
|
};
|
|
|
|
}
|