2#include <test/jtx/check.h> 
    3#include <test/jtx/envconfig.h> 
    5#include <xrpld/app/ledger/LedgerMaster.h> 
    6#include <xrpld/app/tx/apply.h> 
    8#include <xrpl/basics/CountedObject.h> 
    9#include <xrpl/basics/StringUtilities.h> 
   10#include <xrpl/json/json_reader.h> 
   11#include <xrpl/protocol/Indexes.h> 
   12#include <xrpl/protocol/jss.h> 
   26        auto const USD = gw[
"USD"];
 
   27        env.
fund(
XRP(10000), 
"alice", gw);
 
   29        env(
offer(
"alice", USD(20), 
XRP(10)),
 
   31                { "OfferSequence" : 4 } 
 
   39        testcase(
"Account balance < fee destroys correct amount of XRP");
 
   53        BEAST_EXPECT(closed->info().drops == expectedDrops);
 
   55        auto const aliceXRP = 400;
 
   56        auto const aliceAmount = 
XRP(aliceXRP);
 
   62            auto const jt = env.
jt(
pay(env.
master, 
"alice", aliceAmount));
 
   68            BEAST_EXPECT(result.applied);
 
   72        expectedDrops -= next->fees().base;
 
   73        BEAST_EXPECT(next->info().drops == expectedDrops);
 
   77            auto balance = sle->getFieldAmount(sfBalance);
 
   79            BEAST_EXPECT(
balance == aliceAmount);
 
   85            auto const jt = env.
jt(
noop(
"alice"), 
fee(expectedDrops), 
seq(2));
 
   92            BEAST_EXPECT(result.applied);
 
   99            auto balance = sle->getFieldAmount(sfBalance);
 
  104        BEAST_EXPECT(next->info().drops == expectedDrops);
 
 
  110        testcase(
"Signing with a secp256r1 key should fail gracefully");
 
  115        auto test256r1key = [&env](
Account const& acct) {
 
  116            auto const baseFee = env.
current()->fees().base;
 
  120            JTx jt = env.
jt(jsonNoop);
 
  126                "045d02995ec24988d9a2ae06a3733aa35ba0741e87527" 
  127                "ed12909b60bd458052c944b24cbf5893c3e5be321774e" 
  128                "5082e11c034b765861d0effbde87423f8476bb2c";
 
  131            jt.
jv[
"SigningPubKey"] = secp256r1PubKey;
 
  135            auto pubKeyBlob = 
strUnHex(secp256r1PubKey);
 
  137            secp256r1Sig->setFieldVL(sfSigningPubKey, *pubKeyBlob);
 
  138            jt.
stx.reset(secp256r1Sig.release());
 
  141                rpc(
"invalidTransaction",
 
  142                    "fails local checks: Invalid signature."));
 
  148        env.
fund(
XRP(10000), alice, becky);
 
 
  157        testcase(
"Autofilled fee should use the escalated fee");
 
  160            cfg->section(
"transaction_queue")
 
  161                .
set(
"minimum_txn_in_ledger_standalone", 
"3");
 
  162            cfg->FEES.reference_fee = 10;
 
  167        auto const alice = 
Account(
"alice");
 
  172        params[jss::fee_mult_max] = 5000;
 
  177        for (
int i = 0; i < 5; ++i)
 
  182            if (BEAST_EXPECT(tx))
 
  184                BEAST_EXPECT(tx->getAccountID(sfAccount) == alice.id());
 
  185                BEAST_EXPECT(tx->getTxnType() == ttACCOUNT_SET);
 
  186                auto const fee = tx->getFieldAmount(sfFee);
 
  187                BEAST_EXPECT(
fee == 
drops(expectedFees[i]));
 
 
  195        testcase(
"Fee escalation shouldn't allocate extreme memory");
 
  198        using namespace std::chrono_literals;
 
  201            auto& s = cfg->section(
"transaction_queue");
 
  202            s.set(
"minimum_txn_in_ledger_standalone", 
"4294967295");
 
  203            s.set(
"minimum_txn_in_ledger", 
"4294967295");
 
  204            s.set(
"target_txn_in_ledger", 
"4294967295");
 
  205            s.set(
"normal_consensus_increase_percent", 
"4294967295");
 
  213        auto const start = clock_type::now();
 
  215        BEAST_EXPECT(clock_type::now() - start < 1s);
 
 
  222        using boost::asio::buffer;
 
  226            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"; 
  234            buffer(request.data() + 1024, request.length() - 1024)); 
 
  242        testcase(
"Invalid Transaction Object ID Type");
 
  250        env.
