1#include <test/jtx/Env.h>
2#include <test/jtx/WSClient.h>
3#include <test/jtx/amount.h>
4#include <test/jtx/domain.h>
5#include <test/jtx/offer.h>
6#include <test/jtx/paths.h>
7#include <test/jtx/pay.h>
8#include <test/jtx/permissioned_dex.h>
9#include <test/jtx/sendmax.h>
11#include <xrpl/basics/base_uint.h>
12#include <xrpl/beast/unit_test/suite.h>
13#include <xrpl/json/json_value.h>
14#include <xrpl/json/to_string.h>
15#include <xrpl/protocol/Feature.h>
16#include <xrpl/protocol/jss.h>
26 testcase(
"Specify well-known strings as ledger input");
32 params[
"ledger"] =
"validated";
33 resp = env.
rpc(
"json",
"book_changes",
to_string(params));
34 BEAST_EXPECT(!resp[jss::result].isMember(jss::error));
35 BEAST_EXPECT(resp[jss::result][jss::status] ==
"success");
36 BEAST_EXPECT(resp[jss::result][jss::validated] ==
true);
38 params[
"ledger"] =
"current";
39 resp = env.
rpc(
"json",
"book_changes",
to_string(params));
40 BEAST_EXPECT(!resp[jss::result].isMember(jss::error));
41 BEAST_EXPECT(resp[jss::result][jss::status] ==
"success");
42 BEAST_EXPECT(resp[jss::result][jss::validated] ==
false);
44 params[
"ledger"] =
"closed";
45 resp = env.
rpc(
"json",
"book_changes",
to_string(params));
46 BEAST_EXPECT(!resp[jss::result].isMember(jss::error));
47 BEAST_EXPECT(resp[jss::result][jss::status] ==
"success");
52 BEAST_EXPECT(resp[jss::result][jss::validated] ==
true);
55 params[
"ledger"] =
"non_conventional_ledger_input";
56 resp = env.
rpc(
"json",
"book_changes",
to_string(params));
57 BEAST_EXPECT(resp[jss::result].isMember(jss::error));
58 BEAST_EXPECT(resp[jss::result][jss::status] !=
"success");
65 "If ledger_hash or ledger_index is not specified, the behavior "
66 "must default to the `current` ledger");
72 BEAST_EXPECT(!resp[jss::result].isMember(jss::error));
73 BEAST_EXPECT(resp[jss::result][jss::status] ==
"success");
88 featurePermissionedDEX};
92 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = permDex;
106 auto const ledgerIndex = txResult[jss::ledger_index].
asInt();
109 jvParams[jss::ledger_index] = ledgerIndex;
111 auto jv = wsc->invoke(
"book_changes", jvParams);
112 auto jrr = jv[jss::result];
114 BEAST_EXPECT(jrr[jss::changes].size() == 1);
115 BEAST_EXPECT(jrr[jss::changes][0u][jss::domain].asString() ==
to_string(domainID));
TestcaseT testcase
Memberspace for declaring test cases.
virtual Config & config()=0
void run() override
Runs the suite.
void testLedgerInputDefaultBehavior()
void testConventionalLedgerInputStrings()
A transaction testing environment.
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.
std::shared_ptr< STTx const > tx() const
Return the tx data for the last JTx.
Sets the SendMax on a JTx.
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
XrpT const XRP
Converts to XRP Issue or STAmount.
FeatureBitset testableAmendments()
json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
std::unique_ptr< WSClient > makeWSClient(Config const &cfg, bool v2, unsigned rpcVersion, 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.
BaseUInt< 256 > Domain
Domain is a 256-bit hash representing a specific domain.
std::string to_string(BaseUInt< Bits, Tag > const &a)