Auto merge of #3069 - braddmiller:3034-disable-auto-dep, r=daira
Disable auto-deprecation on regtest and testnet Prevents auto-senescence based on @str4d's recommendation to early return out of `EnforceNodeDeprecation` if net is not `main`. Closes #2876. Co-authored-by: Marshall Gaucher <marshall@z.cash>
This commit is contained in:
commit
01c31ec57f
|
@ -8,10 +8,16 @@
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "chainparams.h"
|
||||||
|
|
||||||
static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION);
|
static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION);
|
||||||
|
|
||||||
void EnforceNodeDeprecation(int nHeight, bool forceLogging) {
|
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;
|
int blocksToDeprecation = DEPRECATION_HEIGHT - nHeight;
|
||||||
bool disableDeprecation = (GetArg("-disabledeprecation", "") == CLIENT_VERSION_STR);
|
bool disableDeprecation = (GetArg("-disabledeprecation", "") == CLIENT_VERSION_STR);
|
||||||
if (blocksToDeprecation <= 0) {
|
if (blocksToDeprecation <= 0) {
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "chainparams.h"
|
||||||
|
|
||||||
using ::testing::StrictMock;
|
using ::testing::StrictMock;
|
||||||
|
|
||||||
|
@ -32,11 +33,13 @@ protected:
|
||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
uiInterface.ThreadSafeMessageBox.disconnect_all_slots();
|
uiInterface.ThreadSafeMessageBox.disconnect_all_slots();
|
||||||
uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, &mock_, _1, _2, _3));
|
uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, &mock_, _1, _2, _3));
|
||||||
|
SelectParams(CBaseChainParams::MAIN);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void TearDown() {
|
virtual void TearDown() {
|
||||||
fRequestShutdown = false;
|
fRequestShutdown = false;
|
||||||
mapArgs["-disabledeprecation"] = "";
|
mapArgs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
StrictMock<MockUIInterface> mock_;
|
StrictMock<MockUIInterface> mock_;
|
||||||
|
@ -103,3 +106,17 @@ TEST_F(DeprecationTest, DeprecatedNodeKeepsRunningIfCurrentVersionDisabled) {
|
||||||
EnforceNodeDeprecation(DEPRECATION_HEIGHT);
|
EnforceNodeDeprecation(DEPRECATION_HEIGHT);
|
||||||
EXPECT_FALSE(ShutdownRequested());
|
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());
|
||||||
|
}
|
Loading…
Reference in New Issue