3#include <xrpld/app/misc/NetworkOPs.h> 
    4#include <xrpld/app/misc/TxQ.h> 
    6#include <xrpl/beast/hash/uhash.h> 
    7#include <xrpl/beast/unit_test.h> 
    8#include <xrpl/protocol/Feature.h> 
    9#include <xrpl/protocol/TxFlags.h> 
   10#include <xrpl/protocol/jss.h> 
   12#include <boost/lexical_cast.hpp> 
   27        return boost::lexical_cast<std::string>(t);
 
 
   47        auto const USD = gw[
"USD"];
 
 
   80            fail(
"missing exception");
 
   90            fail(
"missing exception");
 
  111        BEAST_EXPECT(
XRP(1) == 
drops(1000000));
 
  116        auto const USD = gw[
"USD"];
 
  117        BEAST_EXPECT(
to_string(USD(0)) == 
"0/USD(gw)");
 
  118        BEAST_EXPECT(
to_string(USD(10)) == 
"10/USD(gw)");
 
  119        BEAST_EXPECT(
to_string(USD(-10)) == 
"-10/USD(gw)");
 
  120        BEAST_EXPECT(USD(0) == 
STAmount(USD, 0));
 
  121        BEAST_EXPECT(USD(1) == 
STAmount(USD, 1));
 
  122        BEAST_EXPECT(USD(-1) == 
STAmount(USD, -1));
 
  125        BEAST_EXPECT(!
get(USD(10)).is_any);
 
  126        BEAST_EXPECT(
get(
any(USD(10))).is_any);
 
 
  134        auto const n = 
XRP(10000);
 
  136        auto const USD = gw[
"USD"];
 
  137        auto const alice = 
