From e882e3c06f82b286e8ddcd0bdf7a3e7a9c7287e7 Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Wed, 7 Mar 2018 09:33:55 -0700 Subject: [PATCH] Clean up --- src/deprecation.cpp | 6 ++++++ src/gtest/test_deprecation.cpp | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/deprecation.cpp b/src/deprecation.cpp index 7f5749319..9f394e720 100644 --- a/src/deprecation.cpp +++ b/src/deprecation.cpp @@ -8,10 +8,16 @@ #include "init.h" #include "ui_interface.h" #include "util.h" +#include "chainparams.h" static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION); void EnforceNodeDeprecation(int nHeight, bool forceLogging) { + + // Do not enforce deprecation in regtest or on testnet + std::string networkID = Params().NetworkIDString(); + if (networkID != "main") return; + int blocksToDeprecation = DEPRECATION_HEIGHT - nHeight; bool disableDeprecation = (GetArg("-disabledeprecation", "") == CLIENT_VERSION_STR); if (blocksToDeprecation <= 0) { diff --git a/src/gtest/test_deprecation.cpp b/src/gtest/test_deprecation.cpp index 72d98cf91..005c9c3cc 100644 --- a/src/gtest/test_deprecation.cpp +++ b/src/gtest/test_deprecation.cpp @@ -6,6 +6,7 @@ #include "init.h" #include "ui_interface.h" #include "util.h" +#include "chainparams.h" using ::testing::StrictMock; @@ -32,11 +33,13 @@ protected: virtual void SetUp() { uiInterface.ThreadSafeMessageBox.disconnect_all_slots(); uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, &mock_, _1, _2, _3)); + SelectParams(CBaseChainParams::MAIN); + } virtual void TearDown() { fRequestShutdown = false; - mapArgs["-disabledeprecation"] = ""; + mapArgs.clear(); } StrictMock mock_; @@ -102,4 +105,18 @@ TEST_F(DeprecationTest, DeprecatedNodeKeepsRunningIfCurrentVersionDisabled) { EXPECT_CALL(mock_, ThreadSafeMessageBox(::testing::_, "", CClientUIInterface::MSG_ERROR)); EnforceNodeDeprecation(DEPRECATION_HEIGHT); EXPECT_FALSE(ShutdownRequested()); +} + +TEST_F(DeprecationTest, DeprecatedNodeIgnoredOnRegtest) { + SelectParams(CBaseChainParams::REGTEST); + EXPECT_FALSE(ShutdownRequested()); + EnforceNodeDeprecation(DEPRECATION_HEIGHT+1); + EXPECT_FALSE(ShutdownRequested()); +} + +TEST_F(DeprecationTest, DeprecatedNodeIgnoredOnTestnet) { + SelectParams(CBaseChainParams::TESTNET); + EXPECT_FALSE(ShutdownRequested()); + EnforceNodeDeprecation(DEPRECATION_HEIGHT+1); + EXPECT_FALSE(ShutdownRequested()); } \ No newline at end of file