Change an error code in account_lines to match rippled (#742)

Fixes #741
This commit is contained in:
Alex Kremer
2023-07-07 16:50:32 +01:00
committed by GitHub
parent 9f4f5d319e
commit 616f0176c9
2 changed files with 43 additions and 5 deletions

View File

@@ -90,8 +90,11 @@ public:
spec([[maybe_unused]] uint32_t apiVersion) const
{
static auto const rpcSpec = RpcSpec{
{JS(account), validation::Required{}, validation::AccountValidator},
{JS(peer), validation::Type<std::string>{}, validation::AccountValidator},
{JS(account),
validation::Required{},
validation::WithCustomError{validation::AccountValidator, Status(RippledError::rpcACT_MALFORMED)}},
{JS(peer),
validation::WithCustomError{validation::AccountValidator, Status(RippledError::rpcACT_MALFORMED)}},
{JS(ignore_default), validation::Type<bool>{}},
{JS(ledger_hash), validation::Uint256HexStringValidator},
{JS(limit), validation::Type<uint32_t>{}, validation::Between{10, 400}},

View File

@@ -206,7 +206,7 @@ TEST_F(RPCAccountLinesHandlerTest, AccountInvalidFormat)
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "actMalformed");
EXPECT_EQ(err.at("error_message").as_string(), "accountMalformed");
EXPECT_EQ(err.at("error_message").as_string(), "Account malformed.");
});
}
@@ -223,8 +223,43 @@ TEST_F(RPCAccountLinesHandlerTest, AccountNotString)
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
EXPECT_EQ(err.at("error_message").as_string(), "accountNotString");
EXPECT_EQ(err.at("error").as_string(), "actMalformed");
EXPECT_EQ(err.at("error_message").as_string(), "Account malformed.");
});
}
TEST_F(RPCAccountLinesHandlerTest, PeerInvalidFormat)
{
runSpawn([this](auto& yield) {
auto const handler = AnyHandler{AccountLinesHandler{mockBackendPtr}};
auto const input = json::parse(
R"({
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"peer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jp"
})");
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "actMalformed");
EXPECT_EQ(err.at("error_message").as_string(), "Account malformed.");
});
}
TEST_F(RPCAccountLinesHandlerTest, PeerNotString)
{
runSpawn([this](auto& yield) {
auto const handler = AnyHandler{AccountLinesHandler{mockBackendPtr}};
auto const input = json::parse(
R"({
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"peer": 12
})");
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "actMalformed");
EXPECT_EQ(err.at("error_message").as_string(), "Account malformed.");
});
}