20 #include <test/jtx/TestHelpers.h>
22 #include <ripple/protocol/TxFlags.h>
23 #include <test/jtx/offer.h>
24 #include <test/jtx/owners.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];
89 return env.
current()->fees().base * n;
95 auto feeDrops = env.
current()->fees().base;
109 bool const accountLow = account < issue.
account;
111 bool expectDefaultTrustLine =
true;
117 low.setIssuer(accountLow ? account : issue.
account);
118 high.setIssuer(accountLow ? issue.
account : account);
120 expectDefaultTrustLine = sle->getFieldAmount(
sfLowLimit) == low &&
124 auto amount = sle->getFieldAmount(
sfBalance);
128 return amount == value && expectDefaultTrustLine;
152 if (sle->getType() == ltOFFER)
156 toMatch.begin(), toMatch.end(), [&](auto const& a) {
157 return a.in == sle->getFieldAmount(sfTakerPays) &&
158 a.out == sle->getFieldAmount(sfTakerGets);
164 return size == cnt && matched == toMatch.size();
171 jvParams[jss::ledger_index] =
"current";
172 jvParams[jss::account_root] = acct.
human();
173 return env.
rpc(
"json",
"ledger_entry",
to_string(jvParams))[jss::result];
184 jvParams[jss::ledger_index] =
"current";
185 jvParams[jss::ripple_state][jss::currency] = currency;
187 jvParams[jss::ripple_state][jss::accounts].
append(acct_a.
human());
188 jvParams[jss::ripple_state][jss::accounts].
append(acct_b.
human());
189 return env.
rpc(
"json",
"ledger_entry",
to_string(jvParams))[jss::result];
215 jv[jss::TransactionType] = jss::EscrowCreate;
227 jv[jss::TransactionType] = jss::EscrowFinish;
239 jv[jss::TransactionType] = jss::EscrowCancel;
260 jv[jss::TransactionType] = jss::PaymentChannelCreate;
265 jv[jss::SettleDelay] = settleDelay.
count();
282 jv[jss::TransactionType] = jss::PaymentChannelFund;
302 jv[jss::TransactionType] = jss::PaymentChannelClaim;
311 jv[
"Signature"] =
strHex(*signature);
313 jv[
"PublicKey"] =
strHex(pk->slice());
357 env(offer(account,
in,
out));
Json::Value getAccountOffers(Env &env, AccountID const &acct, bool current)
const SF_UINT32 sfOfferSequence
const SF_UINT32 sfOwnerCount
void push_back(STPathElement const &e)
constexpr XRPAmount dropsPerXRP
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)
A currency issued by an account.
bool checkArraySize(Json::Value const &val, unsigned int size)
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
Json::Value finish(AccountID const &account, AccountID const &from, std::uint32_t seq)
Issue const & issue() const
void stpath_append_one(STPath &st, Account const &account)
Match the number of items in the account's owner directory.
Json::Value ledgerEntryState(Env &env, Account const &acct_a, Account const &acct_b, std::string const ¤cy)
void require(Args const &... args)
Check a set of requirements.
@ arrayValue
array value (ordered list)
const std::string fieldName
Json::Value getJson(JsonOptions) const override
PrettyAmount xrpMinusFee(Env const &env, std::int64_t xrpAmount)
std::string const & human() const
Returns the human readable public key.
bool channelExists(ReadView const &view, uint256 const &chan)
Slice slice() const noexcept
std::uint32_t ownerCount(test::jtx::Env const &env, test::jtx::Account const &acct)
const Json::StaticString jsonName
void n_offers(Env &env, std::size_t n, Account const &account, STAmount const &in, STAmount const &out)
bool equal(STAmount const &sa1, STAmount const &sa2)
const SF_UINT32 sfExpiration
const SF_AMOUNT sfLowLimit
Value & append(const Value &value)
Append value to array at the end.
uint256 channel(AccountID const &account, AccountID const &dst, std::uint32_t seqProxyValue)
STPathElement IPE(Issue const &iss)
bool expectOffers(Env &env, AccountID const &account, std::uint16_t size, std::vector< Amounts > const &toMatch)
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
AccountID const & xrpAccount()
Compute AccountID from public key.
UInt size() const
Number of values in array or object.
const SF_AMOUNT sfHighLimit
STPathElement cpe(Currency const &c)
STPathElement allpe(AccountID const &a, Issue const &iss)
Keylet line(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
STAmount channelBalance(ReadView const &view, uint256 const &chan)
Set the sequence number on a JTx.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
const SF_UINT32 sfDestinationTag
Json::Value accountBalance(Env &env, Account const &acct)
void fund(jtx::Env &env, jtx::Account const &gw, std::vector< jtx::Account > const &accounts, std::vector< STAmount > const &amts, Fund how)
const SF_AMOUNT sfBalance
const SF_UINT32 sfCancelAfter
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 to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
const SF_UINT256 sfChannel
Immutable cryptographic account descriptor.
std::string strHex(FwdIt begin, FwdIt end)
constexpr std::uint32_t tfUniversal
bool expectLedgerEntryRoot(Env &env, Account const &acct, STAmount const &expectedValue)
bool expectLine(Env &env, AccountID const &account, STAmount const &value, bool defaultLimits)
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
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)
XRPAmount txfee(Env const &env, std::uint16_t n)
A transaction testing environment.
Json::Value getAccountLines(Env &env, AccountID const &acctId)
Json::Value rpc(std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
Json::Value ledgerEntryRoot(Env &env, Account const &acct)
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...
@ ltPAYCHAN
A ledger object describing a single unidirectional XRP payment channel.