diff --git a/src/Makefile.test.include b/src/Makefile.test.include --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -111,7 +111,8 @@ test/univalue_tests.cpp \ test/util_tests.cpp \ test/validation_tests.cpp \ - test/work_comparator_tests.cpp + test/work_comparator_tests.cpp \ + rpc/test/server_tests.cpp if ENABLE_WALLET BITCOIN_TESTS += \ diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -798,7 +798,7 @@ HelpExampleCli("estimatefee", "6")); } - if (!IsDeprecatedRPCEnabled("estimatefee")) { + if (!IsDeprecatedRPCEnabled(gArgs, "estimatefee")) { throw JSONRPCError( RPC_METHOD_DEPRECATED, "estimatefee is deprecated and will be fully removed in v0.17. " diff --git a/src/rpc/server.h b/src/rpc/server.h --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -11,6 +11,7 @@ #include "rpc/jsonrpcrequest.h" #include "rpc/protocol.h" #include "uint256.h" +#include "util.h" #include #include @@ -243,7 +244,7 @@ const ContextFreeRPCCommand *pcmd); }; -bool IsDeprecatedRPCEnabled(const std::string &method); +bool IsDeprecatedRPCEnabled(ArgsManager &args, const std::string &method); extern CRPCTable tableRPC; diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -407,9 +407,9 @@ return fRPCInWarmup; } -bool IsDeprecatedRPCEnabled(const std::string &method) { +bool IsDeprecatedRPCEnabled(ArgsManager &args, const std::string &method) { const std::vector enabled_methods = - gArgs.GetArgs("-deprecatedrpc"); + args.GetArgs("-deprecatedrpc"); return find(enabled_methods.begin(), enabled_methods.end(), method) != enabled_methods.end(); diff --git a/src/rpc/test/server_tests.cpp b/src/rpc/test/server_tests.cpp new file mode 100644 --- /dev/null +++ b/src/rpc/test/server_tests.cpp @@ -0,0 +1,23 @@ +#include "rpc/server.h" +#include "test/test_bitcoin.h" +#include "util.h" + +#include +#include + +#include + +BOOST_FIXTURE_TEST_SUITE(server_tests, BasicTestingSetup) + +BOOST_AUTO_TEST_CASE(server_IsDeprecatedRPCEnabled) { + ArgsManager testArgs; + const char *argv_test[] = {"bitcoind", "-deprecatedrpc=foo", + "-deprecatedrpc=bar"}; + + testArgs.ParseParameters(3, (char **)argv_test); + BOOST_CHECK(IsDeprecatedRPCEnabled(testArgs, "foo") == true); + BOOST_CHECK(IsDeprecatedRPCEnabled(testArgs, "bar") == true); + BOOST_CHECK(IsDeprecatedRPCEnabled(testArgs, "bob") == false); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -126,6 +126,9 @@ validation_tests.cpp work_comparator_tests.cpp + # RPC Tests + ../rpc/test/server_tests.cpp + # Tests generated from JSON ${JSON_HEADERS} )