xrpld
Loading...
Searching...
No Matches
NetworkOPs_test.cpp
1#include <test/jtx/CaptureLogs.h>
2#include <test/jtx/Env.h>
3#include <test/jtx/envconfig.h>
4#include <test/jtx/fee.h>
5#include <test/jtx/jtx_json.h>
6#include <test/jtx/seq.h>
7#include <test/jtx/ter.h>
8#include <test/jtx/ticket.h>
9
10#include <xrpl/beast/unit_test/suite.h>
11#include <xrpl/beast/utility/Journal.h>
12#include <xrpl/core/HashRouter.h>
13#include <xrpl/protocol/TER.h>
14#include <xrpl/protocol/jss.h>
15
16#include <memory>
17
18namespace xrpl::test {
19
21{
22public:
23 void
24 run() override
25 {
27 }
28
29 void
31 {
32 // All transactions are already marked as SF_BAD, and we should be able
33 // to handle the case properly without an assertion failure
34 testcase("No valid transactions in batch");
35
36 std::string logs;
37
38 {
39 using namespace jtx;
40 auto const alice = Account{"alice"};
42 env.memoize(env.master);
43 env.memoize(alice);
44
45 auto const jtx = env.jt(ticket::create(alice, 1), Seq(1), Fee(10));
46
47 auto transactionId = jtx.stx->getTransactionID();
48 env.app().getHashRouter().setFlags(transactionId, HashRouterFlags::HELD);
49
50 env(jtx, Json(jss::Sequence, 1), Ter(terNO_ACCOUNT));
51
52 env.app().getHashRouter().setFlags(transactionId, HashRouterFlags::BAD);
53
54 env.close();
55 }
56
57 BEAST_EXPECT(logs.contains("No transaction to process!"));
58 }
59};
60
62
63} // namespace xrpl::test
A testsuite class.
Definition suite.h:50
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:149
bool setFlags(uint256 const &key, HashRouterFlags flags)
Set the flags on a hash.
Provides server functionality for clients.
Definition NetworkOPs.h:71
virtual HashRouter & getHashRouter()=0
void run() override
Runs the suite.
Immutable cryptographic account descriptor.
Definition jtx/Account.h:17
A transaction testing environment.
Definition Env.h:143
Application & app()
Definition Env.h:280
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:133
Account const & master
Definition Env.h:147
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
Definition Env.h:566
void memoize(Account const &account)
Associate AccountID with account.
Definition Env.cpp:174
Set the fee on a JTx.
Definition fee.h:15
Inject raw JSON.
Definition jtx_json.h:11
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition ter.h:13
T make_unique(T... args)
json::Value create(Account const &account, std::uint32_t count)
Create one of more tickets.
Definition ticket.cpp:16
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:28
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ terNO_ACCOUNT
Definition TER.h:209
Set the sequence number on a JTx.
Definition seq.h:12