From 72af215a362e6b13f3494702e6a8acbaaa8a994b Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Tue, 12 Mar 2019 09:33:53 +0100 Subject: [PATCH] Fix CreateNewBlock_validity by not holding cs_main when calling createAndProcessEmptyBlock --- src/test/miner_tests.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index c58986b43..e9c7123b1 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -257,6 +257,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) createAndProcessEmptyBlock(); } + { LOCK(cs_main); // Just to make sure we can still make simple blocks @@ -507,9 +508,13 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++) chainActive.Tip()->GetAncestor(chainActive.Tip()->nHeight - i)->nTime += 512; //Trick the MedianTimePast + } // unlock cs_main while calling createAndProcessEmptyBlock + // Mine an empty block createAndProcessEmptyBlock(); + LOCK(cs_main); + SetMockTime(chainActive.Tip()->GetMedianTimePast() + 1); BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));