rippled
Loading...
Searching...
No Matches
NetworkOPs_test.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2020 Dev Null Productions
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <test/jtx.h>
21#include <test/jtx/CaptureLogs.h>
22#include <test/jtx/Env.h>
23
24#include <xrpld/app/misc/HashRouter.h>
25
26namespace ripple {
27namespace test {
28
30{
31public:
32 void
33 run() override
34 {
36 }
37
38 void
40 {
41 // All trasactions are already marked as SF_BAD, and we should be able
42 // to handle the case properly without an assertion failure
43 testcase("No valid transactions in batch");
44
45 std::string logs;
46
47 {
48 using namespace jtx;
49 auto const alice = Account{"alice"};
50 Env env{
51 *this,
52 envconfig(),
55 env.memoize(env.master);
56 env.memoize(alice);
57
58 auto const jtx = env.jt(ticket::create(alice, 1), seq(1), fee(10));
59
60 auto transacionId = jtx.stx->getTransactionID();
61 env.app().getHashRouter().setFlags(
62 transacionId, HashRouterFlags::HELD);
63
64 env(jtx, json(jss::Sequence, 1), ter(terNO_ACCOUNT));
65
66 env.app().getHashRouter().setFlags(
67 transacionId, HashRouterFlags::BAD);
68
69 env.close();
70 }
71
72 BEAST_EXPECT(
73 logs.find("No transaction to process!") != std::string::npos);
74 }
75};
76
77BEAST_DEFINE_TESTSUITE(NetworkOPs, app, ripple);
78
79} // namespace test
80} // namespace ripple
A testsuite class.
Definition suite.h:55
testcase_t testcase
Memberspace for declaring test cases.
Definition suite.h:155
Provides server functionality for clients.
Definition NetworkOPs.h:89
void run() override
Runs the suite.
Immutable cryptographic account descriptor.
Definition Account.h:39
A transaction testing environment.
Definition Env.h:121
void memoize(Account const &account)
Associate AccountID with account.
Definition Env.cpp:156
Set the fee on a JTx.
Definition fee.h:37
Inject raw JSON.
Definition jtx_json.h:33
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition ter.h:35
T find(T... args)
T is_same_v
Json::Value create(Account const &account, std::uint32_t count)
Create one of more tickets.
Definition ticket.cpp:31
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:54
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
@ terNO_ACCOUNT
Definition TER.h:217
Set the sequence number on a JTx.
Definition seq.h:34