Bitcoin ABC  0.24.7
P2P Digital Currency
server_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019 The Bitcoin developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <rpc/server.h>
6 #include <test/util/setup_common.h>
7 #include <util/system.h>
8 
9 #include <boost/test/unit_test.hpp>
10 
11 #include <cstdint>
12 #include <vector>
13 
14 BOOST_FIXTURE_TEST_SUITE(server_tests, BasicTestingSetup)
15 
16 BOOST_AUTO_TEST_CASE(server_IsDeprecatedRPCEnabled) {
17  ArgsManager testArgs;
18  testArgs.AddArg("-deprecatedrpc", "", ArgsManager::ALLOW_ANY,
20 
21  const char *argv_test[] = {"bitcoind", "-deprecatedrpc=foo",
22  "-deprecatedrpc=bar"};
23 
24  std::string error;
25  BOOST_CHECK_MESSAGE(testArgs.ParseParameters(3, (char **)argv_test, error),
26  error);
27 
28  BOOST_CHECK(IsDeprecatedRPCEnabled(testArgs, "foo") == true);
29  BOOST_CHECK(IsDeprecatedRPCEnabled(testArgs, "bar") == true);
30  BOOST_CHECK(IsDeprecatedRPCEnabled(testArgs, "bob") == false);
31 }
32 
ArgsManager::ALLOW_ANY
@ ALLOW_ANY
Definition: system.h:159
BOOST_FIXTURE_TEST_SUITE
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
ArgsManager::AddArg
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:565
OptionsCategory::OPTIONS
@ OPTIONS
ArgsManager::ParseParameters
NODISCARD bool ParseParameters(int argc, const char *const argv[], std::string &error)
Definition: system.cpp:317
system.h
ArgsManager
Definition: system.h:152
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(server_IsDeprecatedRPCEnabled)
Definition: server_tests.cpp:16
IsDeprecatedRPCEnabled
bool IsDeprecatedRPCEnabled(const ArgsManager &args, const std::string &method)
Definition: server.cpp:398
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:48
server.h
BOOST_CHECK
#define BOOST_CHECK(expr)
Definition: object.cpp:17
BOOST_AUTO_TEST_SUITE_END
#define BOOST_AUTO_TEST_SUITE_END()
Definition: object.cpp:16