21#include <test/jtx/Env.h>
22#include <test/jtx/envconfig.h>
23#include <xrpl/protocol/jss.h>
25#include <boost/container/static_vector.hpp>
37 using namespace test::jtx;
38 Env env{*
this, envconfig(no_admin)};
43 env.client().invoke(
"tx_history", {})[jss::result];
44 BEAST_EXPECT(result[jss::error] ==
"invalidParams");
45 BEAST_EXPECT(result[jss::status] ==
"error");
51 params[jss::start] = 10001;
53 env.client().invoke(
"tx_history", params)[jss::result];
54 BEAST_EXPECT(result[jss::error] ==
"noPermission");
55 BEAST_EXPECT(result[jss::status] ==
"error");
62 testcase(
"Command retired from API v2");
63 using namespace test::jtx;
64 Env env{*
this, envconfig(no_admin)};
67 params[jss::api_version] = 2;
69 env.client().invoke(
"tx_history", params)[jss::result];
70 BEAST_EXPECT(result[jss::error] ==
"unknownCmd");
71 BEAST_EXPECT(result[jss::status] ==
"error");
78 using namespace test::jtx;
83 size_t const numAccounts = 20;
84 boost::container::static_vector<Account, numAccounts> accounts;
85 for (
size_t i = 0; i < numAccounts; ++i)
88 auto const& acct = accounts.back();
89 env.fund(XRP(10000), acct);
93 auto const& prev = accounts[i - 1];
94 env.trust(acct[
"USD"](1000), prev);
95 env(pay(acct, prev, acct[
"USD"](5)));
97 env(offer(acct, XRP(100), acct[
"USD"](1)));
103 params[jss::start] = 0;
105 env.client().invoke(
"tx_history", params)[jss::result];
107 result[jss::txs].isArray() && result[jss::txs].size() > 0))
111 bool const txFound = [&] {
113 for (
auto tx : result[jss::txs])
115 tx.removeMember(jss::inLedger);
116 tx.removeMember(jss::ledger_index);
122 BEAST_EXPECT(txFound);
125 unsigned int start = 0;
126 unsigned int total = 0;
132 params[jss::start] = start;
134 env.client().invoke(
"tx_history", params)[jss::result];
136 result[jss::txs].isArray() && result[jss::txs].size() > 0))
138 total += result[jss::txs].size();
140 for (
auto const& t : result[jss::txs])
142 typeCounts[t[sfTransactionType.fieldName].asString()]++;
145 BEAST_EXPECT(total == 117);
146 BEAST_EXPECT(typeCounts[jss::AccountSet.c_str()] == 20);
147 BEAST_EXPECT(typeCounts[jss::TrustSet.c_str()] == 19);
148 BEAST_EXPECT(typeCounts[jss::Payment.c_str()] == 58);
149 BEAST_EXPECT(typeCounts[jss::OfferCreate.c_str()] == 20);
154 params[jss::start] = 10000;
156 env.client().invoke(
"tx_history", params)[jss::result];
157 BEAST_EXPECT(result[jss::status] ==
"success");
158 BEAST_EXPECT(result[jss::index] == 10000);
172BEAST_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.