Account(
"alice");
 
  142            env(
pay(
"alice", 
"bob", 
XRP(1000)),
 
  154            env.
fund(n, 
"alice");
 
  155            env.
fund(n, 
"bob", 
"carol");
 
  172            env.
fund(n, 
"alice", 
"bob", gw);
 
  180            BEAST_EXPECT(env.
balance(alice) == 0);
 
  181            BEAST_EXPECT(env.
balance(alice, USD) != 0);
 
  182            BEAST_EXPECT(env.
balance(alice, USD) == USD(0));
 
  183            env.
fund(n, alice, gw);
 
  185            BEAST_EXPECT(env.
balance(alice) == n);
 
  186            BEAST_EXPECT(env.
balance(gw) == n);
 
  187            env.
trust(USD(1000), alice);
 
  188            env(
pay(gw, alice, USD(10)));
 
  198            BEAST_EXPECT(env.
seq(
"alice") == 3);
 
  199            BEAST_EXPECT(env.
seq(gw) == 3);
 
  205            env.
fund(n, 
"alice");
 
 
  225        auto const USD = gw[
"USD"];
 
  228        env.
fund(
XRP(10000), 
"alice", gw);
 
  231        env.
trust(USD(100), 
"alice");
 
 
  253        env.fund(
XRP(10000), alice, bob);
 
 
  289        auto const gw = 
Account(
"gateway");
 
  290        auto const USD = gw[
"USD"];
 
  292        env.
fund(
XRP(10000), 
"alice", 
"bob", 
"carol", gw);
 
  307        env.
trust(USD(100), 
"alice", 
"bob", 
"carol");
 
  311        env(
pay(gw, 
"carol", USD(50)));
 
  317        env(
pay(
"alice", 
"bob", 
any(USD(10))),
 
  326        env(
regkey(
"alice", 
"eric"));
 
  328        env(
noop(
"alice"), 
sig(
"alice"));
 
  329        env(
noop(
"alice"), 
sig(
"eric"));
 
  341        env(
noop(
"alice"), 
sig(
"eric"));
 
 
  362        auto const gw = 
Account(
"gateway");
 
  363        auto const USD = gw[
"USD"];
 
  365        auto const alice = 
Account{
"alice"};
 
  369        auto const queueTxCount =
 
  371        auto const openTxCount = env.
current()->txCount();
 
  372        BEAST_EXPECT(localTxCnt == 2 && queueTxCount == 0 && openTxCount == 2);
 
  374        auto applyTxn = [&env](
auto&&... txnArgs) {
 
  375            auto jt = env.
jt(txnArgs...);
 
  382            args[jss::fail_hard] = 
true;
 
  384            return env.
rpc(
"json", 
"submit", args.toStyledString());
 
  387        auto jr = applyTxn(
noop(alice), 
fee(1));
 
  389        BEAST_EXPECT(jr[jss::result][jss::engine_result] == 
"telINSUF_FEE_P");
 
  394        BEAST_EXPECT(env.
current()->txCount() == openTxCount);
 
  396        jr = applyTxn(
noop(alice), 
sig(
"bob"));
 
  398        BEAST_EXPECT(jr[jss::result][jss::engine_result] == 
"tefBAD_AUTH");
 
  403        BEAST_EXPECT(env.
current()->txCount() == openTxCount);
 
  405        jr = applyTxn(
noop(alice), 
seq(20));
 
  407        BEAST_EXPECT(jr[jss::result][jss::engine_result] == 
"terPRE_SEQ");
 
  412        BEAST_EXPECT(env.
current()->txCount() == openTxCount);
 
  414        jr = applyTxn(
offer(alice, 
XRP(1000), USD(1000)));
 
  417            jr[jss::result][jss::engine_result] == 
"tecUNFUNDED_OFFER");
 
  422        BEAST_EXPECT(env.
current()->txCount() == openTxCount);
 
  426        BEAST_EXPECT(jr[jss::result][jss::engine_result] == 
"temBAD_FEE");
 
  431        BEAST_EXPECT(env.
current()->txCount() == openTxCount);
 
  433        jr = applyTxn(
noop(alice));
 
  435        BEAST_EXPECT(jr[jss::result][jss::engine_result] == 
"tesSUCCESS");
 
  437        BEAST_EXPECT(env.
current()->txCount() == openTxCount + 1);
 
 
  448        env(
signers(
"alice", 1, {{
"alice", 1}, {
"bob", 2}}),
 
  450        env(
signers(
"alice", 1, {{
"bob", 1}, {
"carol", 2}}));
 
  453        auto const baseFee = env.
current()->fees().base;
 
  455        env(
noop(
"alice"), 
msig(
"carol"), 
fee(2 * baseFee));
 
  456        env(
noop(
"alice"), 
msig(
"bob", 
"carol"), 
fee(3 * baseFee));
 
  458            msig(
"bob", 
"carol", 
"dilbert"),
 
 
  496        BEAST_EXPECT(!jt1.
get<
int>());
 
  498        BEAST_EXPECT(jt1.
get<
int>());
 
  499        BEAST_EXPECT(*jt1.
get<
int>() == 7);
 
  500        BEAST_EXPECT(!jt1.
get<
UDT>());
 
  505        BEAST_EXPECT(jt1.
get<
int>());
 
  506        BEAST_EXPECT(*jt1.
get<
int>() == 17);
 
  507        BEAST_EXPECT(!jt1.
get<
UDT>());
 
  511        *jt1.
get<
int>() = 42;
 
  512        BEAST_EXPECT(jt1.
get<
int>());
 
  513        BEAST_EXPECT(*jt1.
get<
int>() == 42);
 
  514        BEAST_EXPECT(!jt1.
get<
UDT>());
 
  517        auto const& jt2 = jt1;
 
  518        BEAST_EXPECT(jt2.get<
int>());
 
  519        BEAST_EXPECT(*jt2.get<
int>() == 42);
 
  520        BEAST_EXPECT(!jt2.get<
UDT>());
 
 
  528        env.
fund(
XRP(100000), 
"alice");
 
  529        auto jt1 = env.
jt(
noop(
"alice"));
 
  539        BEAST_EXPECT(*jt3.get<
std::string>() == 
"Hello, world!");
 
  540        BEAST_EXPECT(jt3.get<
bool>());
 
  541        BEAST_EXPECT(!*jt3.get<
bool>());
 
 
  553        BEAST_EXPECT(jt1.
get<
int>());
 
  554        BEAST_EXPECT(*jt1.
get<
int>() == 7);
 
  555        BEAST_EXPECT(!jt1.
get<
UDT>());
 
  557        BEAST_EXPECT(jt2.
get<
int>());
 
  558        BEAST_EXPECT(*jt2.
get<
int>() == 7);
 
  559        BEAST_EXPECT(!jt2.
get<
UDT>());
 
  562        BEAST_EXPECT(jt3.
get<
int>());
 
  563        BEAST_EXPECT(*jt3.
get<
int>() == 7);
 
  564        BEAST_EXPECT(!jt3.
get<
UDT>());
 
 
  576        BEAST_EXPECT(jt1.
get<
int>());
 
  577        BEAST_EXPECT(*jt1.
get<
int>() == 7);
 
  578        BEAST_EXPECT(!jt1.
get<
UDT>());
 
  579        JTx jt2(std::move(jt1));
 
  580        BEAST_EXPECT(!jt1.
get<
int>());
 
  581        BEAST_EXPECT(!jt1.
get<
UDT>());
 
  582        BEAST_EXPECT(jt2.
get<
int>());
 
  583        BEAST_EXPECT(*jt2.
get<
int>() == 7);
 
  584        BEAST_EXPECT(!jt2.
get<
UDT>());
 
  585        jt1 = std::move(jt2);
 
  586        BEAST_EXPECT(!jt2.
get<
int>());
 
  587        BEAST_EXPECT(!jt2.
get<
UDT>());
 
  588        BEAST_EXPECT(jt1.
get<
int>());
 
  589        BEAST_EXPECT(*jt1.
get<
int>() == 7);
 
  590        BEAST_EXPECT(!jt1.
get<
UDT>());
 
 
  605        env(
noop(
"alice"), 
memo(
"data", 
"format", 
"type"));
 
  607            memo(
"data1", 
"format1", 
"type1"),
 
  608            memo(
"data2", 
"format2", 
"type2"));
 
 
  617        memo(
"data", 
"format", 
"type")(env, jt);
 
  619        auto const& 
memo = jt.
jv[
"Memos"][0u][
"Memo"];
 
 
  634        BEAST_EXPECT(
seq == env.
closed()->seq() + 1);
 
  636        BEAST_EXPECT(env.
closed()->seq() == 
seq);
 
  637        BEAST_EXPECT(env.
current()->seq() == 
seq + 1);
 
  639        BEAST_EXPECT(env.
closed()->seq() == 
seq + 1);
 
  640        BEAST_EXPECT(env.
current()->seq() == 
seq + 2);
 
 
  650        env.
fund(
XRP(100000), 
"alice", 
"bob");
 
  652        env(
pay(
"alice", 
"bob", 
XRP(100)));
 
 
  665        auto const USD = gw[
"USD"];
 
  666        env.
fund(
XRP(10000), 
"alice", 
"bob");
 
  669            pay(
"alice", 
"bob", USD(10)),
 
 
  686        auto const baseFee = env.
current()->fees().base;
 
  693        JTx jt = env.
jt(jsonNoop);
 
 
  704        auto const baseFee = env.
current()->fees().base;
 
  706        auto const alice = 
Account(
"alice");
 
  714            if (BEAST_EXPECT(tx))
 
  716                BEAST_EXPECT(tx->getAccountID(sfAccount) == alice.id());
 
  717                BEAST_EXPECT(tx->getTxnType() == ttACCOUNT_SET);
 
  727            if (BEAST_EXPECT(tx))
 
  729                BEAST_EXPECT(tx->getAccountID(sfAccount) == alice.id());
 
  730                BEAST_EXPECT(tx->getTxnType() == ttACCOUNT_SET);
 
  737            params[jss::fee_mult_max] = 1;
 
  738            params[jss::fee_div_max] = 2;
 
  740            auto const expectedErrorString = 
"Fee of " +
 
  742                " exceeds the requested tx limit of " +
 
 
  767            auto const n = supported.size();
 
  768            for (
size_t i = 0; i < n; ++i)
 
  775        if (!neverSupportedFeat)
 
  777            log << 
"No unsupported features found - skipping test." 
  783        auto hasFeature = [](
Env& env, 
uint256 const& f) {
 
  795                this->BEAST_EXPECT(hasFeature(env, f));
 
  805                    (f == featureMultiSignReserve || f == featureFlow);
 
  806                this->BEAST_EXPECT(has == hasFeature(env, f));
 
  810        auto const missingSomeFeatures =
 
  812        BEAST_EXPECT(missingSomeFeatures.count() == (supported.count() - 2));
 
  815            Env env{*
this, missingSomeFeatures};
 
  820                    (f == featureMultiSignReserve || f == featureFlow);
 
  821                this->BEAST_EXPECT(hasnot != hasFeature(env, f));
 
  833                    featureMultiSignReserve, featureFlow, *neverSupportedFeat)};
 
  838            BEAST_EXPECT(hasFeature(env, *neverSupportedFeat));
 
  841                bool has = (f == featureMultiSignReserve || f == featureFlow);
 
  842                this->BEAST_EXPECT(has == hasFeature(env, f));
 
  858                (supported.count() - 2 + 1));
 
  859            BEAST_EXPECT(hasFeature(env, *neverSupportedFeat));
 
  862                    (f == featureMultiSignReserve || f == featureFlow);
 
  863                this->BEAST_EXPECT(hasnot != hasFeature(env, f));
 
  877            BEAST_EXPECT(hasFeature(env, *neverSupportedFeat));
 
  879                this->BEAST_EXPECT(hasFeature(env, f));
 
 
  891                    (*cfg).deprecatedClearSection(
"port_rpc");
 
 
 
