mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-18 18:15:50 +00:00
Add pseudo account type to injected data in RPC account_info result
- Low hanging fruit
This commit is contained in:
@@ -500,6 +500,7 @@ JSS(propose_seq); // out: LedgerPropose
|
||||
JSS(proposers); // out: NetworkOPs, LedgerConsensus
|
||||
JSS(protocol); // out: NetworkOPs, PeerImp
|
||||
JSS(proxied); // out: RPC ping
|
||||
JSS(pseudo_account); // out: AccountInfo
|
||||
JSS(pubkey_node); // out: NetworkOPs
|
||||
JSS(pubkey_publisher); // out: ValidatorList
|
||||
JSS(pubkey_validator); // out: NetworkOPs, ValidatorList
|
||||
|
||||
@@ -245,6 +245,30 @@ class LoanBroker_test : public beast::unit_test::suite
|
||||
BEAST_EXPECT(pseudo->at(sfLoanBrokerID) == keylet.key);
|
||||
}
|
||||
|
||||
{
|
||||
// Get the AccountInfo RPC result for the broker pseudo-account
|
||||
std::string const pseudoStr = to_string(pseudoAccount.id());
|
||||
auto const accountInfo = env.rpc("account_info", pseudoStr);
|
||||
if (BEAST_EXPECT(accountInfo.isObject()))
|
||||
{
|
||||
auto const& accountData =
|
||||
accountInfo[jss::result][jss::account_data];
|
||||
if (BEAST_EXPECT(accountData.isObject()))
|
||||
{
|
||||
BEAST_EXPECT(accountData[jss::Account] == pseudoStr);
|
||||
BEAST_EXPECT(
|
||||
accountData[sfLoanBrokerID] ==
|
||||
to_string(keylet.key));
|
||||
}
|
||||
auto const& pseudoInfo =
|
||||
accountInfo[jss::result][jss::pseudo_account];
|
||||
if (BEAST_EXPECT(pseudoInfo.isObject()))
|
||||
{
|
||||
BEAST_EXPECT(pseudoInfo[jss::type] == "LoanBroker");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto verifyCoverAmount =
|
||||
[&env, &vault, &pseudoAccount, &broker, &keylet, this](auto n) {
|
||||
using namespace jtx;
|
||||
@@ -614,6 +638,30 @@ class LoanBroker_test : public beast::unit_test::suite
|
||||
// Create and update Loan Brokers
|
||||
for (auto const& vault : vaults)
|
||||
{
|
||||
{
|
||||
// Get the AccountInfo RPC result for the vault pseudo-account
|
||||
std::string const pseudoStr =
|
||||
to_string(vault.pseudoAccount.id());
|
||||
auto const accountInfo = env.rpc("account_info", pseudoStr);
|
||||
if (BEAST_EXPECT(accountInfo.isObject()))
|
||||
{
|
||||
auto const& accountData =
|
||||
accountInfo[jss::result][jss::account_data];
|
||||
if (BEAST_EXPECT(accountData.isObject()))
|
||||
{
|
||||
BEAST_EXPECT(accountData[jss::Account] == pseudoStr);
|
||||
BEAST_EXPECT(
|
||||
accountData[sfVaultID] == to_string(vault.vaultID));
|
||||
}
|
||||
auto const& pseudoInfo =
|
||||
accountInfo[jss::result][jss::pseudo_account];
|
||||
if (BEAST_EXPECT(pseudoInfo.isObject()))
|
||||
{
|
||||
BEAST_EXPECT(pseudoInfo[jss::type] == "Vault");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using namespace loanBroker;
|
||||
|
||||
auto badKeylet = keylet::vault(alice.id(), env.seq(alice));
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <xrpld/app/main/Application.h>
|
||||
#include <xrpld/app/misc/TxQ.h>
|
||||
#include <xrpld/ledger/ReadView.h>
|
||||
#include <xrpld/ledger/View.h>
|
||||
#include <xrpld/rpc/Context.h>
|
||||
#include <xrpld/rpc/GRPCHandlers.h>
|
||||
#include <xrpld/rpc/detail/RPCHelpers.h>
|
||||
@@ -150,6 +151,24 @@ doAccountInfo(RPC::JsonContext& context)
|
||||
|
||||
result[jss::account_flags] = std::move(acctFlags);
|
||||
|
||||
auto const pseudoFields = getPseudoAccountFields();
|
||||
for (auto const& pseudoField : pseudoFields)
|
||||
{
|
||||
if (sleAccepted->isFieldPresent(*pseudoField))
|
||||
{
|
||||
std::string name = pseudoField->fieldName;
|
||||
if (name.ends_with("ID"))
|
||||
{
|
||||
// Remove the ID suffix from the field name.
|
||||
name = name.substr(0, name.size() - 2);
|
||||
}
|
||||
// ValidPseudoAccounts invariant guarantees that only one field
|
||||
// can be set
|
||||
result[jss::pseudo_account][jss::type] = name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// The document[https://xrpl.org/account_info.html#account_info] states
|
||||
// that signer_lists is a bool, however assigning any string value
|
||||
// works. Do not allow this. This check is for api Version 2 onwards
|
||||
|
||||
Reference in New Issue
Block a user