21#include <test/jtx/WSClient.h>
23#include "xrpl/beast/unit_test/suite.h"
24#include "xrpl/protocol/jss.h"
35 testcase(
"Specify well-known strings as ledger input");
41 params[
"ledger"] =
"validated";
42 resp = env.
rpc(
"json",
"book_changes",
to_string(params));
43 BEAST_EXPECT(!resp[jss::result].isMember(jss::error));
44 BEAST_EXPECT(resp[jss::result][jss::status] ==
"success");
45 BEAST_EXPECT(resp[jss::result][jss::validated] ==
true);
47 params[
"ledger"] =
"current";
48 resp = env.
rpc(
"json",
"book_changes",
to_string(params));
49 BEAST_EXPECT(!resp[jss::result].isMember(jss::error));
50 BEAST_EXPECT(resp[jss::result][jss::status] ==
"success");
51 BEAST_EXPECT(resp[jss::result][jss::validated] ==
false);
53 params[
"ledger"] =
"closed";
54 resp = env.
rpc(
"json",
"book_changes",
to_string(params));
55 BEAST_EXPECT(!resp[jss::result].isMember(jss::error));
56 BEAST_EXPECT(resp[jss::result][jss::status] ==
"success");
61 BEAST_EXPECT(resp[jss::result][jss::validated] ==
true);
64 params[
"ledger"] =
"non_conventional_ledger_input";
65 resp = env.
rpc(
"json",
"book_changes",
to_string(params));
66 BEAST_EXPECT(resp[jss::result].isMember(jss::error));
67 BEAST_EXPECT(resp[jss::result][jss::status] !=
"success");
74 "If ledger_hash or ledger_index is not specified, the behavior "
75 "must default to the `current` ledger");
82 BEAST_EXPECT(!resp[jss::result].isMember(jss::error));
83 BEAST_EXPECT(resp[jss::result][jss::status] ==
"success");
98 featureCredentials | featurePermissionedDEX};
102 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
110 env(
pay(bob, carol, USD(10)),
120 auto const ledgerIndex = txResult[jss::ledger_index].
asInt();
123 jvParams[jss::ledger_index] = ledgerIndex;
125 auto jv = wsc->invoke(
"book_changes", jvParams);
126 auto jrr = jv[jss::result];
128 BEAST_EXPECT(jrr[jss::changes].size() == 1);
130 jrr[jss::changes][0u][jss::domain].asString() ==
testcase_t testcase
Memberspace for declaring test cases.
virtual Config & config()=0
void run() override
Runs the suite.
void testConventionalLedgerInputStrings()
void testLedgerInputDefaultBehavior()
A transaction testing environment.
std::shared_ptr< STTx const > tx() const
Return the tx data for the last JTx.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Sets the SendMax on a JTx.
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
FeatureBitset testable_amendments()
Json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
XRP_t const XRP
Converts to XRP Issue or STAmount.
std::unique_ptr< WSClient > makeWSClient(Config const &cfg, bool v2, unsigned rpc_version, std::unordered_map< std::string, std::string > const &headers)
Returns a client operating through WebSockets/S.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string to_string(base_uint< Bits, Tag > const &a)