2#include <test/jtx/Account.h>
3#include <test/jtx/Env.h>
4#include <test/jtx/amount.h>
5#include <test/jtx/envconfig.h>
6#include <test/jtx/last_ledger_sequence.h>
7#include <test/jtx/noop.h>
8#include <test/jtx/seq.h>
9#include <test/jtx/ter.h>
11#include <xrpld/core/Config.h>
13#include <xrpl/basics/base_uint.h>
14#include <xrpl/beast/unit_test/suite.h>
15#include <xrpl/core/JobQueue.h>
16#include <xrpl/protocol/TER.h>
32 auto const alice =
Account(
"alice");
35 auto const aliceSequence = env.
seq(alice);
37 auto const tx1 = env.
jt(
noop(alice),
Seq(aliceSequence));
42 BEAST_EXPECT(env.
seq(alice) == aliceSequence + 1);
45 BEAST_EXPECT(env.
seq(alice) == aliceSequence + 2);
50 auto const result = env.
rpc(
"tx",
to_string(tx1.stx->getTransactionID()));
51 BEAST_EXPECT(result[
"result"][
"meta"][
"TransactionResult"] ==
"tesSUCCESS");
54 auto const result = env.
rpc(
"tx",
to_string(tx2.stx->getTransactionID()));
55 BEAST_EXPECT(result[
"result"][
"meta"][
"TransactionResult"] ==
"tesSUCCESS");
67 cfg->forceMultiThread =
false;
71 auto const alice =
Account(
"alice");
74 auto const aliceSequence = env.seq(alice);
76 auto const tx1 = env.jt(
noop(alice),
Seq(aliceSequence));
80 BEAST_EXPECT(env.seq(alice) == aliceSequence);
82 env.app().getJobQueue().rendezvous();
83 BEAST_EXPECT(env.seq(alice) == aliceSequence + 2);
88 auto const result = env.rpc(
"tx",
to_string(tx1.stx->getTransactionID()));
89 BEAST_EXPECT(result[
"result"][
"meta"][
"TransactionResult"] ==
"tesSUCCESS");
92 auto const result = env.rpc(
"tx",
to_string(tx2.stx->getTransactionID()));
93 BEAST_EXPECT(result[
"result"][
"meta"][
"TransactionResult"] ==
"tesSUCCESS");
102 testcase(
"Incorrect order multiple intermediaries");
105 cfg->forceMultiThread =
true;
109 auto const alice =
Account(
"alice");
112 auto const aliceSequence = env.seq(alice);
113 static constexpr auto kSize = 5;
117 for (
auto i = 0; i < kSize; ++i)
122 for (
auto i = 1; i < kSize; ++i)
125 BEAST_EXPECT(env.seq(alice) == aliceSequence);
129 env.app().getJobQueue().rendezvous();
130 BEAST_EXPECT(env.seq(alice) == aliceSequence + kSize);
134 for (
auto i = 0; i < kSize; ++i)
136 auto const result = env.rpc(
"tx",
to_string(tx[i].stx->getTransactionID()));
137 BEAST_EXPECT(result[
"result"][
"meta"][
"TransactionResult"] ==
"tesSUCCESS");
TestcaseT testcase
Memberspace for declaring test cases.
A transaction testing environment.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
Set the expected result code for a JTx The test will fail if the code doesn't match.
T emplace_back(T... args)
XrpT const XRP
Converts to XRP Issue or STAmount.
json::Value noop(Account const &account)
The null transaction.
std::array< Account, 1+sizeof...(Args)> noripple(Account const &account, Args const &... args)
Designate accounts as no-ripple in Env::fund.
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string to_string(BaseUInt< Bits, Tag > const &a)
void testIncorrectOrderMultipleIntermediaries()
void testIncorrectOrder()
void run() override
Runs the suite.
Set the sequence number on a JTx.