aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-13 11:38:37 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-13 11:38:37 +0000
commit10da0a0b7cc70fad0ffde60bdd04926484fb043a (patch)
tree01c2dc48aef06f5494c1782c76b080f0f7de9e21 /src/cryptonote_core/blockchain.cpp
parentunit_tests: fix block reward test using post hard fork settings (diff)
downloadmonero-10da0a0b7cc70fad0ffde60bdd04926484fb043a.tar.xz
add a --fakechain argument for tests
The core tests use the blockchain, and reset it to be able to add test data to it. This does not play nice with the databases, since those will save that data without an explicit save call. We add a fakechain flag that the tests will set, which tells the core and blockchain code to use a separate database, as well as skip a few things like checkpoints and fixup, which only make sense for real data.
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r--src/cryptonote_core/blockchain.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 195b5662e..5823c86f7 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -236,7 +236,7 @@ uint64_t Blockchain::get_current_blockchain_height() const
//------------------------------------------------------------------
//FIXME: possibly move this into the constructor, to avoid accidentally
// dereferencing a null BlockchainDB pointer
-bool Blockchain::init(BlockchainDB* db, const bool testnet)
+bool Blockchain::init(BlockchainDB* db, const bool testnet, const bool fakechain)
{
LOG_PRINT_L3("Blockchain::" << __func__);
CRITICAL_REGION_LOCAL(m_blockchain_lock);
@@ -293,8 +293,11 @@ bool Blockchain::init(BlockchainDB* db, const bool testnet)
{
}
- // ensure we fixup anything we found and fix in the future
- m_db->fixup();
+ if (!fakechain)
+ {
+ // ensure we fixup anything we found and fix in the future
+ m_db->fixup();
+ }
// check how far behind we are
uint64_t top_block_timestamp = m_db->get_top_block_timestamp();
@@ -311,7 +314,7 @@ bool Blockchain::init(BlockchainDB* db, const bool testnet)
m_async_pool.create_thread(boost::bind(&boost::asio::io_service::run, &m_async_service));
#if defined(PER_BLOCK_CHECKPOINT)
- if (m_fast_sync && get_blocks_dat_start(testnet) != nullptr)
+ if (!fakechain && m_fast_sync && get_blocks_dat_start(testnet) != nullptr)
{
if (get_blocks_dat_size(testnet) > 4)
{