MicroCore tests started

pull/93/merge
moneroexamples 6 years ago
parent 5f57e47696
commit 8f59acd34c

@ -99,8 +99,8 @@ MicroCore::get_mempool() const
return m_mempool;
}
bool
MicroCore::get_block_from_height(const uint64_t& height, block& blk)
bool
MicroCore::get_block_from_height(uint64_t height, block& blk) const
{
try
@ -118,23 +118,15 @@ MicroCore::get_block_from_height(const uint64_t& height, block& blk)
/**
* Get transaction tx from the blockchain using it hash
*/
bool
MicroCore::get_tx(const crypto::hash& tx_hash, transaction& tx)
MicroCore::get_tx(crypto::hash const& tx_hash, transaction& tx) const
{
if (core_storage.have_tx(tx_hash))
{
// get transaction with given hash
tx = core_storage.get_db().get_tx(tx_hash);
return true;
}
else
{
cerr << "MicroCore::get_tx tx does not exist in blockchain: " << tx_hash << endl;
return false;
}
return true;
}

@ -48,6 +48,9 @@ public:
tx_memory_pool const&
get_mempool() const;
hw::device* const
get_device() const;
template<typename... T>
auto get_output_key(T&&... args)
{
@ -55,55 +58,53 @@ public:
}
template <typename... T>
auto get_transactions(T&&... args)
auto get_transactions(T&&... args) const
{
return core_storage.get_transactions(std::forward<T>(args)...);
}
template <typename... T>
auto get_blocks_range(T&&... args)
auto get_blocks_range(T&&... args) const
{
return core_storage.get_db().get_blocks_range(std::forward<T>(args)...);
}
template <typename... T>
auto have_tx(T&&... args)
auto have_tx(T&&... args) const
{
return core_storage.have_tx(std::forward<T>(args)...);
}
template<typename... T>
auto tx_exists(T&&... args)
auto tx_exists(T&&... args) const
{
return core_storage.get_db().tx_exists(std::forward<T>(args)...);
}
template<typename... T>
auto get_output_tx_and_index(T&&... args)
auto get_output_tx_and_index(T&&... args) const
{
return core_storage.get_db().get_output_tx_and_index(std::forward<T>(args)...);
}
template<typename... T>
auto get_tx_block_height(T&&... args)
auto get_tx_block_height(T&&... args) const
{
return core_storage.get_db().get_tx_block_height(std::forward<T>(args)...);
}
template<typename... T>
auto get_tx_amount_output_indices(T&&... args)
auto get_tx_amount_output_indices(T&&... args) const
{
return core_storage.get_db().get_tx_amount_output_indices(std::forward<T>(args)...);
}
bool
get_block_from_height(const uint64_t& height, block& blk);
get_block_from_height(uint64_t height, block& blk) const;
bool
get_tx(const crypto::hash& tx_hash, transaction& tx);
get_tx(crypto::hash const& tx_hash, transaction& tx) const;
hw::device* const
get_device() const;
};

@ -22,10 +22,10 @@ add_om_test(mysql)
add_om_test(microcore)
SETUP_TARGET_FOR_COVERAGE(
NAME mysql_coverage # New target name
NAME mysql_cov # New target name
EXECUTABLE mysql_tests)
SETUP_TARGET_FOR_COVERAGE(
NAME microcore_coverage # New target name
EXECUTABLE microcore_tests)
NAME microcore_cov # New target name
EXECUTABLE microcore_tests)

@ -37,6 +37,12 @@ class DifferentNetworks :
class BlockchainSetupTest : public DifferentNetworks
{};
TEST_P(BlockchainSetupTest, DefaultConstruction)
{
xmreg::BlockchainSetup bc_setup;
EXPECT_TRUE(true);
}
TEST_P(BlockchainSetupTest, ReadInConfigFile)
{
network_type net_type = GetParam();
@ -232,8 +238,8 @@ public:
static void
SetUpTestCase()
{
string config_path {"../config/config.json"};
config_json = xmreg::BlockchainSetup::read_config(config_path);
}
protected:
@ -242,14 +248,32 @@ protected:
virtual void
SetUp()
{
//bc_setup = xmreg::BlockchainSetup("../config/config.json");
bc_setup = xmreg::BlockchainSetup{net_type, do_not_relay, config_json};
}
//if (config_json.empty())
// FAIL() << "Cant readin_config()";
}
network_type net_type {network_type::STAGENET};
bool do_not_relay {false};
xmreg::BlockchainSetup bc_setup;
xmreg::BlockchainSetup bc_setup;
static json config_json;
};
json MICROCORE_TEST::config_json;
}
TEST_F(MICROCORE_TEST, DefaultConstruction)
{
xmreg::MicroCore mcore;
EXPECT_TRUE(true);
}
TEST_F(MICROCORE_TEST, InitializationSuccess)
{
xmreg::MicroCore mcore;
EXPECT_TRUE(mcore.init(bc_setup.blockchain_path, net_type));
EXPECT_TRUE(mcore.get_core().get_db().is_open());
EXPECT_TRUE(mcore.get_core().get_db().is_read_only());
}
}

Loading…
Cancel
Save