fund(
XRP(10'000), alice, bob);
 
  255            if (BEAST_EXPECT(alice_index.isNonZero()))
 
  270                if (!state.peekItem(bob_index, 
digest))
 
  277                for (
auto const& e : list)
 
  279                    result[e.first] = e.second;
 
  285            if (BEAST_EXPECT(bob_index.isNonZero()) &&
 
  286                BEAST_EXPECT(
digest.has_value()))
 
  290                auto const beforeCounts =
 
  296                auto const afterCounts =
 
  299                using namespace std::string_literals;
 
  301                    beforeCounts.at(
"CachedView::hit"s) ==
 
  302                    afterCounts.at(
"CachedView::hit"s));
 
  304                    beforeCounts.at(
"CachedView::hitExpired"s) + 1 ==
 
  305                    afterCounts.at(
"CachedView::hitExpired"s));
 
  307                    beforeCounts.at(
"CachedView::miss"s) ==
 
  308                    afterCounts.at(
"CachedView::miss"s));
 
 
 
  326BEAST_DEFINE_TESTSUITE(Regression, app, 
ripple);
 
Unserialize a JSON document into a Value.
 
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
 
testcase_t testcase
Memberspace for declaring test cases.
 
virtual CachedSLEs & cachedSLEs()=0
 
virtual Config & config()=0
 
virtual TimeKeeper & timeKeeper()=0
 
virtual Family & getNodeFamily()=0
 
virtual LedgerMaster & getLedgerMaster()=0
 
static CountedObjects & getInstance() noexcept
 
std::shared_ptr< Ledger const > getClosedLedger()
 
Writable ledger view that accumulates state and tx changes.
 
void apply(TxsRawView &to) const
Apply changes.
 
uint256 const & as_uint256() const
 
bool del(key_type const &key, bool valid)
 
time_point closeTime() const
Returns the predicted close time, in network time.
 
Immutable cryptographic account descriptor.
 
A transaction testing environment wrapper.
 
A transaction testing environment.
 
Json::Value json(JsonValue &&jv, FN const &... fN)
Create JSON from parameters.
 
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
 
std::shared_ptr< STTx const > tx() const
Return the tx data for the last JTx.
 
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
 
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
 
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
 
beast::Journal const journal
 
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
 
void memoize(Account const &account)
Associate AccountID with account.
 
Match the number of items in the account's owner directory.
 
Check a set of conditions.
 
Set the expected result code for a JTx The test will fail if the code doesn't match.
 
Set the regular signature on a JTx.
 
Set the expected result code for a JTx The test will fail if the code doesn't match.
 
T emplace_back(T... args)
 
@ objectValue
object value (collection of name/value pairs).
 
Keylet account(AccountID const &id) noexcept
AccountID root.
 
Json::Value cash(jtx::Account const &dest, uint256 const &checkId, STAmount const &amount)
Cash a check requiring that a specific amount be delivered.
 
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
 
constexpr XRPAmount dropsPerXRP
 
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
 
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
 
Json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
 
XRP_t const XRP
Converts to XRP Issue or STAmount.
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
 
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,...
 
constexpr XRPAmount INITIAL_XRP
Configure the native currency.
 
static Hasher::result_type digest(void const *data, std::size_t size) noexcept
 
ApplyResult apply(Application &app, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
 
create_genesis_t const create_genesis
 
void testInvalidTxObjectIDType()
 
void run() override
Runs the suite.
 
void testFeeEscalationExtremeConfig()
 
void testLowBalanceDestroy()
 
void testFeeEscalationAutofill()
 
Execution context for applying a JSON transaction.
 
std::shared_ptr< STTx const  > stx
 
Type used to specify DeliverMin for cashing a check.
 
Set the sequence number on a JTx.