20#ifndef RIPPLE_TEST_JTX_TESTHELPERS_H_INCLUDED
21#define RIPPLE_TEST_JTX_TESTHELPERS_H_INCLUDED
23#include <test/jtx/Env.h>
25#include <xrpl/basics/base_uint.h>
26#include <xrpl/json/json_value.h>
27#include <xrpl/protocol/AccountID.h>
28#include <xrpl/protocol/Quality.h>
29#include <xrpl/protocol/TxFlags.h>
30#include <xrpl/protocol/jss.h>
42template <
typename Input>
45 requires requires(Input& v) {
72template <
typename...
IOU>
78 for (
auto const& line : jrr[jss::lines])
80 for (
auto const& iou : {ious...})
82 if (line[jss::currency].asString() ==
to_string(iou.currency))
85 v[jss::currency] = line[jss::currency];
86 v[jss::balance] = line[jss::balance];
87 v[jss::limit] = line[jss::limit];
88 v[jss::account] = line[jss::account];
120template <
class T,
class... Args>
125 if constexpr (
sizeof...(args) > 0)
129template <
class... Args>
134 if constexpr (
sizeof...(args) > 0)
145template <
class... Args>
154template <
class... Args>
163 for (
auto const& p : st2)
184 bool defaultLimits =
false);
186template <
typename... Amts>
194 return expectLine(env, account, value,
false) &&
214 Account
const& acct_a,
215 Account
const& acct_b,
236 return escrow(account.id(), to.
id(), amount);
258 {0xA0, 0x25, 0x80, 0x20, 0xE3, 0xB0, 0xC4, 0x42, 0x98, 0xFC,
259 0x1C, 0x14, 0x9A, 0xFB, 0xF4, 0xC8, 0x99, 0x6F, 0xB9, 0x24,
260 0x27, 0xAE, 0x41, 0xE4, 0x64, 0x9B, 0x93, 0x4C, 0xA4, 0x95,
261 0x99, 0x1B, 0x78, 0x52, 0xB8, 0x55, 0x81, 0x01, 0x00}};
321 jt.
jv[sfCondition.jsonName] =
value_;
344 jt.
jv[sfFulfillment.jsonName] =
value_;
372 account.id(), to.
id(), amount, settleDelay, pk, cancelAfter, dstTag);
400 return channel(account.id(), dst.
id(), seqProxyValue);
439 requires std::is_same_v<A, AccountID>
444 jv[sfAccount.jsonName] =
to_string(account);
446 jv[sfDestination.jsonName] =
to_string(dest);
447 jv[sfTransactionType.jsonName] = jss::CheckCreate;
459 return create(account.id(), dest.
id(), sendMax);
Value & append(const Value &value)
Append value to array at the end.
bool isNull() const
isNull() tests to see if this field is null.
A currency issued by an account.
Json::Value getJson(JsonOptions) const override
std::vector< STPath >::const_iterator end() const
void push_back(STPath const &e)
std::vector< STPath >::const_iterator begin() const
std::vector< STPath >::size_type size() const
An immutable linear range of bytes.
Immutable cryptographic account descriptor.
AccountID id() const
Returns the Account ID.
A transaction testing environment.
Converts to IOU Issue or STAmount.
Json::Value create(A const &account, A const &dest, STAmount const &sendMax)
Create a check.
bool checkArraySize(Json::Value const &val, unsigned int size)
std::uint32_t ownerCount(Env const &env, Account const &account)
Json::Value ledgerEntryRoot(Env &env, Account const &acct)
auto make_vector(Input const &input)
Json::Value escrow(AccountID const &account, AccountID const &to, STAmount const &amount)
bool expectOffers(Env &env, AccountID const &account, std::uint16_t size, std::vector< Amounts > const &toMatch)
STAmount channelBalance(ReadView const &view, uint256 const &chan)
uint256 channel(AccountID const &account, AccountID const &dst, std::uint32_t seqProxyValue)
PrettyAmount xrpMinusFee(Env const &env, std::int64_t xrpAmount)
bool expectLine(Env &env, AccountID const &account, STAmount const &value, bool defaultLimits)
bool equal(STAmount const &sa1, STAmount const &sa2)
Json::Value getAccountLines(Env &env, AccountID const &acctId)
bool same(STPathSet const &st1, Args const &... args)
Json::Value ledgerEntryState(Env &env, Account const &acct_a, Account const &acct_b, std::string const ¤cy)
std::array< std::uint8_t, 4 > const fb1
void stpath_append_one(STPath &st, Account const &account)
void fund(jtx::Env &env, jtx::Account const &gw, std::vector< jtx::Account > const &accounts, std::vector< STAmount > const &amts, Fund how)
void stpath_append(STPath &st, T const &t, Args const &... args)
void n_offers(Env &env, std::size_t n, Account const &account, STAmount const &in, STAmount const &out)
Json::Value accountBalance(Env &env, Account const &acct)
Json::Value cancel(AccountID const &account, Account const &from, std::uint32_t seq)
STPathElement IPE(Issue const &iss)
Json::Value claim(AccountID const &account, uint256 const &channel, std::optional< STAmount > const &balance, std::optional< STAmount > const &amount, std::optional< Slice > const &signature, std::optional< PublicKey > const &pk)
Json::Value finish(AccountID const &account, AccountID const &from, std::uint32_t seq)
std::array< std::uint8_t, 39 > constexpr cb1
Json::Value create(AccountID const &account, AccountID const &to, STAmount const &amount, NetClock::duration const &settleDelay, PublicKey const &pk, std::optional< NetClock::time_point > const &cancelAfter, std::optional< std::uint32_t > const &dstTag)
void stpathset_append(STPathSet &st, STPath const &p, Args const &... args)
STPathElement cpe(Currency const &c)
bool expectLedgerEntryRoot(Env &env, Account const &acct, STAmount const &expectedValue)
STPathElement allpe(AccountID const &a, Issue const &iss)
bool channelExists(ReadView const &view, uint256 const &chan)
XRPAmount txfee(Env const &env, std::uint16_t n)
STPath stpath(Args const &... args)
Json::Value getAccountOffers(Env &env, AccountID const &acct, bool current)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
@ current
This was a new validation and was added.
std::string strHex(FwdIt begin, FwdIt end)
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
constexpr std::uint32_t tfUniversal
std::string to_string(base_uint< Bits, Tag > const &a)
Execution context for applying a JSON transaction.
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...
Set the "CancelAfter" time tag on a JTx.
NetClock::time_point value_
cancel_time(NetClock::time_point const &value)
void operator()(jtx::Env &, jtx::JTx &jt) const
void operator()(Env &, JTx &jt) const
condition(Slice const &cond)
condition(std::array< std::uint8_t, N > const &c)
Set the "FinishAfter" time tag on a JTx.
finish_time(NetClock::time_point const &value)
void operator()(Env &, JTx &jt) const
NetClock::time_point value_
fulfillment(Slice condition)
fulfillment(std::array< std::uint8_t, N > f)
void operator()(Env &, JTx &jt) const
Set the sequence number on a JTx.
T time_since_epoch(T... args)