19 #include <ripple/protocol/TxFlags.h>
20 #include <ripple/protocol/jss.h>
33 if (thirdLineCreatesLE)
34 testcase(
"Allow two free trustlines");
36 testcase(
"Dynamic reserve for trustline");
41 auto const gwA =
Account{
"gwA"};
42 auto const gwB =
Account{
"gwB"};
43 auto const acctC =
Account{
"acctC"};
44 auto const acctD =
Account{
"acctD"};
46 auto const& creator = createOnHighAcct ? acctD : acctC;
47 auto const& assistor = createOnHighAcct ? acctC : acctD;
49 auto const txFee = env.
current()->fees().base;
50 auto const baseReserve = env.
current()->fees().accountReserve(0);
51 auto const threelineReserve = env.
current()->fees().accountReserve(3);
53 env.
fund(
XRP(10000), gwA, gwB, assistor);
64 if (thirdLineCreatesLE)
67 env(
trust(creator, assistor[
"USD"](100)),
74 env(
trust(assistor, creator[
"USD"](100)),
79 env(
trust(creator, assistor[
"USD"](100)),
86 if (thirdLineCreatesLE)
88 env(
trust(creator, assistor[
"USD"](100)),
93 env(
trust(creator, assistor[
"USD"](100)),
97 jv[
"account"] = creator.human();
100 BEAST_EXPECT(
lines[jss::result][jss::lines].isArray());
101 BEAST_EXPECT(
lines[jss::result][jss::lines].size() == 3);
102 for (
auto const& line :
lines[jss::result][jss::lines])
104 BEAST_EXPECT(line[jss::limit] ==
"100");
112 testcase(
"SetTrust using a ticket");
118 auto const gw =
Account{
"gateway"};
119 auto const alice =
Account{
"alice"};
120 auto const USD = gw[
"USD"];
122 env.fund(
XRP(10000), gw, alice);
131 env(ticket::create(alice, 1));
139 env(
pay(gw, alice, USD(200)));
147 jv[jss::Account] = a.
human();
149 jv[jss::TransactionType] = jss::TrustSet;
157 testcase(
"SetTrust checks for malformed transactions");
162 auto const gw =
Account{
"gateway"};
163 auto const alice =
Account{
"alice"};
164 env.fund(
XRP(10000), gw, alice);
168 badFlag <= std::numeric_limits<std::uint32_t>::max();
204 testcase <<
"SetTrust " << (createQuality ?
"creates" :
"removes")
205 <<
" quality of trustline for "
206 << (createOnHighAcct ?
"high" :
"low") <<
" account";
211 auto const alice =
Account{
"alice"};
212 auto const bob =
Account{
"bob"};
214 auto const& fromAcct = createOnHighAcct ? alice : bob;
215 auto const& toAcct = createOnHighAcct ? bob : alice;
217 env.fund(
XRP(10000), fromAcct, toAcct);
219 auto txWithoutQuality =
trust(toAcct, fromAcct[
"USD"](100));
220 txWithoutQuality[
"QualityIn"] =
"0";
221 txWithoutQuality[
"QualityOut"] =
"0";
223 auto txWithQuality = txWithoutQuality;
224 txWithQuality[
"QualityIn"] =
"1000";
225 txWithQuality[
"QualityOut"] =
"1000";
227 auto& tx1 = createQuality ? txWithQuality : txWithoutQuality;
228 auto& tx2 = createQuality ? txWithoutQuality : txWithQuality;
230 auto check_quality = [&](
const bool exists) {
232 jv[
"account"] = toAcct.human();
233 auto const lines = env.rpc(
"json",
"account_lines",
to_string(jv));
234 auto quality = exists ? 1000 : 0;
235 BEAST_EXPECT(
lines[jss::result][jss::lines].isArray());
236 BEAST_EXPECT(
lines[jss::result][jss::lines].size() == 1);
238 lines[jss::result][jss::lines][0u][jss::quality_in] == quality);
240 lines[jss::result][jss::lines][0u][jss::quality_out] ==
245 check_quality(createQuality);
248 check_quality(!createQuality);
Currency const & badCurrency()
We deliberately disallow the currency that looks like "XRP" because too many people were using it ins...
bool to_currency(Currency ¤cy, std::string const &code)
Tries to convert a string to a Currency, returns true on success.
void testFreeTrustlines(bool thirdLineCreatesLE, bool createOnHighAcct)
const XRP_t XRP
Converts to XRP Issue or STAmount.
A currency issued by an account.
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
const std::uint32_t tfTrustSetMask
Json::Value getJson(JsonOptions) const override
Check a set of conditions.
void testModifyQualityOfTrustline(bool createQuality, bool createOnHighAcct)
std::string const & human() const
Returns the human readable public key.
Json::Value trust_explicit_amt(jtx::Account const &a, STAmount const &amt)
Set a ticket sequence on a JTx.
void testMalformedTransaction()
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
@ tecNO_LINE_INSUF_RESERVE
Json::Value pay(Account const &account, Account const &to, AnyAmount amount)
Create a payment.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
Immutable cryptographic account descriptor.
void testTicketSetTrust()
const std::uint32_t tfSetfAuth
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
AccountID const & noAccount()
A placeholder for empty accounts.
A transaction testing environment.
Json::Value rpc(std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
BEAST_DEFINE_TESTSUITE(DeliverMin, app, ripple)