2015-05-27 12:08:46 +00:00
|
|
|
// Copyright (c) 2012-2015, The CryptoNote developers, The Bytecoin developers
|
|
|
|
//
|
|
|
|
// This file is part of Bytecoin.
|
|
|
|
//
|
|
|
|
// Bytecoin is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Bytecoin 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 Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
#include "CryptoNoteCore/Currency.h"
|
2015-05-27 12:08:46 +00:00
|
|
|
#include "INode.h"
|
2015-07-30 15:22:07 +00:00
|
|
|
#include "IWalletLegacy.h"
|
2015-05-27 12:08:46 +00:00
|
|
|
#include "System/Dispatcher.h"
|
|
|
|
#include "System/Event.h"
|
2015-07-30 15:22:07 +00:00
|
|
|
#include "WalletLegacy/WalletLegacy.h"
|
2015-05-27 12:08:46 +00:00
|
|
|
|
|
|
|
namespace Tests {
|
|
|
|
namespace Common {
|
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
class TestWalletLegacy : private CryptoNote::IWalletLegacyObserver {
|
2015-05-27 12:08:46 +00:00
|
|
|
public:
|
2015-07-30 15:22:07 +00:00
|
|
|
TestWalletLegacy(System::Dispatcher& dispatcher, const CryptoNote::Currency& currency, CryptoNote::INode& node);
|
|
|
|
~TestWalletLegacy();
|
2015-05-27 12:08:46 +00:00
|
|
|
|
|
|
|
std::error_code init();
|
2015-07-30 15:22:07 +00:00
|
|
|
std::error_code sendTransaction(const std::string& address, uint64_t amount, Crypto::Hash& txHash);
|
2015-05-27 12:08:46 +00:00
|
|
|
void waitForSynchronizationToHeight(uint32_t height);
|
2015-07-30 15:22:07 +00:00
|
|
|
CryptoNote::IWalletLegacy* wallet();
|
2015-05-27 12:08:46 +00:00
|
|
|
CryptoNote::AccountPublicAddress address() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void synchronizationCompleted(std::error_code result) override;
|
2015-07-30 15:22:07 +00:00
|
|
|
virtual void synchronizationProgressUpdated(uint32_t current, uint32_t total) override;
|
2015-05-27 12:08:46 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
System::Dispatcher& m_dispatcher;
|
|
|
|
System::Event m_synchronizationCompleted;
|
|
|
|
System::Event m_someTransactionUpdated;
|
|
|
|
|
|
|
|
CryptoNote::INode& m_node;
|
|
|
|
const CryptoNote::Currency& m_currency;
|
2015-07-30 15:22:07 +00:00
|
|
|
std::unique_ptr<CryptoNote::IWalletLegacy> m_wallet;
|
|
|
|
std::unique_ptr<CryptoNote::IWalletLegacyObserver> m_walletObserver;
|
2015-05-27 12:08:46 +00:00
|
|
|
uint32_t m_currentHeight;
|
|
|
|
uint32_t m_synchronizedHeight;
|
|
|
|
std::error_code m_lastSynchronizationResult;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|