mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Promote API version 2 to supported (#4803)
* Promote API version 2 to supported * Switch command line to API version 1 * Fix LedgerRequestRPC test * Remove obsolete tx_account method This method is not implemented, the only parts which are removed are related to command-line parsing * Fix RPCCall test * Reduce diff size, small test improvements * Minor fixes * Support for the mold linker * [fold] handle case where both mold and gold are installed * [fold] Use first non-default linker * Fix TransactionEntry_test * Fix AccountTx_test --------- Co-authored-by: seelabs <scott.determan@yahoo.com>
This commit is contained in:
@@ -279,6 +279,17 @@ public:
|
||||
The command is examined and used to build
|
||||
the correct JSON as per the arguments.
|
||||
*/
|
||||
template <class... Args>
|
||||
Json::Value
|
||||
rpc(unsigned apiVersion,
|
||||
std::unordered_map<std::string, std::string> const& headers,
|
||||
std::string const& cmd,
|
||||
Args&&... args);
|
||||
|
||||
template <class... Args>
|
||||
Json::Value
|
||||
rpc(unsigned apiVersion, std::string const& cmd, Args&&... args);
|
||||
|
||||
template <class... Args>
|
||||
Json::Value
|
||||
rpc(std::unordered_map<std::string, std::string> const& headers,
|
||||
@@ -655,6 +666,7 @@ protected:
|
||||
|
||||
Json::Value
|
||||
do_rpc(
|
||||
unsigned apiVersion,
|
||||
std::vector<std::string> const& args,
|
||||
std::unordered_map<std::string, std::string> const& headers = {});
|
||||
|
||||
@@ -698,12 +710,39 @@ protected:
|
||||
template <class... Args>
|
||||
Json::Value
|
||||
Env::rpc(
|
||||
unsigned apiVersion,
|
||||
std::unordered_map<std::string, std::string> const& headers,
|
||||
std::string const& cmd,
|
||||
Args&&... args)
|
||||
{
|
||||
return do_rpc(
|
||||
std::vector<std::string>{cmd, std::forward<Args>(args)...}, headers);
|
||||
apiVersion,
|
||||
std::vector<std::string>{cmd, std::forward<Args>(args)...},
|
||||
headers);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
Json::Value
|
||||
Env::rpc(unsigned apiVersion, std::string const& cmd, Args&&... args)
|
||||
{
|
||||
return rpc(
|
||||
apiVersion,
|
||||
std::unordered_map<std::string, std::string>(),
|
||||
cmd,
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
Json::Value
|
||||
Env::rpc(
|
||||
std::unordered_map<std::string, std::string> const& headers,
|
||||
std::string const& cmd,
|
||||
Args&&... args)
|
||||
{
|
||||
return do_rpc(
|
||||
RPC::apiCommandLineVersion,
|
||||
std::vector<std::string>{cmd, std::forward<Args>(args)...},
|
||||
headers);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
@@ -743,7 +782,7 @@ void
|
||||
forAllApiVersions(VersionedTestCallable auto... testCallable)
|
||||
{
|
||||
for (auto testVersion = RPC::apiMinimumSupportedVersion;
|
||||
testVersion <= RPC::apiBetaVersion;
|
||||
testVersion <= RPC::apiMaximumValidVersion;
|
||||
++testVersion)
|
||||
{
|
||||
(..., testCallable(testVersion));
|
||||
|
||||
@@ -460,15 +460,11 @@ Env::st(JTx const& jt)
|
||||
|
||||
Json::Value
|
||||
Env::do_rpc(
|
||||
unsigned apiVersion,
|
||||
std::vector<std::string> const& args,
|
||||
std::unordered_map<std::string, std::string> const& headers)
|
||||
{
|
||||
return rpcClient(
|
||||
args,
|
||||
app().config(),
|
||||
app().logs(),
|
||||
RPC::apiMaximumSupportedVersion,
|
||||
headers)
|
||||
return rpcClient(args, app().config(), app().logs(), apiVersion, headers)
|
||||
.second;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ Json::Value
|
||||
cmdToJSONRPC(
|
||||
std::vector<std::string> const& args,
|
||||
beast::Journal j,
|
||||
unsigned int apiVersion = RPC::apiMaximumSupportedVersion);
|
||||
unsigned int apiVersion);
|
||||
|
||||
} // namespace jtx
|
||||
} // namespace test
|
||||
|
||||
@@ -137,6 +137,7 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
j[jss::result][jss::transactions][1u][jss::tx]
|
||||
[jss::DeliverMax]);
|
||||
case 2:
|
||||
case 3:
|
||||
if (j.isMember(jss::result) &&
|
||||
(j[jss::result][jss::status] == "success") &&
|
||||
(j[jss::result][jss::transactions].size() == 2) &&
|
||||
@@ -198,20 +199,22 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
rpcACT_MALFORMED));
|
||||
|
||||
jParms[jss::account] = A1.human();
|
||||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(jParms))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(jParms))));
|
||||
|
||||
// Ledger min/max index
|
||||
{
|
||||
Json::Value p{jParms};
|
||||
p[jss::ledger_index_min] = -1;
|
||||
p[jss::ledger_index_max] = -1;
|
||||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
|
||||
p[jss::ledger_index_min] = 0;
|
||||
p[jss::ledger_index_max] = 100;
|
||||
if (apiVersion < 2u)
|
||||
BEAST_EXPECT(
|
||||
hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
else
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
@@ -238,12 +241,13 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
{
|
||||
Json::Value p{jParms};
|
||||
p[jss::ledger_index_min] = -1;
|
||||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
|
||||
p[jss::ledger_index_min] = 1;
|
||||
if (apiVersion < 2u)
|
||||
BEAST_EXPECT(
|
||||
hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
else
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
@@ -260,22 +264,25 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
{
|
||||
Json::Value p{jParms};
|
||||
p[jss::ledger_index_max] = -1;
|
||||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
|
||||
p[jss::ledger_index_max] = env.current()->info().seq;
|
||||
if (apiVersion < 2u)
|
||||
BEAST_EXPECT(
|
||||
hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
else
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
rpcLGR_IDX_MALFORMED));
|
||||
|
||||
p[jss::ledger_index_max] = 3;
|
||||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
|
||||
p[jss::ledger_index_max] = env.closed()->info().seq;
|
||||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
|
||||
p[jss::ledger_index_max] = env.closed()->info().seq - 1;
|
||||
BEAST_EXPECT(noTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
@@ -286,7 +293,8 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
Json::Value p{jParms};
|
||||
|
||||
p[jss::ledger_index] = env.closed()->info().seq;
|
||||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
|
||||
p[jss::ledger_index] = env.closed()->info().seq - 1;
|
||||
BEAST_EXPECT(noTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
@@ -306,7 +314,8 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
Json::Value p{jParms};
|
||||
|
||||
p[jss::ledger_hash] = to_string(env.closed()->info().hash);
|
||||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
|
||||
p[jss::ledger_hash] = to_string(env.closed()->info().parentHash);
|
||||
BEAST_EXPECT(noTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
@@ -324,8 +333,8 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
p[jss::ledger_index] = -1;
|
||||
|
||||
if (apiVersion < 2u)
|
||||
BEAST_EXPECT(
|
||||
hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
else
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
@@ -337,8 +346,8 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
Json::Value p{jParms};
|
||||
p[jss::ledger_index_max] = env.current()->info().seq;
|
||||
if (apiVersion < 2u)
|
||||
BEAST_EXPECT(
|
||||
hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
BEAST_EXPECT(hasTxs(
|
||||
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
else
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <ripple/rpc/impl/RPCHelpers.h>
|
||||
#include <test/jtx.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
namespace RPC {
|
||||
@@ -263,7 +265,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
testBadInput()
|
||||
testBadInput(unsigned apiVersion)
|
||||
{
|
||||
using namespace test::jtx;
|
||||
Env env{*this};
|
||||
@@ -287,9 +289,9 @@ public:
|
||||
// the purpose in this test is to force the ledger expiration/out of
|
||||
// date check to trigger
|
||||
env.timeKeeper().adjustCloseTime(weeks{3});
|
||||
result = env.rpc("ledger_request", "1")[jss::result];
|
||||
result = env.rpc(apiVersion, "ledger_request", "1")[jss::result];
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
if (RPC::apiMaximumSupportedVersion == 1)
|
||||
if (apiVersion == 1)
|
||||
{
|
||||
BEAST_EXPECT(result[jss::error] == "noCurrent");
|
||||
BEAST_EXPECT(
|
||||
@@ -357,7 +359,8 @@ public:
|
||||
{
|
||||
testLedgerRequest();
|
||||
testEvolution();
|
||||
testBadInput();
|
||||
test::jtx::forAllApiVersions(
|
||||
std::bind_front(&LedgerRequestRPC_test::testBadInput, this));
|
||||
testMoreThan256Closed();
|
||||
testNonAdmin();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -230,22 +230,20 @@ class TransactionEntry_test : public beast::unit_test::suite
|
||||
}
|
||||
|
||||
// Use the command line form with the index.
|
||||
if (apiVersion == RPC::apiMaximumSupportedVersion)
|
||||
{
|
||||
Json::Value const clIndex{env.rpc(
|
||||
"transaction_entry", txhash, std::to_string(index))};
|
||||
BEAST_EXPECT(clIndex["result"] == resIndex);
|
||||
}
|
||||
Json::Value const clIndex{env.rpc(
|
||||
apiVersion,
|
||||
"transaction_entry",
|
||||
txhash,
|
||||
std::to_string(index))};
|
||||
BEAST_EXPECT(clIndex["result"] == resIndex);
|
||||
|
||||
// Use the command line form with the ledger_hash.
|
||||
if (apiVersion == RPC::apiMaximumSupportedVersion)
|
||||
{
|
||||
Json::Value const clHash{env.rpc(
|
||||
"transaction_entry",
|
||||
txhash,
|
||||
resIndex[jss::ledger_hash].asString())};
|
||||
BEAST_EXPECT(clHash["result"] == resIndex);
|
||||
}
|
||||
Json::Value const clHash{env.rpc(
|
||||
apiVersion,
|
||||
"transaction_entry",
|
||||
txhash,
|
||||
resIndex[jss::ledger_hash].asString())};
|
||||
BEAST_EXPECT(clHash["result"] == resIndex);
|
||||
};
|
||||
|
||||
Account A1{"A1"};
|
||||
|
||||
Reference in New Issue
Block a user