21#include <test/jtx/Env.h>
22#include <test/jtx/envconfig.h>
24#include <xrpl/protocol/jss.h>
26#include <boost/container/static_vector.hpp>
38 using namespace test::jtx;
39 Env env{*
this, envconfig(no_admin)};
44 env.client().invoke(
"tx_history", {})[jss::result];
45 BEAST_EXPECT(result[jss::error] ==
"invalidParams");
46 BEAST_EXPECT(result[jss::status] ==
"error");
52 params[jss::start] = 10001;
54 env.client().invoke(
"tx_history", params)[jss::result];
55 BEAST_EXPECT(result[jss::error] ==
"noPermission");
56 BEAST_EXPECT(result[jss::status] ==
"error");
63 testcase(
"Command retired from API v2");
64 using namespace test::jtx;
65 Env env{*
this, envconfig(no_admin)};
68 params[jss::api_version] = 2;
70 env.client().invoke(
"tx_history", params)[jss::result];
71 BEAST_EXPECT(result[jss::error] ==
"unknownCmd");
72 BEAST_EXPECT(result[jss::status] ==
"error");
79 using namespace test::jtx;
84 size_t const numAccounts = 20;
85 boost::container::static_vector<Account, numAccounts> accounts;
86 for (
size_t i = 0; i < numAccounts; ++i)
89 auto const& acct = accounts.back();
90 env.fund(XRP(10000), acct);
94 auto const& prev = accounts[i - 1];
95 env.trust(acct[
"USD"](1000), prev);
96 env(pay(acct, prev, acct[
"USD"](5)));
98 env(offer(acct, XRP(100), acct[
"USD"](1)));
104 params[jss::start] = 0;
106 env.client().invoke(
"tx_history", params)[jss::result];
108 result[jss::txs].isArray() && result[jss::txs].size() > 0))
112 bool const txFound = [&] {
114 for (
auto tx : result[jss::txs])
116 tx.removeMember(jss::inLedger);
117 tx.removeMember(jss::ledger_index);
123 BEAST_EXPECT(txFound);
126 unsigned int start = 0;
127 unsigned int total = 0;
133 params[jss::start] = start;
135 env.client().invoke(
"tx_history", params)[jss::result];
137 result[jss::txs].isArray() && result[jss::txs].size() > 0))
139 total += result[jss::txs].size();
141 for (
auto const& t : result[jss::txs])
143 typeCounts[t[sfTransactionType.fieldName].asString()]++;
146 BEAST_EXPECT(total == 117);
147 BEAST_EXPECT(typeCounts[jss::AccountSet.c_str()] == 20);
148 BEAST_EXPECT(typeCounts[jss::TrustSet.c_str()] == 19);
149 BEAST_EXPECT(typeCounts[jss::Payment.c_str()] == 58);
150 BEAST_EXPECT(typeCounts[jss::OfferCreate.c_str()] == 20);
155 params[jss::start] = 10000;
157 env.client().invoke(
"tx_history", params)[jss::result];
158 BEAST_EXPECT(result[jss::status] ==
"success");
159 BEAST_EXPECT(result[jss::index] == 10000);
173BEAST_DEFINE_TESTSUITE(TransactionHistory, rpc,
ripple);
testcase_t testcase
Memberspace for declaring test cases.
void testCommandRetired()
void run() override
Runs the suite.
@ objectValue
object value (collection of name/value pairs).
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.