diff options
author | SergioDemianLerner <Sergio.d.Lerner@gmail.com> | 2014-09-04 16:23:42 -0300 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-10-02 13:51:39 +0200 |
commit | f0fd00cb77d91ec9ac729bc4cf35ff7d9f676d8f (patch) | |
tree | a7c6249b856c74dd8600c8244ea9e8331d74eb6c /src/chainparams.cpp | |
parent | 8d132431b4f6a7676482815231cd923d9047d541 (diff) |
Switch testing framework from MAIN to new UNITTEST network
UNITTEST inherites from MAIN but allows synamically changing its parameters using the ModifiableParams() interface
Diffstat (limited to 'src/chainparams.cpp')
-rw-r--r-- | src/chainparams.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 179db5a818..8a00da0bb5 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -214,8 +214,50 @@ public: }; static CRegTestParams regTestParams; +// +// Unit test +// +class CUnitTestParams : public CMainParams, public CModifiableParams { +public: + CUnitTestParams() { + networkID = CBaseChainParams::UNITTEST; + strNetworkID = "unittest"; + nDefaultPort = 18445; + vFixedSeeds.clear(); + vSeeds.clear(); // Regtest mode doesn't have any DNS seeds. + + fRequireRPCPassword = false; + fMiningRequiresPeers = false; + fDefaultCheckMemPool = true; + fAllowMinDifficultyBlocks = false; + fMineBlocksOnDemand = true; + fSkipProofOfWorkCheck = false; + } + virtual bool SkipProofOfWorkCheck() const { return fSkipProofOfWorkCheck; } +protected: + bool fSkipProofOfWorkCheck; +public: + // Published setters to allow changing values in unit test cases + virtual void setSubsidyHalvingInterval(int anSubsidyHalvingInterval) { nSubsidyHalvingInterval=anSubsidyHalvingInterval; } + virtual void setEnforceBlockUpgradeMajority(int anEnforceBlockUpgradeMajority) { nEnforceBlockUpgradeMajority=anEnforceBlockUpgradeMajority; } + virtual void setRejectBlockOutdatedMajority(int anRejectBlockOutdatedMajority) { nRejectBlockOutdatedMajority=anRejectBlockOutdatedMajority; } + virtual void setToCheckBlockUpgradeMajority(int anToCheckBlockUpgradeMajority) { nToCheckBlockUpgradeMajority=anToCheckBlockUpgradeMajority; } + virtual void setDefaultCheckMemPool(bool afDefaultCheckMemPool) { fDefaultCheckMemPool=afDefaultCheckMemPool; } + virtual void setAllowMinDifficultyBlocks(bool afAllowMinDifficultyBlocks) { fAllowMinDifficultyBlocks=afAllowMinDifficultyBlocks; } + virtual void setSkipProofOfWorkCheck(bool afSkipProofOfWorkCheck) { fSkipProofOfWorkCheck = afSkipProofOfWorkCheck; } +}; +static CUnitTestParams unitTestParams; + + static CChainParams *pCurrentParams = 0; +CModifiableParams *ModifiableParams() +{ + assert(pCurrentParams); + assert(pCurrentParams==&unitTestParams); + return (CModifiableParams*)&unitTestParams; +} + const CChainParams &Params() { assert(pCurrentParams); return *pCurrentParams; @@ -229,6 +271,8 @@ CChainParams &Params(CBaseChainParams::Network network) { return testNetParams; case CBaseChainParams::REGTEST: return regTestParams; + case CBaseChainParams::UNITTEST: + return unitTestParams; default: assert(false && "Unimplemented network"); return mainParams; |