2016-01-18 15:33:29 +00:00
|
|
|
// Copyright (c) 2011-2016 The Cryptonote developers
|
2015-09-18 11:55:31 +00:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2015-05-27 12:08:46 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "TestNode.h"
|
|
|
|
#include "NetworkConfiguration.h"
|
|
|
|
|
|
|
|
#include <future>
|
|
|
|
#include <memory>
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
#include <System/Dispatcher.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace CryptoNote {
|
|
|
|
class core;
|
2015-07-30 15:22:07 +00:00
|
|
|
class CryptoNoteProtocolHandler;
|
|
|
|
class NodeServer;
|
2015-05-27 12:08:46 +00:00
|
|
|
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;
|
2015-07-30 15:22:07 +00:00
|
|
|
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;
|
2015-05-27 12:08:46 +00:00
|
|
|
virtual uint64_t getLocalHeight() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void workerThread(std::promise<std::string>& initPromise);
|
|
|
|
|
|
|
|
std::unique_ptr<CryptoNote::core> core;
|
2015-07-30 15:22:07 +00:00
|
|
|
std::unique_ptr<CryptoNote::CryptoNoteProtocolHandler> protocol;
|
|
|
|
std::unique_ptr<CryptoNote::NodeServer> p2pNode;
|
2015-05-27 12:08:46 +00:00
|
|
|
|
|
|
|
std::thread m_thread;
|
|
|
|
const CryptoNote::Currency& m_currency;
|
|
|
|
TestNodeConfiguration m_cfg;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|