20 #include <ripple/protocol/jss.h>
21 #include <ripple/protocol/TxFlags.h>
34 if (thirdLineCreatesLE)
35 testcase(
"Allow two free trustlines");
37 testcase(
"Dynamic reserve for trustline");
42 auto const gwA =
Account{
"gwA" };
43 auto const gwB =
Account{
"gwB" };
44 auto const acctC =
Account{
"acctC" };
45 auto const acctD =
Account{
"acctD" };
47 auto const & creator = createOnHighAcct ? acctD : acctC;
48 auto const & assistor = createOnHighAcct ? acctC : acctD;
50 auto const txFee = env.
current()->fees().base;
51 auto const baseReserve = env.
current()->fees().accountReserve(0);
52 auto const threelineReserve = env.
current()->fees().accountReserve(3);
54 env.
fund(
XRP(10000), gwA, gwB, assistor);
58 +
drops(3*txFee) , creator);
63 if (thirdLineCreatesLE)
66 env(
trust(creator, assistor[
"USD"](100)),
82 if (thirdLineCreatesLE)
91 jv[
"account"] = creator.human();
94 BEAST_EXPECT(
lines[jss::result][jss::lines].isArray());
95 BEAST_EXPECT(
lines[jss::result][jss::lines].size() == 3);
96 for (
auto const & line :
lines[jss::result][jss::lines])
98 BEAST_EXPECT(line[jss::limit] ==
"100");
106 jv[jss::Account] = a.
human();
108 jv[jss::TransactionType] = jss::TrustSet;
115 testcase(
"SetTrust checks for malformed transactions");
120 auto const gw =
Account{
"gateway" };
121 auto const alice =
Account{
"alice" };
122 env.fund(
XRP(10000), gw, alice);
126 badFlag <= std::numeric_limits<std::uint32_t>::max(); badFlag *= 2)
129 env(
trust(alice, gw[
"USD"](100),
156 testcase <<
"SetTrust " << (createQuality ?
"creates" :
"removes")
157 <<
" quality of trustline for "
158 << (createOnHighAcct ?
"high" :
"low" )
164 auto const alice =
Account{
"alice" };
165 auto const bob =
Account{
"bob" };
167 auto const & fromAcct = createOnHighAcct ? alice : bob;
168 auto const & toAcct = createOnHighAcct ? bob : alice;
170 env.fund(
XRP(10000), fromAcct, toAcct);
173 auto txWithoutQuality =
trust(toAcct, fromAcct[
"USD"](100));
174 txWithoutQuality[
"QualityIn"] =
"0";
175 txWithoutQuality[
"QualityOut"] =
"0";
177 auto txWithQuality = txWithoutQuality;
178 txWithQuality[
"QualityIn"] =
"1000";
179 txWithQuality[
"QualityOut"] =
"1000";
181 auto & tx1 = createQuality ? txWithQuality : txWithoutQuality;
182 auto & tx2 = createQuality ? txWithoutQuality : txWithQuality;
184 auto check_quality = [&](
const bool exists)
187 jv[
"account"] = toAcct.human();
188 auto const lines = env.rpc(
"json",
"account_lines",
to_string(jv));
189 auto quality = exists ? 1000 : 0;
190 BEAST_EXPECT(
lines[jss::result][jss::lines].isArray());
191 BEAST_EXPECT(
lines[jss::result][jss::lines].size() == 1);
192 BEAST_EXPECT(
lines[jss::result][jss::lines][0u][jss::quality_in]
194 BEAST_EXPECT(
lines[jss::result][jss::lines][0u][jss::quality_out]
200 check_quality(createQuality);
203 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.
BEAST_DEFINE_TESTSUITE(AccountDelete, app, ripple)
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)
std::string to_string(ListDisposition disposition)
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)
Immutable cryptographic account descriptor.
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.