mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix failing assert in connect RPC (#5235)
This commit is contained in:
59
src/test/rpc/Connect_test.cpp
Normal file
59
src/test/rpc/Connect_test.cpp
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
This file is part of rippled: https://github.com/ripple/rippled
|
||||||
|
Copyright (c) 2025 Ripple Labs Inc.
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
#include <test/jtx.h>
|
||||||
|
#include <xrpl/protocol/jss.h>
|
||||||
|
|
||||||
|
namespace ripple {
|
||||||
|
|
||||||
|
class Connect_test : public beast::unit_test::suite
|
||||||
|
{
|
||||||
|
void
|
||||||
|
testErrors()
|
||||||
|
{
|
||||||
|
testcase("Errors");
|
||||||
|
|
||||||
|
using namespace test::jtx;
|
||||||
|
|
||||||
|
{
|
||||||
|
// standalone mode should fail
|
||||||
|
Env env{*this};
|
||||||
|
BEAST_EXPECT(env.app().config().standalone());
|
||||||
|
|
||||||
|
auto const result = env.rpc("json", "connect", "{}");
|
||||||
|
BEAST_EXPECT(result[jss::result][jss::status] == "error");
|
||||||
|
BEAST_EXPECT(result[jss::result].isMember(jss::error));
|
||||||
|
BEAST_EXPECT(result[jss::result][jss::error] == "notSynced");
|
||||||
|
BEAST_EXPECT(
|
||||||
|
result[jss::result][jss::error_message] ==
|
||||||
|
"Not synced to the network.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
void
|
||||||
|
run() override
|
||||||
|
{
|
||||||
|
testErrors();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BEAST_DEFINE_TESTSUITE(Connect, rpc, ripple);
|
||||||
|
|
||||||
|
} // namespace ripple
|
||||||
@@ -38,7 +38,9 @@ Json::Value
|
|||||||
doConnect(RPC::JsonContext& context)
|
doConnect(RPC::JsonContext& context)
|
||||||
{
|
{
|
||||||
if (context.app.config().standalone())
|
if (context.app.config().standalone())
|
||||||
return "cannot connect in standalone mode";
|
{
|
||||||
|
return RPC::make_error(rpcNOT_SYNCED);
|
||||||
|
}
|
||||||
|
|
||||||
if (!context.params.isMember(jss::ip))
|
if (!context.params.isMember(jss::ip))
|
||||||
return RPC::missing_field_error(jss::ip);
|
return RPC::missing_field_error(jss::ip);
|
||||||
|
|||||||
Reference in New Issue
Block a user