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;
163 [&](
auto const& issue) {
182 if (sle->getType() == ltOFFER)
186 toMatch.begin(), toMatch.end(), [&](auto const& a) {
187 return a.in == sle->getFieldAmount(sfTakerPays) &&
188 a.out == sle->getFieldAmount(sfTakerGets);
194 return size == cnt && matched == toMatch.size();
201 jvParams[jss::ledger_index] =
"current";
202 jvParams[jss::account_root] = acct.
human();
203 return env.
rpc(
"json",
"ledger_entry",
to_string(jvParams))[jss::result];
214 jvParams[jss::ledger_index] =
"current";
215 jvParams[jss::ripple_state][jss::currency] = currency;
217 jvParams[jss::ripple_state][jss::accounts].
append(acct_a.
human());
218 jvParams[jss::ripple_state][jss::accounts].
append(acct_b.
human());
219 return env.
rpc(
"json",
"ledger_entry",
to_string(jvParams))[jss::result];
226 return jrr[jss::node][sfBalance.fieldName];
251 jv[jss::TransactionType] = jss::PaymentChannelCreate;
255 jv[jss::SettleDelay] = settleDelay.
count();
258 jv[sfCancelAfter.fieldName] = cancelAfter->time_since_epoch().count();
260 jv[sfDestinationTag.fieldName] = *dstTag;
272 jv[jss::TransactionType] = jss::PaymentChannelFund;
277 jv[sfExpiration.fieldName] =
expiration->time_since_epoch().count();
291 jv[jss::TransactionType] = jss::PaymentChannelClaim;
299 jv[
"Signature"] =
strHex(*signature);
301 jv[
"PublicKey"] =
strHex(pk->slice());
318 auto const slep = view.
read({ltPAYCHAN, chan});
321 return (*slep)[sfBalance];
327 auto const slep = view.
read({ltPAYCHAN, chan});
342 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.
constexpr value_type const & value() const
A currency issued by an account.
constexpr MPTID const & getMptID() const
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=JsonOptions::none) 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 mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
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)
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 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)
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 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)
bool expectHolding(Env &env, AccountID const &account, STAmount const &value, bool defaultLimits)
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.
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.
std::string strHex(FwdIt begin, FwdIt end)
std::string to_string(base_uint< Bits, Tag > const &a)
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...