Changeset View
Changeset View
Standalone View
Standalone View
src/test/excessiveblock_tests.cpp
// Copyright (c) 2017-2020 The Bitcoin developers | // Copyright (c) 2017-2020 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <util/ref.h> | |||||
#include <test/util/setup_common.h> | #include <test/util/setup_common.h> | ||||
#include <boost/algorithm/string.hpp> | #include <boost/algorithm/string.hpp> | ||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
#include <limits> | #include <limits> | ||||
#include <string> | #include <string> | ||||
extern UniValue CallRPC(std::string strMethod); | extern UniValue CallRPC(const std::string &args, const util::Ref &context); | ||||
BOOST_FIXTURE_TEST_SUITE(excessiveblock_tests, TestingSetup) | class ExcessiveBlockTestingSetup : public TestingSetup { | ||||
public: | |||||
UniValue CallRPC(const std::string &args) { | |||||
const util::Ref context{m_node}; | |||||
return ::CallRPC(args, context); | |||||
} | |||||
}; | |||||
BOOST_FIXTURE_TEST_SUITE(excessiveblock_tests, ExcessiveBlockTestingSetup) | |||||
BOOST_AUTO_TEST_CASE(excessiveblock_rpc) { | BOOST_AUTO_TEST_CASE(excessiveblock_rpc) { | ||||
BOOST_CHECK_NO_THROW(CallRPC("getexcessiveblock")); | BOOST_CHECK_NO_THROW(CallRPC("getexcessiveblock")); | ||||
BOOST_CHECK_THROW(CallRPC("setexcessiveblock"), std::runtime_error); | BOOST_CHECK_THROW(CallRPC("setexcessiveblock"), std::runtime_error); | ||||
BOOST_CHECK_THROW(CallRPC("setexcessiveblock not_uint"), | BOOST_CHECK_THROW(CallRPC("setexcessiveblock not_uint"), | ||||
std::runtime_error); | std::runtime_error); | ||||
BOOST_CHECK_THROW(CallRPC("setexcessiveblock 1000000 not_uint"), | BOOST_CHECK_THROW(CallRPC("setexcessiveblock 1000000 not_uint"), | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |