20#include <test/jtx/TestHelpers.h>
21#include <test/jtx/offer.h>
22#include <test/jtx/owners.h>
24#include <xrpl/protocol/TxFlags.h>
36 return env.
rpc(
"json",
"account_offers",
to_string(jv))[jss::result];
44 return env.
rpc(
"json",
"account_lines",
to_string(jv))[jss::result];
95 return env.
current()->fees().base * n;
101 auto feeDrops = env.
current()->fees().base;
115 bool const accountLow = account < issue.
account;
117 bool expectDefaultTrustLine =
true;
123 low.setIssuer(accountLow ? account : issue.
account);
124 high.setIssuer(accountLow ? issue.
account : account);
126 expectDefaultTrustLine = sle->getFieldAmount(sfLowLimit) == low &&
127 sle->getFieldAmount(sfHighLimit) == high;
130 auto amount = sle->getFieldAmount(sfBalance);
134 return amount == value && expectDefaultTrustLine;
158 if (sle->getType() == ltOFFER)
162 toMatch.begin(), toMatch.end(), [&](auto const& a) {
163 return a.in == sle->getFieldAmount(sfTakerPays) &&
164 a.out == sle->getFieldAmount(sfTakerGets);
170 return size == cnt && matched == toMatch.size();
177 jvParams[jss::ledger_index] =
"current";
178 jvParams[jss::account_root] = acct.
human();
179 return env.
rpc(
"json",
"ledger_entry",
to_string(jvParams))[jss::result];
190 jvParams[jss::ledger_index] =
"current";
191 jvParams[jss::ripple_state][jss::currency] = currency;
193 jvParams[jss::ripple_state][jss::accounts].
append(acct_a.
human());
194 jvParams[jss::ripple_state][jss::accounts].
append(acct_b.
human());
195 return env.
rpc(
"json",
"ledger_entry",
to_string(jvParams))[jss::result];
202 return jrr[jss::node][sfBalance.fieldName];
221 jv[jss::TransactionType] = jss::EscrowCreate;
233 jv[jss::TransactionType] = jss::EscrowFinish;
237 jv[sfOfferSequence.jsonName] =
seq;
245 jv[jss::TransactionType] = jss::EscrowCancel;
248 jv[sfOwner.jsonName] = from.
human();
249 jv[sfOfferSequence.jsonName] =
seq;
266 jv[jss::TransactionType] = jss::PaymentChannelCreate;
271 jv[jss::SettleDelay] = settleDelay.
count();
274 jv[sfCancelAfter.fieldName] = cancelAfter->time_since_epoch().count();
276 jv[sfDestinationTag.fieldName] = *dstTag;
288 jv[jss::TransactionType] = jss::PaymentChannelFund;
294 jv[sfExpiration.fieldName] =
expiration->time_since_epoch().count();
308 jv[jss::TransactionType] = jss::PaymentChannelClaim;
317 jv[
"Signature"] =
strHex(*signature);
319 jv[
"PublicKey"] =
strHex(pk->slice());
336 auto const slep = view.
read({ltPAYCHAN, chan});
339 return (*slep)[sfBalance];
345 auto const slep = view.
read({ltPAYCHAN, chan});
360 auto const ownerCount = env.
le(account)->getFieldU32(sfOwnerCount);
Value & append(Value const &value)
Append value to array at the end.
UInt size() const
Number of values in array or object.
A currency issued by an account.
Slice slice() const noexcept
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
Json::Value getJson(JsonOptions) const override
Issue const & issue() const
void push_back(STPathElement const &e)
Immutable cryptographic account descriptor.
std::string const & human() const
Returns the human readable public key.
A transaction testing environment.
std::uint32_t ownerCount(Account const &account) const
Return the number of objects owned by an account.
void require(Args const &... args)
Check a set of requirements.
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.
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< SLE const > le(Account const &account) const
Return an account root.
Match the number of items in the account's owner directory.
@ arrayValue
array value (ordered list)
Keylet line(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
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)
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)
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
bool expectLine(Env &env, AccountID const &account, STAmount const &value, bool defaultLimits)
bool equal(STAmount const &sa1, STAmount const &sa2)
constexpr XRPAmount dropsPerXRP
Json::Value getAccountLines(Env &env, AccountID const &acctId)
Json::Value ledgerEntryState(Env &env, Account const &acct_a, Account const &acct_b, std::string const ¤cy)
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 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)
Json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
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)
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)
Json::Value getAccountOffers(Env &env, AccountID const &acct, bool current)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
AccountID const & xrpAccount()
Compute AccountID from public key.
@ current
This was a new validation and was added.
std::string strHex(FwdIt begin, FwdIt end)
constexpr std::uint32_t tfUniversal
std::string to_string(base_uint< Bits, Tag > const &a)
void forEachItem(ReadView const &view, Keylet const &root, std::function< void(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items in the given directory.
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...
Set the sequence number on a JTx.