Fix mismatches (#630)

Fix #632
This commit is contained in:
cyan317
2023-05-11 17:48:27 +01:00
committed by GitHub
parent 4cae248b5c
commit d548d44a61
4 changed files with 47 additions and 42 deletions

View File

@@ -19,12 +19,14 @@
#include <rpc/handlers/AccountInfo.h>
#include <ripple/protocol/ErrorCodes.h>
namespace RPC {
AccountInfoHandler::Result
AccountInfoHandler::process(AccountInfoHandler::Input input, Context const& ctx) const
{
if (!input.account && !input.ident)
return Error{Status{RippledError::rpcACT_MALFORMED}};
return Error{Status{RippledError::rpcINVALID_PARAMS, ripple::RPC::missing_field_message(JS(account))}};
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = getLedgerInfoFromHashOrSeq(
@@ -40,7 +42,7 @@ AccountInfoHandler::process(AccountInfoHandler::Input input, Context const& ctx)
auto const accountLedgerObject = sharedPtrBackend_->fetchLedgerObject(accountKeylet.key, lgrInfo.seq, ctx.yield);
if (!accountLedgerObject)
return Error{Status{RippledError::rpcACT_NOT_FOUND, "accountNotFound"}};
return Error{Status{RippledError::rpcACT_NOT_FOUND}};
ripple::STLedgerEntry const sle{
ripple::SerialIter{accountLedgerObject->data(), accountLedgerObject->size()}, accountKeylet.key};
@@ -84,13 +86,15 @@ tag_invoke(boost::json::value_from_tag, boost::json::value& jv, AccountInfoHandl
{JS(account_data), toJson(output.accountData)},
{JS(ledger_hash), output.ledgerHash},
{JS(ledger_index), output.ledgerIndex},
{JS(validated), output.validated},
};
if (output.signerLists)
{
jv.as_object()[JS(signer_lists)] = boost::json::array();
auto signers = boost::json::array();
for (auto const& signerList : output.signerLists.value())
jv.as_object()[JS(signer_lists)].as_array().push_back(toJson(signerList));
signers.push_back(toJson(signerList));
jv.as_object()[JS(account_data)].as_object()[JS(signer_lists)] = std::move(signers);
}
}

View File

@@ -47,7 +47,7 @@ AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx) con
}
if (minIndex > maxIndex)
return Error{Status{RippledError::rpcINVALID_PARAMS, "invalidIndex"}};
return Error{Status{RippledError::rpcLGR_IDXS_INVALID}};
if (input.ledgerHash || input.ledgerIndex)
{

View File

@@ -66,7 +66,7 @@ static auto
generateTestValuesForParametersTest()
{
return std::vector<AccountInfoParamTestCaseBundle>{
AccountInfoParamTestCaseBundle{"MissingAccountAndIdent", R"({})", "actMalformed", "Account malformed."},
AccountInfoParamTestCaseBundle{"MissingAccountAndIdent", R"({})", "invalidParams", "Missing field 'account'."},
AccountInfoParamTestCaseBundle{"AccountNotString", R"({"account":1})", "invalidParams", "accountNotString"},
AccountInfoParamTestCaseBundle{"AccountInvalid", R"({"account":"xxx"})", "actMalformed", "accountMalformed"},
AccountInfoParamTestCaseBundle{"IdentNotString", R"({"ident":1})", "invalidParams", "identNotString"},
@@ -215,7 +215,7 @@ TEST_F(RPCAccountInfoHandlerTest, AccountNotExsit)
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
EXPECT_EQ(err.at("error_message").as_string(), "accountNotFound");
EXPECT_EQ(err.at("error_message").as_string(), "Account not found.");
});
}
@@ -296,46 +296,47 @@ TEST_F(RPCAccountInfoHandlerTest, SignerListsTrue)
"PreviousTxnLgrSeq":2,
"Sequence":2,
"TransferRate":0,
"index":"13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8"
"index":"13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8",
"signer_lists":
[
{{
"Flags":0,
"LedgerEntryType":"SignerList",
"OwnerNode":"0",
"PreviousTxnID":"0000000000000000000000000000000000000000000000000000000000000000",
"PreviousTxnLgrSeq":0,
"SignerEntries":
[
{{
"SignerEntry":
{{
"Account":"{}",
"SignerWeight":1
}}
}},
{{
"SignerEntry":
{{
"Account":"{}",
"SignerWeight":1
}}
}}
],
"SignerListID":0,
"SignerQuorum":2,
"index":"A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7"
}}
]
}},
"ledger_hash":"{}",
"ledger_index":30,
"signer_lists":
[
{{
"Flags":0,
"LedgerEntryType":"SignerList",
"OwnerNode":"0",
"PreviousTxnID":"0000000000000000000000000000000000000000000000000000000000000000",
"PreviousTxnLgrSeq":0,
"SignerEntries":
[
{{
"SignerEntry":
{{
"Account":"{}",
"SignerWeight":1
}}
}},
{{
"SignerEntry":
{{
"Account":"{}",
"SignerWeight":1
}}
}}
],
"SignerListID":0,
"SignerQuorum":2,
"index":"A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7"
}}
]
"validated":true
}})",
ACCOUNT,
INDEX1,
LEDGERHASH,
ACCOUNT1,
ACCOUNT2);
ACCOUNT2,
LEDGERHASH);
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max

View File

@@ -179,8 +179,8 @@ generateTestValuesForParametersTest()
"ledger_index_max": 11,
"ledger_index_min": 20
})",
"invalidParams",
"invalidIndex"},
"lgrIdxsInvalid",
"Ledger indexes invalid."},
AccountTxParamTestCaseBundle{
"LedgerIndexMaxMinAndLedgerIndex",
R"({