log_os< char > log
Logging output stream.
 
void pass()
Record a successful test condition.
 
testcase_t testcase
Memberspace for declaring test cases.
 
bool except(F &&f, String const &reason)
 
void fail(String const &reason, char const *file, int line)
Record a failure.
 
virtual Config & config()=0
 
virtual NetworkOPs & getOPs()=0
 
std::unordered_set< uint256, beast::uhash<> > features
 
FeatureBitset & set(uint256 const &f, bool value=true)
 
virtual std::size_t getLocalTxCount()=0
 
Slice slice() const noexcept
 
Metrics getMetrics(OpenView const &view) const
Returns fee metrics in reference fee level units.
 
static std::string to_string(T const &t)
 
void testExceptionalShutdown()
 
void run() override
Runs the suite.
 
Immutable cryptographic account descriptor.
 
A transaction testing environment wrapper.
 
A transaction testing environment.
 
Json::Value json(JsonValue &&jv, FN const &... fN)
Create JSON from parameters.
 
std::shared_ptr< ReadView const > closed()
Returns the last closed ledger.
 
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
 
void require(Args const &... args)
Check a set of requirements.
 
std::shared_ptr< STTx const > tx() const
Return the tx data for the last JTx.
 
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
 
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
 
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
 
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
 
Json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
 
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
 
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
 
