aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/cryptonote_core.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2018-07-19 13:35:25 -0500
committerluigi1111 <luigi1111w@gmail.com>2018-07-19 13:35:25 -0500
commit025187e6c9206fc970b66f7459919ce0131fc612 (patch)
tree364babe92ebb444dd2592e73789e66ba17a3f05a /src/cryptonote_core/cryptonote_core.cpp
parent33122ab8a69843c046f9b031b4ac23ad331b10e5 (diff)
parent207b66ecc28833f1cb211d3489df96fc42ebab28 (diff)
downloadmonzero-core-025187e6c9206fc970b66f7459919ce0131fc612.tar.gz
monzero-core-025187e6c9206fc970b66f7459919ce0131fc612.tar.xz
monzero-core-025187e6c9206fc970b66f7459919ce0131fc612.zip
Merge pull request #3854
149da42 db_lmdb: enable batch transactions by default (stoffu) 34cb6b4 add --regtest and --fixed-difficulty for regression testing (vicsn) 9e1403e update get_info RPC and bump RPC version (vicsn) 207b66e first new functional tests (vicsn)
Diffstat (limited to 'src/cryptonote_core/cryptonote_core.cpp')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 910bf0c1f..18490c65e 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -76,6 +76,16 @@ namespace cryptonote
, "Run on stagenet. The wallet must be launched with --stagenet flag."
, false
};
+ const command_line::arg_descriptor<bool> arg_regtest_on = {
+ "regtest"
+ , "Run in a regression testing mode."
+ , false
+ };
+ const command_line::arg_descriptor<difficulty_type> arg_fixed_difficulty = {
+ "fixed-difficulty"
+ , "Fixed difficulty used for testing."
+ , 0
+ };
const command_line::arg_descriptor<std::string, false, true, 2> arg_data_dir = {
"data-dir"
, "Specify data directory"
@@ -251,6 +261,8 @@ namespace cryptonote
command_line::add_arg(desc, arg_testnet_on);
command_line::add_arg(desc, arg_stagenet_on);
+ command_line::add_arg(desc, arg_regtest_on);
+ command_line::add_arg(desc, arg_fixed_difficulty);
command_line::add_arg(desc, arg_dns_checkpoints);
command_line::add_arg(desc, arg_prep_blocks_threads);
command_line::add_arg(desc, arg_fast_block_sync);
@@ -373,7 +385,8 @@ namespace cryptonote
{
start_time = std::time(nullptr);
- if (test_options != NULL)
+ const bool regtest = command_line::get_arg(vm, arg_regtest_on);
+ if (test_options != NULL || regtest)
{
m_nettype = FAKECHAIN;
}
@@ -430,6 +443,16 @@ namespace cryptonote
blockchain_db_sync_mode sync_mode = db_defaultsync;
uint64_t blocks_per_sync = 1;
+ if (m_nettype == FAKECHAIN)
+ {
+ // reset the db by removing the database file before opening it
+ if (!db->remove_data_file(filename))
+ {
+ MERROR("Failed to remove data file in " << filename);
+ return false;
+ }
+ }
+
try
{
uint64_t db_flags = 0;
@@ -507,7 +530,12 @@ namespace cryptonote
m_blockchain_storage.set_user_options(blocks_threads,
blocks_per_sync, sync_mode, fast_sync);
- r = m_blockchain_storage.init(db.release(), m_nettype, m_offline, test_options);
+ const std::pair<uint8_t, uint64_t> regtest_hard_forks[3] = {std::make_pair(1, 0), std::make_pair(Blockchain::get_hard_fork_heights(MAINNET).back().version, 1), std::make_pair(0, 0)};
+ const cryptonote::test_options regtest_test_options = {
+ regtest_hard_forks
+ };
+ const difficulty_type fixed_difficulty = command_line::get_arg(vm, arg_fixed_difficulty);
+ r = m_blockchain_storage.init(db.release(), m_nettype, m_offline, regtest ? &regtest_test_options : test_options, fixed_difficulty);
r = m_mempool.init(max_txpool_size);
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize memory pool");