diff --git a/src/config.h b/src/config.h --- a/src/config.h +++ b/src/config.h @@ -38,6 +38,20 @@ bool useCashAddr; }; +// Dummy for subclassing in unittests +class DummyConfig : public Config { +public: + bool SetMaxBlockSize(uint64_t maxBlockSize) override { return false; } + uint64_t GetMaxBlockSize() const override { return 0; } + bool SetBlockPriorityPercentage(int64_t blockPriorityPercentage) override { + return false; + } + uint8_t GetBlockPriorityPercentage() const override { return 0; } + const CChainParams &GetChainParams() const override; + void SetCashAddrEncoding(bool) override {} + bool UseCashAddrEncoding() const override { return false; } +}; + // Temporary woraround. const Config &GetConfig(); diff --git a/src/config.cpp b/src/config.cpp --- a/src/config.cpp +++ b/src/config.cpp @@ -53,3 +53,7 @@ bool GlobalConfig::UseCashAddrEncoding() const { return useCashAddr; } + +const CChainParams &DummyConfig::GetChainParams() const { + return Params(CBaseChainParams::REGTEST); +} diff --git a/src/test/dstencode_tests.cpp b/src/test/dstencode_tests.cpp --- a/src/test/dstencode_tests.cpp +++ b/src/test/dstencode_tests.cpp @@ -11,20 +11,11 @@ namespace { -class DummyCfg : public Config { +class DstCfgDummy : public DummyConfig { public: - DummyCfg() : useCashAddr(false) {} - virtual bool SetMaxBlockSize(uint64_t maxBlockSize) { return false; } - virtual uint64_t GetMaxBlockSize() const { return 0; } - virtual bool SetBlockPriorityPercentage(int64_t blockPriorityPercentage) { - return false; - } - virtual uint8_t GetBlockPriorityPercentage() const { return 0; } - virtual const CChainParams &GetChainParams() const { - return Params(CBaseChainParams::MAIN); - } - virtual void SetCashAddrEncoding(bool b) { useCashAddr = b; } - virtual bool UseCashAddrEncoding() const { return useCashAddr; } + DstCfgDummy() : useCashAddr(false) {} + void SetCashAddrEncoding(bool b) override { useCashAddr = b; } + bool UseCashAddrEncoding() const override { return useCashAddr; } private: bool useCashAddr; @@ -50,7 +41,7 @@ std::string base58_script = "3CWFddi6m4ndiGyKqzYvsFYagqDLPVMTzC"; const CChainParams ¶ms = Params(CBaseChainParams::MAIN); - DummyCfg cfg; + DstCfgDummy cfg; // Check encoding cfg.SetCashAddrEncoding(true);