mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-03 10:05:51 +00:00
@@ -19,12 +19,14 @@
|
|||||||
|
|
||||||
#include <rpc/handlers/AccountInfo.h>
|
#include <rpc/handlers/AccountInfo.h>
|
||||||
|
|
||||||
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
|
|
||||||
namespace RPC {
|
namespace RPC {
|
||||||
AccountInfoHandler::Result
|
AccountInfoHandler::Result
|
||||||
AccountInfoHandler::process(AccountInfoHandler::Input input, Context const& ctx) const
|
AccountInfoHandler::process(AccountInfoHandler::Input input, Context const& ctx) const
|
||||||
{
|
{
|
||||||
if (!input.account && !input.ident)
|
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 range = sharedPtrBackend_->fetchLedgerRange();
|
||||||
auto const lgrInfoOrStatus = getLedgerInfoFromHashOrSeq(
|
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);
|
auto const accountLedgerObject = sharedPtrBackend_->fetchLedgerObject(accountKeylet.key, lgrInfo.seq, ctx.yield);
|
||||||
|
|
||||||
if (!accountLedgerObject)
|
if (!accountLedgerObject)
|
||||||
return Error{Status{RippledError::rpcACT_NOT_FOUND, "accountNotFound"}};
|
return Error{Status{RippledError::rpcACT_NOT_FOUND}};
|
||||||
|
|
||||||
ripple::STLedgerEntry const sle{
|
ripple::STLedgerEntry const sle{
|
||||||
ripple::SerialIter{accountLedgerObject->data(), accountLedgerObject->size()}, accountKeylet.key};
|
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(account_data), toJson(output.accountData)},
|
||||||
{JS(ledger_hash), output.ledgerHash},
|
{JS(ledger_hash), output.ledgerHash},
|
||||||
{JS(ledger_index), output.ledgerIndex},
|
{JS(ledger_index), output.ledgerIndex},
|
||||||
|
{JS(validated), output.validated},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (output.signerLists)
|
if (output.signerLists)
|
||||||
{
|
{
|
||||||
jv.as_object()[JS(signer_lists)] = boost::json::array();
|
auto signers = boost::json::array();
|
||||||
for (auto const& signerList : output.signerLists.value())
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx) con
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (minIndex > maxIndex)
|
if (minIndex > maxIndex)
|
||||||
return Error{Status{RippledError::rpcINVALID_PARAMS, "invalidIndex"}};
|
return Error{Status{RippledError::rpcLGR_IDXS_INVALID}};
|
||||||
|
|
||||||
if (input.ledgerHash || input.ledgerIndex)
|
if (input.ledgerHash || input.ledgerIndex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ static auto
|
|||||||
generateTestValuesForParametersTest()
|
generateTestValuesForParametersTest()
|
||||||
{
|
{
|
||||||
return std::vector<AccountInfoParamTestCaseBundle>{
|
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{"AccountNotString", R"({"account":1})", "invalidParams", "accountNotString"},
|
||||||
AccountInfoParamTestCaseBundle{"AccountInvalid", R"({"account":"xxx"})", "actMalformed", "accountMalformed"},
|
AccountInfoParamTestCaseBundle{"AccountInvalid", R"({"account":"xxx"})", "actMalformed", "accountMalformed"},
|
||||||
AccountInfoParamTestCaseBundle{"IdentNotString", R"({"ident":1})", "invalidParams", "identNotString"},
|
AccountInfoParamTestCaseBundle{"IdentNotString", R"({"ident":1})", "invalidParams", "identNotString"},
|
||||||
@@ -215,7 +215,7 @@ TEST_F(RPCAccountInfoHandlerTest, AccountNotExsit)
|
|||||||
ASSERT_FALSE(output);
|
ASSERT_FALSE(output);
|
||||||
auto const err = RPC::makeError(output.error());
|
auto const err = RPC::makeError(output.error());
|
||||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
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,
|
"PreviousTxnLgrSeq":2,
|
||||||
"Sequence":2,
|
"Sequence":2,
|
||||||
"TransferRate":0,
|
"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_hash":"{}",
|
||||||
"ledger_index":30,
|
"ledger_index":30,
|
||||||
"signer_lists":
|
"validated":true
|
||||||
[
|
|
||||||
{{
|
|
||||||
"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"
|
|
||||||
}}
|
|
||||||
]
|
|
||||||
}})",
|
}})",
|
||||||
ACCOUNT,
|
ACCOUNT,
|
||||||
INDEX1,
|
INDEX1,
|
||||||
LEDGERHASH,
|
|
||||||
ACCOUNT1,
|
ACCOUNT1,
|
||||||
ACCOUNT2);
|
ACCOUNT2,
|
||||||
|
LEDGERHASH);
|
||||||
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||||
mockBackendPtr->updateRange(10); // min
|
mockBackendPtr->updateRange(10); // min
|
||||||
mockBackendPtr->updateRange(30); // max
|
mockBackendPtr->updateRange(30); // max
|
||||||
|
|||||||
@@ -179,8 +179,8 @@ generateTestValuesForParametersTest()
|
|||||||
"ledger_index_max": 11,
|
"ledger_index_max": 11,
|
||||||
"ledger_index_min": 20
|
"ledger_index_min": 20
|
||||||
})",
|
})",
|
||||||
"invalidParams",
|
"lgrIdxsInvalid",
|
||||||
"invalidIndex"},
|
"Ledger indexes invalid."},
|
||||||
AccountTxParamTestCaseBundle{
|
AccountTxParamTestCaseBundle{
|
||||||
"LedgerIndexMaxMinAndLedgerIndex",
|
"LedgerIndexMaxMinAndLedgerIndex",
|
||||||
R"({
|
R"({
|
||||||
|
|||||||
Reference in New Issue
Block a user