diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-02-08 18:47:56 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-02-08 18:52:00 +0000 |
commit | a333c42cdeab4675c22df25255313752d81a2d4e (patch) | |
tree | 97abd7cc6a0a06375979eebfdc72913b7940bef8 /src/cryptonote_core/blockchain.cpp | |
parent | core_tests: allow setting miner tx max_outs when creating a block (diff) | |
download | monero-a333c42cdeab4675c22df25255313752d81a2d4e.tar.xz |
core_tests: add tests for hard fork behaviors (MRL-0004)
We also replace the --fakechain option with an optional structure
containing details about configuration for the core/blockchain,
for test purposes. This seems more future friendly.
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 70953f3e7..7dd0aca42 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -50,6 +50,7 @@ #include "warnings.h" #include "crypto/hash.h" #include "cryptonote_core/checkpoints_create.h" +#include "cryptonote_core/cryptonote_core.h" #if defined(PER_BLOCK_CHECKPOINT) #include "blocks/blocks.h" #endif @@ -252,11 +253,13 @@ 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, const bool fakechain) +bool Blockchain::init(BlockchainDB* db, const bool testnet, const cryptonote::test_options *test_options) { LOG_PRINT_L3("Blockchain::" << __func__); CRITICAL_REGION_LOCAL(m_blockchain_lock); + bool fakechain = test_options != NULL; + if (db == nullptr) { LOG_ERROR("Attempted to init Blockchain with null DB"); @@ -273,12 +276,19 @@ bool Blockchain::init(BlockchainDB* db, const bool testnet, const bool fakechain m_testnet = testnet; if (m_hardfork == nullptr) { - if (m_testnet) + if (fakechain) + m_hardfork = new HardFork(*db, 1, 0); + else if (m_testnet) m_hardfork = new HardFork(*db, 1, testnet_hard_fork_version_1_till); else m_hardfork = new HardFork(*db, 1, mainnet_hard_fork_version_1_till); } - if (m_testnet) + if (fakechain) + { + for (size_t n = 0; test_options->hard_forks[n].first; ++n) + m_hardfork->add_fork(test_options->hard_forks[n].first, test_options->hard_forks[n].second, 0, n + 1); + } + else if (m_testnet) { for (size_t n = 0; n < sizeof(testnet_hard_forks) / sizeof(testnet_hard_forks[0]); ++n) m_hardfork->add_fork(testnet_hard_forks[n].version, testnet_hard_forks[n].height, testnet_hard_forks[n].threshold, testnet_hard_forks[n].time); @@ -348,11 +358,11 @@ bool Blockchain::init(BlockchainDB* db, const bool testnet, const bool fakechain return true; } //------------------------------------------------------------------ -bool Blockchain::init(BlockchainDB* db, HardFork*& hf, const bool testnet, const bool fakechain) +bool Blockchain::init(BlockchainDB* db, HardFork*& hf, const bool testnet) { if (hf != nullptr) m_hardfork = hf; - bool res = init(db, testnet, fakechain); + bool res = init(db, testnet, NULL); if (hf == nullptr) hf = m_hardfork; return res; |