1#include <test/jtx/TestHelpers.h>
2#include <test/jtx/offer.h>
3#include <test/jtx/owners.h>
5#include <xrpl/protocol/TxFlags.h>
17 return env.
rpc(
"json",
"account_offers",
to_string(jv))[jss::result];
25 return env.
rpc(
"json",
"account_lines",
to_string(jv))[jss::result];
73 return env.
current()->fees().base * n;
79 auto feeDrops = env.
current()->fees().base;
89 bool const accountLow = account < issue.
account;
91 bool expectDefaultTrustLine =
true;
97 low.setIssuer(accountLow ? account : issue.
account);
98 high.setIssuer(accountLow ? issue.
account : account);
100 expectDefaultTrustLine = sle->getFieldAmount(sfLowLimit) == low && sle->getFieldAmount(sfHighLimit) == high;
103 auto amount = sle->getFieldAmount(sfBalance);
107 return amount == value && expectDefaultTrustLine;
139 if (sle->getType() == ltOFFER)
142 if (std::find_if(toMatch.begin(), toMatch.end(), [&](auto const& a) {
143 return a.in == sle->getFieldAmount(sfTakerPays) && a.out == sle->getFieldAmount(sfTakerGets);
149 return size == cnt && matched == toMatch.size();
156 jvParams[jss::ledger_index] =
"current";
157 jvParams[jss::account_root] = acct.
human();
158 return env.
rpc(
"json",
"ledger_entry",
to_string(jvParams))[jss::result];
165 jvParams[jss::ledger_index] =
"current";
166 jvParams[jss::ripple_state][jss::currency] = currency;
168 jvParams[jss::ripple_state][jss::accounts].
append(acct_a.
human());
169 jvParams[jss::ripple_state][jss::accounts].
append(acct_b.
human());
170 return env.
rpc(
"json",
"ledger_entry",
to_string(jvParams))[jss::result];
177 return jrr[jss::node][sfBalance.fieldName];
201 jv[jss::TransactionType] = jss::PaymentChannelCreate;
205 jv[jss::SettleDelay] = settleDelay.
count();
208 jv[sfCancelAfter.fieldName] = cancelAfter->time_since_epoch().count();
210 jv[sfDestinationTag.fieldName] = *dstTag;
222 jv[jss::TransactionType] = jss::PaymentChannelFund;
227 jv[sfExpiration.fieldName] =
expiration->time_since_epoch().count();
241 jv[jss::TransactionType] = jss::PaymentChannelClaim;
249 jv[
"Signature"] =
strHex(*signature);
251 jv[
"PublicKey"] =
strHex(pk->slice());
265 auto const slep = view.
read({ltPAYCHAN, chan});
268 return (*slep)[sfBalance];
274 auto const slep = view.
read({ltPAYCHAN, chan});
286 auto const ownerCount = env.
le(account)->getFieldU32(sfOwnerCount);
319namespace loanBroker {
325 jv[sfTransactionType] = jss::LoanBrokerSet;
336 jv[sfTransactionType] = jss::LoanBrokerDelete;
338 jv[sfLoanBrokerID] =
to_string(brokerID);
347 jv[sfTransactionType] = jss::LoanBrokerCoverDeposit;
349 jv[sfLoanBrokerID] =
to_string(brokerID);
359 jv[sfTransactionType] = jss::LoanBrokerCoverWithdraw;
361 jv[sfLoanBrokerID] =
to_string(brokerID);
371 jv[sfTransactionType] = jss::LoanBrokerCoverClawback;
387 jv[sfTransactionType] = jss::LoanSet;
389 jv[sfLoanBrokerID] =
to_string(loanBrokerID);
390 jv[sfPrincipalRequested] =
to_string(principalRequested);
399 jv[sfTransactionType] = jss::LoanManage;
410 jv[sfTransactionType] = jss::LoanDelete;
421 jv[sfTransactionType] = jss::LoanPay;
424 jv[sfAmount] =
amount.getJson();
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
Number is a floating point type that can represent a wide range of values.
Slice slice() const noexcept
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
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.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
std::uint32_t ownerCount(Account const &account) const
Return the number of objects owned by an account.
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
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 require(Args const &... args)
Check a set of requirements.
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Match the number of items in the account's owner directory.
@ arrayValue
array value (ordered list)
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Keylet line(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Json::Value coverDeposit(AccountID const &account, uint256 const &brokerID, STAmount const &amount, uint32_t flags)
Json::Value coverWithdraw(AccountID const &account, uint256 const &brokerID, STAmount const &amount, uint32_t flags)
Json::Value del(AccountID const &account, uint256 const &brokerID, uint32_t flags)
Json::Value coverClawback(AccountID const &account, std::uint32_t flags)
Json::Value pay(AccountID const &account, uint256 const &loanID, STAmount const &amount, std::uint32_t flags)
Json::Value manage(AccountID const &account, uint256 const &loanID, std::uint32_t flags)
Json::Value del(AccountID const &account, uint256 const &loanID, std::uint32_t flags)
STAmount channelBalance(ReadView const &view, uint256 const &chan)
uint256 channel(AccountID const &account, AccountID const &dst, std::uint32_t seqProxyValue)
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 fund(AccountID const &account, uint256 const &channel, STAmount const &amount, std::optional< NetClock::time_point > const &expiration)
bool channelExists(ReadView const &view, uint256 const &chan)
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 expectLedgerEntryRoot(Env &env, Account const &acct, STAmount const &expectedValue)
Json::Value getAccountOffers(Env &env, AccountID const &acct, bool current)
PrettyAmount xrpMinusFee(Env const &env, std::int64_t xrpAmount)
bool expectOffers(Env &env, AccountID const &account, std::uint16_t size, std::vector< Amounts > const &toMatch)
bool expectHolding(Env &env, AccountID const &account, STAmount const &value, bool defaultLimits)
Json::Value ledgerEntryState(Env &env, Account const &acct_a, Account const &acct_b, std::string const ¤cy)
std::uint32_t ownerCount(Env const &env, Account const &account)
XRPAmount txfee(Env const &env, std::uint16_t n)
STPathElement allpe(AccountID const &a, Issue const &iss)
Json::Value accountBalance(Env &env, Account const &acct)
STPathElement IPE(Issue const &iss)
STPathElement cpe(Currency const &c)
Json::Value ledgerEntryRoot(Env &env, Account const &acct)
bool equal(STAmount const &sa1, STAmount const &sa2)
constexpr XRPAmount dropsPerXRP
bool checkArraySize(Json::Value const &val, unsigned int size)
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
void stpath_append_one(STPath &st, Account const &account)
void n_offers(Env &env, std::size_t n, Account const &account, STAmount const &in, STAmount const &out)
Json::Value getAccountLines(Env &env, AccountID const &acctId)
Json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
std::string to_string(base_uint< Bits, Tag > const &a)
std::string strHex(FwdIt begin, FwdIt end)
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.
@ current
This was a new validation and was added.
AccountID const & xrpAccount()
Compute AccountID from public key.
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...