File tree Expand file tree Collapse file tree 7 files changed +9
-3
lines changed Expand file tree Collapse file tree 7 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -1052,7 +1052,9 @@ bool AppInitParameterInteraction(const ArgsManager& args)
1052
1052
if (!g_wallet_init_interface.ParameterInteraction ()) return false ;
1053
1053
1054
1054
// Option to startup with mocktime set (used for regression testing):
1055
- SetMockTime (args.GetIntArg (" -mocktime" , 0 )); // SetMockTime(0) is a no-op
1055
+ if (const auto mocktime{args.GetIntArg (" -mocktime" )}) {
1056
+ SetMockTime (std::chrono::seconds{*mocktime});
1057
+ }
1056
1058
1057
1059
if (args.GetBoolArg (" -peerbloomfilters" , DEFAULT_PEERBLOOMFILTERS))
1058
1060
g_local_services = ServiceFlags (g_local_services | NODE_BLOOM);
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ void initialize_tx_pool()
42
42
{
43
43
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
44
44
g_setup = testing_setup.get ();
45
+ SetMockTime (WITH_LOCK (g_setup->m_node .chainman ->GetMutex (), return g_setup->m_node .chainman ->ActiveTip ()->Time ()));
45
46
46
47
BlockAssembler::Options options;
47
48
options.coinbase_output_script = P2WSH_EMPTY;
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ void initialize_process_message()
44
44
/* chain_type=*/ ChainType::REGTEST,
45
45
{.extra_args = {" -txreconciliation" }});
46
46
g_setup = testing_setup.get ();
47
+ SetMockTime (WITH_LOCK (g_setup->m_node .chainman ->GetMutex (), return g_setup->m_node .chainman ->ActiveTip ()->Time ()));
47
48
for (int i = 0 ; i < 2 * COINBASE_MATURITY; i++) {
48
49
MineBlock (g_setup->m_node , {});
49
50
}
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ void initialize_process_messages()
34
34
/* chain_type=*/ ChainType::REGTEST,
35
35
{.extra_args = {" -txreconciliation" }});
36
36
g_setup = testing_setup.get ();
37
+ SetMockTime (WITH_LOCK (g_setup->m_node .chainman ->GetMutex (), return g_setup->m_node .chainman ->ActiveTip ()->Time ()));
37
38
for (int i = 0 ; i < 2 * COINBASE_MATURITY; i++) {
38
39
MineBlock (g_setup->m_node , {});
39
40
}
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ void initialize_tx_pool()
44
44
{
45
45
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
46
46
g_setup = testing_setup.get ();
47
+ SetMockTime (WITH_LOCK (g_setup->m_node .chainman ->GetMutex (), return g_setup->m_node .chainman ->ActiveTip ()->Time ()));
47
48
48
49
BlockAssembler::Options options;
49
50
options.coinbase_output_script = P2WSH_OP_TRUE;
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ void initialize_chain()
72
72
const auto params{CreateChainParams (ArgsManager{}, ChainType::REGTEST)};
73
73
static const auto chain{CreateBlockChain (2 * COINBASE_MATURITY, *params)};
74
74
g_chain = &chain;
75
+ SetMockTime (chain.back ()->Time ());
75
76
76
77
// Make sure we can generate a valid snapshot.
77
78
sanity_check_snapshot ();
Original file line number Diff line number Diff line change @@ -24,14 +24,13 @@ FUZZ_TARGET(utxo_total_supply)
24
24
{
25
25
SeedRandomStateForTest (SeedRand::ZEROS);
26
26
FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
27
- const auto mock_time{ ConsumeTime (fuzzed_data_provider, /* min=*/ 1296688602 )} ; // regtest genesis block timestamp
27
+ SetMockTime ( ConsumeTime (fuzzed_data_provider, /* min=*/ 1296688602 )) ; // regtest genesis block timestamp
28
28
/* * The testing setup that creates a chainman only (no chainstate) */
29
29
ChainTestingSetup test_setup{
30
30
ChainType::REGTEST,
31
31
{
32
32
.extra_args = {
33
33
" -testactivationheight=bip34@2" ,
34
- strprintf (" -mocktime=%d" , mock_time).c_str ()
35
34
},
36
35
},
37
36
};
You can’t perform that action at this time.
0 commit comments