xrpld
Loading...
Searching...
No Matches
TestServiceRegistry.h
1#pragma once
2
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/chrono.h>
5#include <xrpl/core/HashRouter.h>
6#include <xrpl/core/NetworkIDService.h>
7#include <xrpl/core/ServiceRegistry.h>
8#include <xrpl/ledger/PendingSaves.h>
9#include <xrpl/server/LoadFeeTrack.h>
10
11#include <boost/asio/io_context.hpp>
12
13#include <helpers/TestFamily.h>
14#include <helpers/TestSink.h>
15
16#include <optional>
17#include <stdexcept>
18
19namespace xrpl::test {
20
22class TestLogs : public Logs
23{
24public:
26 {
27 }
28
34};
35
38{
39public:
40 explicit TestNetworkIDService(std::uint32_t networkID = 0) : networkID_(networkID)
41 {
42 }
43
44 [[nodiscard]] std::uint32_t
45 getNetworkID() const noexcept override
46 {
47 return networkID_;
48 }
49
50private:
52};
53
63{
65 boost::asio::io_context ioContext_;
66 TestFamily family_{logs_.journal("TestFamily")};
67 LoadFeeTrack feeTrack_{logs_.journal("LoadFeeTrack")};
71 "TempNodeCache",
72 16384,
74 stopwatch(),
75 logs_.journal("TaggedCache")};
77 "CachedSLEs",
78 16384,
80 stopwatch(),
81 logs_.journal("TaggedCache")};
84
85public:
87 ~TestServiceRegistry() override = default;
88
89 // Core infrastructure services
92 {
93 throw std::logic_error("TestServiceRegistry::getCollectorManager() not implemented");
94 }
95
96 Family&
97 getNodeFamily() override
98 {
99 return family_;
100 }
101
103 getTimeKeeper() override
104 {
105 throw std::logic_error("TestServiceRegistry::timeKeeper() not implemented");
106 }
107
108 JobQueue&
109 getJobQueue() override
110 {
111 throw std::logic_error("TestServiceRegistry::getJobQueue() not implemented");
112 }
113
114 NodeCache&
116 {
117 return tempNodeCache_;
118 }
119
121 getCachedSLEs() override
122 {
123 return cachedSLEs_;
124 }
125
128 {
129 return networkIDService_;
130 }
131
132 // Protocol and validation services
135 {
136 throw std::logic_error("TestServiceRegistry::getAmendmentTable() not implemented");
137 }
138
140 getHashRouter() override
141 {
142 return hashRouter_;
143 }
144
146 getFeeTrack() override
147 {
148 return feeTrack_;
149 }
150
152 getLoadManager() override
153 {
154 throw std::logic_error("TestServiceRegistry::getLoadManager() not implemented");
155 }
156
158 getValidations() override
159 {
160 throw std::logic_error("TestServiceRegistry::getValidations() not implemented");
161 }
162
164 getValidators() override
165 {
166 throw std::logic_error("TestServiceRegistry::validators() not implemented");
167 }
168
171 {
172 throw std::logic_error("TestServiceRegistry::validatorSites() not implemented");
173 }
174
177 {
178 throw std::logic_error("TestServiceRegistry::validatorManifests() not implemented");
179 }
180
183 {
184 throw std::logic_error("TestServiceRegistry::publisherManifests() not implemented");
185 }
186
187 // Network services
188 Overlay&
189 getOverlay() override
190 {
191 throw std::logic_error("TestServiceRegistry::overlay() not implemented");
192 }
193
194 Cluster&
195 getCluster() override
196 {
197 throw std::logic_error("TestServiceRegistry::cluster() not implemented");
198 }
199
202 {
203 throw std::logic_error("TestServiceRegistry::peerReservations() not implemented");
204 }
205
208 {
209 throw std::logic_error("TestServiceRegistry::getResourceManager() not implemented");
210 }
211
212 // Storage services
214 getNodeStore() override
215 {
216 throw std::logic_error("TestServiceRegistry::getNodeStore() not implemented");
217 }
218
220 getSHAMapStore() override
221 {
222 throw std::logic_error("TestServiceRegistry::getSHAMapStore() not implemented");
223 }
224
227 {
228 throw std::logic_error("TestServiceRegistry::getRelationalDatabase() not implemented");
229 }
230
231 // Ledger services
234 {
235 throw std::logic_error("TestServiceRegistry::getInboundLedgers() not implemented");
236 }
237
240 {
241 throw std::logic_error("TestServiceRegistry::getInboundTransactions() not implemented");
242 }
243
246 {
247 throw std::logic_error("TestServiceRegistry::getAcceptedLedgerCache() not implemented");
248 }
249
252 {
253 throw std::logic_error("TestServiceRegistry::getLedgerMaster() not implemented");
254 }
255
258 {
259 throw std::logic_error("TestServiceRegistry::getLedgerCleaner() not implemented");
260 }
261
264 {
265 throw std::logic_error("TestServiceRegistry::getLedgerReplayer() not implemented");
266 }
267
270 {
271 return pendingSaves_;
272 }
273
275 getOpenLedger() override
276 {
277 throw std::logic_error("TestServiceRegistry::openLedger() not implemented");
278 }
279
280 OpenLedger const&
281 getOpenLedger() const override
282 {
283 throw std::logic_error("TestServiceRegistry::openLedger() const not implemented");
284 }
285
286 // Transaction and operation services
288 getOPs() override
289 {
290 throw std::logic_error("TestServiceRegistry::getOPs() not implemented");
291 }
292
294 getOrderBookDB() override
295 {
296 throw std::logic_error("TestServiceRegistry::getOrderBookDB() not implemented");
297 }
298
301 {
302 throw std::logic_error("TestServiceRegistry::getMasterTransaction() not implemented");
303 }
304
305 TxQ&
306 getTxQ() override
307 {
308 throw std::logic_error("TestServiceRegistry::getTxQ() not implemented");
309 }
310
313 {
314 throw std::logic_error("TestServiceRegistry::getPathRequestManager() not implemented");
315 }
316
317 // Server services
320 {
321 throw std::logic_error("TestServiceRegistry::getServerHandler() not implemented");
322 }
323
325 getPerfLog() override
326 {
327 throw std::logic_error("TestServiceRegistry::getPerfLog() not implemented");
328 }
329
330 // Configuration and state
331 bool
332 isStopping() const override
333 {
334 return false;
335 }
336
338 getJournal(std::string const& name) override
339 {
340 return logs_.journal(name);
341 }
342
343 boost::asio::io_context&
344 getIOContext() override
345 {
346 return ioContext_;
347 }
348
349 Logs&
350 getLogs() override
351 {
352 return logs_;
353 }
354
356 getTrapTxID() const override
357 {
358 return trapTxID_;
359 }
360
362 getWalletDB() override
363 {
364 throw std::logic_error("TestServiceRegistry::getWalletDB() not implemented");
365 }
366
367 // Temporary: Get the underlying Application
369 getApp() override
370 {
371 throw std::logic_error(
372 "TestServiceRegistry::app() not implemented - no Application available in tests");
373 }
374};
375
376} // namespace xrpl::test
A generic endpoint for log messages.
Definition Journal.h:38
The amendment table stores the list of enabled and potential amendments.
Provides the beast::insight::Collector service.
Routing table for objects identified by hash.
Definition HashRouter.h:77
Manages the lifetime of inbound ledgers.
Manages the acquisition and lifetime of transaction sets.
A pool of threads to perform work.
Definition JobQueue.h:43
Check the ledger/transaction databases to make sure they have continuity.
Manages the lifetime of ledger replay tasks.
Manages the current fee schedule.
Manages load sources.
Definition LoadManager.h:27
Manages partitions for logging.
Definition Log.h:20
beast::Severity threshold() const
Definition Log.cpp:143
Logs(beast::Severity level)
Definition Log.cpp:112
Remembers manifests with the highest sequence number.
Definition Manifest.h:236
Service that provides access to the network ID.
Provides server functionality for clients.
Definition NetworkOPs.h:71
Persistency layer for NodeObject.
Definition Database.h:32
Represents the open ledger.
Definition OpenLedger.h:33
Tracks order books in the ledger.
Definition OrderBookDB.h:29
Keeps track of which ledgers haven't been fully saved.
Tracks load and resource consumption.
class to create database, launch online delete thread, and related SQLite database
Definition SHAMapStore.h:19
Map/cache combination.
Definition TaggedCache.h:59
Manages various times used by the server.
Definition TimeKeeper.h:12
Transaction Queue.
Definition TxQ.h:40
Singleton class that maintains performance counters and optionally writes Json-formatted data to a di...
Definition PerfLog.h:31
Simulate server's OverlayImpl.
Test implementation of Family for unit tests.
Definition TestFamily.h:20
Logs implementation that creates TestSink instances.
std::unique_ptr< beast::Journal::Sink > makeSink(std::string const &, beast::Severity threshold) override
TestLogs(beast::Severity level=beast::Severity::Warning)
Simple NetworkIDService implementation for tests.
TestNetworkIDService(std::uint32_t networkID=0)
std::uint32_t getNetworkID() const noexcept override
Get the configured network ID.
OpenLedger const & getOpenLedger() const override
InboundTransactions & getInboundTransactions() override
ManifestCache & getValidatorManifests() override
beast::Journal getJournal(std::string const &name) override
TimeKeeper & getTimeKeeper() override
RelationalDatabase & getRelationalDatabase() override
ValidatorList & getValidators() override
NodeStore::Database & getNodeStore() override
ManifestCache & getPublisherManifests() override
DatabaseCon & getWalletDB() override
Retrieve the "wallet database".
boost::asio::io_context & getIOContext() override
Resource::Manager & getResourceManager() override
PendingSaves & getPendingSaves() override
InboundLedgers & getInboundLedgers() override
PeerReservationTable & getPeerReservations() override
LoadFeeTrack & getFeeTrack() override
CachedSLEs & getCachedSLEs() override
HashRouter & getHashRouter() override
TransactionMaster & getMasterTransaction() override
AmendmentTable & getAmendmentTable() override
perf::PerfLog & getPerfLog() override
NetworkIDService & getNetworkIDService() override
std::optional< uint256 > trapTxID_
SHAMapStore & getSHAMapStore() override
LoadManager & getLoadManager() override
ValidatorSite & getValidatorSites() override
CollectorManager & getCollectorManager() override
PathRequestManager & getPathRequestManager() override
TaggedCache< uint256, AcceptedLedger > & getAcceptedLedgerCache() override
LedgerCleaner & getLedgerCleaner() override
OpenLedger & getOpenLedger() override
std::optional< uint256 > const & getTrapTxID() const override
LedgerReplayer & getLedgerReplayer() override
OrderBookDB & getOrderBookDB() override
~TestServiceRegistry() override=default
ServerHandler & getServerHandler() override
LedgerMaster & getLedgerMaster() override
RCLValidations & getValidations() override
boost::asio::io_context ioContext_
NodeCache & getTempNodeCache() override
T make_unique(T... args)
Severity
Severity level / threshold of a Journal message.
Definition Journal.h:11
Stopwatch & stopwatch()
Returns an instance of a wall clock.
Definition chrono.h:94
Validations< RCLValidationsAdaptor > RCLValidations
Alias for RCL-specific instantiation of generic Validations.
TaggedCache< uint256, SLE const > CachedSLEs
TaggedCache< SHAMapHash, Blob > NodeCache
Structure used to customize HashRouter behavior.
Definition HashRouter.h:91