xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
test
app
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
18
namespace
xrpl::test
{
19
20
class
NetworkOPs_test
:
public
beast::unit_test::Suite
21
{
22
public
:
23
void
24
run
()
override
25
{
26
testAllBadHeldTransactions
();
27
}
28
29
void
30
testAllBadHeldTransactions
()
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"
};
41
Env
env{*
this
,
envconfig
(),
std::make_unique<CaptureLogs>
(&logs),
beast::Severity::All
};
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
61
BEAST_DEFINE_TESTSUITE
(
NetworkOPs
, app,
xrpl
);
62
63
}
// namespace xrpl::test
std::string
beast::unit_test::Suite
A testsuite class.
Definition
suite.h:52
beast::unit_test::Suite::testcase
TestcaseT testcase
Memberspace for declaring test cases.
Definition
suite.h:155
xrpl::HashRouter::setFlags
bool setFlags(UInt256 const &key, HashRouterFlags flags)
Set the flags on a hash.
Definition
HashRouter.cpp:94
xrpl::NetworkOPs
Provides server functionality for clients.
Definition
NetworkOPs.h:82
xrpl::ServiceRegistry::getHashRouter
virtual HashRouter & getHashRouter()=0
xrpl::test::NetworkOPs_test
Definition
NetworkOPs_test.cpp:21
xrpl::test::NetworkOPs_test::run
void run() override
Runs the suite.
Definition
NetworkOPs_test.cpp:24
xrpl::test::NetworkOPs_test::testAllBadHeldTransactions
void testAllBadHeldTransactions()
Definition
NetworkOPs_test.cpp:30
xrpl::test::jtx::Account
Immutable cryptographic account descriptor.
Definition
jtx/Account.h:21
xrpl::test::jtx::Env
A transaction testing environment.
Definition
Env.h:161
xrpl::test::jtx::Env::app
Application & app()
Definition
Env.h:300
xrpl::test::jtx::Env::close
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition
Env.cpp:133
xrpl::test::jtx::Env::master
Account const & master
Definition
Env.h:165
xrpl::test::jtx::Env::jt
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
Definition
Env.h:723
xrpl::test::jtx::Env::memoize
void memoize(Account const &account)
Associate AccountID with account.
Definition
Env.cpp:174
xrpl::test::jtx::Fee
Set the fee on a JTx.
Definition
fee.h:20
xrpl::test::jtx::Json
Inject raw JSON.
Definition
jtx_json.h:16
xrpl::test::jtx::Ter
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition
ter.h:18
std::make_unique
T make_unique(T... args)
memory
beast::Severity::All
@ All
Definition
Journal.h:17
xrpl::test::jtx::ticket::create
json::Value create(Account const &account, std::uint32_t count)
Create one of more tickets.
Definition
ticket.cpp:16
xrpl::test::jtx
Definition
Oracle_test.cpp:34
xrpl::test::jtx::envconfig
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition
envconfig.h:38
xrpl::test
Definition
STLedgerEntry.h:21
xrpl::test::BEAST_DEFINE_TESTSUITE
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::terNO_ACCOUNT
@ terNO_ACCOUNT
Definition
TER.h:218
xrpl::HashRouterFlags::HELD
@ HELD
Definition
HashRouter.h:25
xrpl::HashRouterFlags::BAD
@ BAD
Definition
HashRouter.h:23
xrpl::test::jtx::Seq
Set the sequence number on a JTx.
Definition
seq.h:16
Generated by
1.17.0