19 #include <test/jtx/envconfig.h>
20 #include <ripple/app/tx/apply.h>
21 #include <ripple/basics/StringUtilities.h>
22 #include <ripple/json/json_reader.h>
23 #include <ripple/protocol/Feature.h>
24 #include <ripple/protocol/jss.h>
37 auto const USD = gw[
"USD"];
38 env.
fund(
XRP(10000),
"alice", gw);
41 { "OfferSequence" : 4 }
47 testcase(
"Account balance < fee destroys correct amount of XRP");
55 auto closed = std::make_shared<Ledger>(
59 BEAST_EXPECT(closed->info().drops == expectedDrops);
61 auto const aliceXRP = 400;
62 auto const aliceAmount =
XRP(aliceXRP);
64 auto next = std::make_shared<Ledger>(
69 auto const jt = env.
jt(
pay(env.
master,
"alice", aliceAmount));
75 BEAST_EXPECT(result.second);
79 expectedDrops -= next->fees().base;
80 BEAST_EXPECT(next->info().drops == expectedDrops);
82 auto const sle = next->read(
87 BEAST_EXPECT(
balance == aliceAmount );
93 auto const jt = env.
jt(
noop(
"alice"),
fee(expectedDrops),
101 BEAST_EXPECT(result.second);
106 auto const sle = next->read(
114 BEAST_EXPECT(next->info().drops == expectedDrops);
119 testcase(
"Signing with a secp256r1 key should fail gracefully");
124 auto test256r1key = [&env] (
Account const& acct)
126 auto const baseFee = env.
current()->fees().base;
130 JTx jt = env.
jt (jsonNoop);
136 "045d02995ec24988d9a2ae06a3733aa35ba0741e87527"
137 "ed12909b60bd458052c944b24cbf5893c3e5be321774e"
138 "5082e11c034b765861d0effbde87423f8476bb2c";
141 jt.
jv[
"SigningPubKey"] = secp256r1PubKey;
144 auto secp256r1Sig = std::make_unique<STTx>(*(jt.
stx));
145 auto pubKeyBlob =
strUnHex (secp256r1PubKey);
147 secp256r1Sig->setFieldVL
149 jt.
stx.reset (secp256r1Sig.release());
157 env.
fund(
XRP(10000), alice, becky);
159 test256r1key (alice);
160 test256r1key (becky);
165 testcase(
"Autofilled fee should use the escalated fee");
169 cfg->section(
"transaction_queue")
170 .
set(
"minimum_txn_in_ledger_standalone",
"3");
175 auto const alice =
Account(
"alice");
180 params[jss::fee_mult_max] = 5000;
182 expectedFees({ 10, 10, 8889, 13889, 20000 });
186 for (
int i = 0; i < 5; ++i)
191 if (BEAST_EXPECT(tx))
193 BEAST_EXPECT(tx->getAccountID(
sfAccount) == alice.id());
195 auto const fee = tx->getFieldAmount(
sfFee);
196 BEAST_EXPECT(
fee ==
drops(expectedFees[i]));
203 testcase(
"Fee escalation shouldn't allocate extreme memory");
206 using namespace std::chrono_literals;
210 auto& s = cfg->section(
"transaction_queue");
211 s.set(
"minimum_txn_in_ledger_standalone",
"4294967295");
212 s.set(
"minimum_txn_in_ledger",
"4294967295");
213 s.set(
"target_txn_in_ledger",
"4294967295");
214 s.set(
"normal_consensus_increase_percent",
"4294967295");
222 auto const start = clock_type::now();
224 BEAST_EXPECT(clock_type::now() - start < 1s);
230 using boost::asio::buffer;
231 testcase(
"jsonInvalid");
233 std::string const request = R
"json({"command":"path_find","id":19,"subcommand":"create","source_account":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","destination_account":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","destination_amount":"1000000","source_currencies":[{"currency":"0000000000000000000000000000000000000000"},{"currency":"0000000000000000000000005553440000000000"},{"currency":"0000000000000000000000004254430000000000"},{"issuer":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","currency":"0000000000000000000000004254430000000000"},{"issuer":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","currency":"0000000000000000000000004254430000000000"},{"issuer":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","currency":"0000000000000000000000004555520000000000"},{"currency":"0000000000000000000000004554480000000000"},{"currency":"0000000000000000000000004A50590000000000"},{"issuer":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","currency":"000000000000000000000000434E590000000000"},{"currency":"0000000000000000000000004742490000000000"},{"issuer":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","currency":"0000000000000000000000004341440000000000"}]})json";
241 BEAST_EXPECT(jrReader.parse(jvRequest, buffers) && jvRequest.isObject());
Json::Value noop(Account const &account)
The null transaction.
const XRP_t XRP
Converts to XRP Issue or STAmount.
constexpr XRPAmount dropsPerXRP
BEAST_DEFINE_TESTSUITE(AccountDelete, app, ripple)
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
std::shared_ptr< STTx const > tx() const
Return the tx data for the last JTx.
std::pair< TER, bool > apply(Application &app, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
Set the expected result code for a JTx The test will fail if the code doesn't match.
void apply(TxsRawView &to) const
Apply changes.
Match the number of items in the account's owner directory.
const SF_Blob sfSigningPubKey(access, STI_VL, 3, "SigningPubKey")
Writable ledger view that accumulates state and tx changes.
std::shared_ptr< STTx const > stx
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
Check a set of conditions.
const beast::Journal journal
boost::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
virtual TimeKeeper & timeKeeper()=0
Unserialize a JSON document into a Value.
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Json::Value offer(Account const &account, STAmount const &in, STAmount const &out, std::uint32_t flags)
Create an offer.
constexpr XRPAmount INITIAL_XRP
Configure the native currency.
void testFeeEscalationExtremeConfig()
virtual Family & family()=0
@ objectValue
object value (collection of name/value pairs).
static const account_t account
virtual Config & config()=0
Execution context for applying a JSON transaction.
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,...
virtual time_point closeTime() const =0
Returns the close time, in network time.
Set the regular signature on a JTx.
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
A transaction testing environment wrapper.
const SF_Amount sfFee(access, STI_AMOUNT, 8, "Fee")
Set the sequence number on a JTx.
void testFeeEscalationAutofill()
T emplace_back(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const SF_Amount sfBalance(access, STI_AMOUNT, 2, "Balance")
Json::Value pay(Account const &account, Account const &to, AnyAmount amount)
Create a payment.
void close(NetClock::time_point closeTime, boost::optional< std::chrono::milliseconds > consensusDelay=boost::none)
Close and advance the ledger.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
const create_genesis_t create_genesis
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
void testLowBalanceDestroy()
Immutable cryptographic account descriptor.
void memoize(Account const &account)
Associate AccountID with account.
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Json::Value json(JsonValue &&jv, FN const &... fN)
Create JSON from parameters.
A transaction testing environment.