void memoize(Account const &account)
Associate AccountID with account.
 
Set a multisignature on a JTx.
 
Match clear account flags.
 
Match the number of items in the account's owner directory.
 
Set Paths, SendMax on a JTx.
 
Check a set of conditions.
 
Set the expected result code for a JTx The test will fail if the code doesn't match.
 
Sets the SendMax on a JTx.
 
Set the regular signature on a JTx.
 
Set the expected result code for a JTx The test will fail if the code doesn't match.
 
@ objectValue
object value (collection of name/value pairs).
 
Json::Value create(Account const &account, std::uint32_t count)
Create one of more tickets.
 
owner_count< ltRIPPLE_STATE > lines
Match the number of trust lines in the account's owner directory.
 
Json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
 
Json::Value regkey(Account const &account, disabled_t)
Disable the regular key.
 
Json::Value signers(Account const &account, std::uint32_t quorum, std::vector< signer > const &v)
 
static autofill_t const autofill
 
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
 
Json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
 
Json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
 
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
 
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
 
any_t const any
Returns an amount representing "any issuer".
 
FeatureBitset testable_amendments()
 
Json::Value rate(Account const &account, double multiplier)
Set a transfer rate.
 
static disabled_t const disabled
 
Json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
 
owner_count< ltTICKET > tickets
Match the number of tickets on the account.
 
XRP_t const XRP
Converts to XRP Issue or STAmount.
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
 
uint256 bitsetIndexToFeature(size_t i)
 
constexpr std::uint32_t asfRequireDest
 
constexpr std::uint32_t asfDisableMaster
 
std::string strHex(FwdIt begin, FwdIt end)
 
constexpr std::uint32_t asfDefaultRipple
 
void foreachFeature(FeatureBitset bs, F &&f)
 
T get(Section const §ion, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.
 
std::size_t txCount
Number of transactions in the queue.
 
Amount specifier with an option for any issuer.
 
Execution context for applying a JSON transaction.
 
Prop * get()
Return a property if it exists.
 
void set(std::unique_ptr< basic_prop > p)
Set a property If the property already exists, it is replaced.
 
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...
 
Set the sequence number on a JTx.