xrpld
Loading...
Searching...
No Matches
TestServiceRegistry.h
1#pragma once
2
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/basics/chrono.h>
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/core/HashRouter.h>
8#include <xrpl/core/NetworkIDService.h>
9#include <xrpl/core/ServiceRegistry.h>
10#include <xrpl/ledger/PendingSaves.h>
11#include <xrpl/server/LoadFeeTrack.h>
12
13#include <boost/asio/io_context.hpp>
14
15#include <helpers/TestFamily.h>
16#include <helpers/TestSink.h>
17
18#include <cstdint>
19#include <memory>
20#include <optional>
21#include <stdexcept>
22#include <string>
23
24namespace xrpl::test {
25
29class TestLogs : public Logs
30{
31public:
33 {
34 }
35
41};
42
47{
48public:
49 explicit TestNetworkIDService(std::uint32_t networkID = 0) : networkID_(networkID)
50 {
51 }
52
53 [[nodiscard]] std::uint32_t
54 getNetworkID() const noexcept override
55 {
56 return networkID_;
57 }
58
59private:
61};
62
73{
75 boost::asio::io_context ioContext_;
76 TestFamily family_{logs_.journal("TestFamily")};
77 LoadFeeTrack feeTrack_{logs_.journal("LoadFeeTrack")};
81 "TempNodeCache",
82 16384,
84 stopwatch(),
85 logs_.journal("TaggedCache")};
87 "CachedSLEs",
88 16384,
90 stopwatch(),
91 logs_.journal("TaggedCache")};
94
95public:
97 ~TestServiceRegistry() override = default;
98
99 // Core infrastructure services
102 {
103 throw std::logic_error("TestServiceRegistry::getCollectorManager() not implemented");
104 }
105
106 Family&
107 getNodeFamily() override
108 {
109 return family_;
110 }
111
113 getTimeKeeper() override
114 {
115 throw std::logic_error("TestServiceRegistry::timeKeeper() not implemented");
116 }
117
118 JobQueue&
119 getJobQueue() override
120 {
121 throw std::logic_error("TestServiceRegistry::getJobQueue() not implemented");
122 }
123
124 NodeCache&
126 {
127 return tempNodeCache_;
128 }
129
131 getCachedSLEs() override
132 {
133 return cachedSLEs_;
134 }
135
138 {
139 return networkIDService_;
140 }
141
142 // Protocol and validation services
145 {
146 throw std::logic_error("TestServiceRegistry::getAmendmentTable() not implemented");
147 }
148
150 getHashRouter() override
151 {
152 return hashRouter_;
153 }
154
156 getFeeTrack() override
157 {
158 return feeTrack_;
159 }
160
162 getLoadManager() override
163 {
164 throw std::logic_error("TestServiceRegistry::getLoadManager() not implemented");
165 }
166
168 getValidations() override
169 {
170 throw std::logic_error("TestServiceRegistry::getValidations() not implemented");
171 }
172
174 getValidators() override
175 {
176 throw std::logic_error("TestServiceRegistry::validators() not implemented");
177 }
178
181 {
182 throw std::logic_error("TestServiceRegistry::validatorSites() not implemented");
183 }
184
187 {
188 throw std::logic_error("TestServiceRegistry::validatorManifests() not implemented");
189 }
190
193 {
194 throw std::logic_error("TestServiceRegistry::publisherManifests() not implemented");
195 }
196
197 // Network services
198 Overlay&
199 getOverlay() override
200 {
201 throw std::logic_error("TestServiceRegistry::overlay() not implemented");
202 }
203
204 Cluster&
205 getCluster() override
206 {
207 throw std::logic_error("TestServiceRegistry::cluster() not implemented");
208 }
209
212 {
213 throw std::logic_error("TestServiceRegistry::peerReservations() not implemented");
214 }
215
218 {
219 throw std::logic_error("TestServiceRegistry::getResourceManager() not implemented");
220 }
221
222 // Storage services
224 getNodeStore() override
225 {
226 throw std::logic_error("TestServiceRegistry::getNodeStore() not implemented");
227 }
228
230 getSHAMapStore() override
231 {
232 throw std::logic_error("TestServiceRegistry::getSHAMapStore() not implemented");
233 }
234
237 {
238 throw std::logic_error("TestServiceRegistry::getRelationalDatabase() not implemented");
239 }
240
241 // Ledger services
244 {
245 throw std::logic_error("TestServiceRegistry::getInboundLedgers() not implemented");
246 }
247
250 {
251 throw std::logic_error("TestServiceRegistry::getInboundTransactions() not implemented");
252 }
253
256 {
257 throw std::logic_error("TestServiceRegistry::getAcceptedLedgerCache() not implemented");
258 }
259
262 {
263 throw std::logic_error("TestServiceRegistry::getLedgerMaster() not implemented");
264 }
265
268 {
269 throw std::logic_error("TestServiceRegistry::getLedgerCleaner() not implemented");
270 }
271
274 {
275 throw std::logic_error("TestServiceRegistry::getLedgerReplayer() not implemented");
276 }
277
280 {
281 return pendingSaves_;
282 }
283
285 getOpenLedger() override
286 {
287 throw std::logic_error("TestServiceRegistry::openLedger() not implemented");
288 }
289
290 OpenLedger const&
291 getOpenLedger() const override
292 {
293 throw std::logic_error("TestServiceRegistry::openLedger() const not implemented");
294 }
295
296 // Transaction and operation services
298 getOPs() override
299 {
300 throw std::logic_error("TestServiceRegistry::getOPs() not implemented");
301 }
302
304 getOrderBookDB() override
305 {
306 throw std::logic_error("TestServiceRegistry::getOrderBookDB() not implemented");
307 }
308
311 {
312 throw std::logic_error("TestServiceRegistry::getMasterTransaction() not implemented");
313 }
314
315 TxQ&
316 getTxQ() override
317 {
318 throw std::logic_error("TestServiceRegistry::getTxQ() not implemented");
319 }
320
323 {
324 throw std::logic_error("TestServiceRegistry::getPathRequestManager() not implemented");
325 }
326
327 // Server services
330 {
331 throw std::logic_error("TestServiceRegistry::getServerHandler() not implemented");
332 }
333
335 getPerfLog() override
336 {
337 throw std::logic_error("TestServiceRegistry::getPerfLog() not implemented");
338 }
339
340 // Configuration and state
341 bool
342 isStopping() const override
343 {
344 return false;
345 }
346
348 getJournal(std::string const& name) override
349 {
350 return logs_.journal(name);
351 }
352
353 boost::asio::io_context&
354 getIOContext() override
355 {
356 return ioContext_;
357 }
358
359 Logs&
360 getLogs() override
361 {
362 return logs_;
363 }
364
366 getTrapTxID() const override
367 {
368 return trapTxID_;
369 }
370
372 getWalletDB() override
373 {
374 throw std::logic_error("TestServiceRegistry::getWalletDB() not implemented");
375 }
376
377 // Temporary: Get the underlying Application
379 getApp() override
380 {
381 throw std::logic_error(
382 "TestServiceRegistry::app() not implemented - no Application available in tests");
383 }
384};
385
386} // namespace xrpl::test
A generic endpoint for log messages.
Definition Journal.h:44
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:86
Manages the lifetime of inbound ledgers.
Manages the acquisition and lifetime of transaction sets.
A pool of threads to perform work.
Definition JobQueue.h:60
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:28
Manages partitions for logging.
Definition Log.h:23
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:374
Service that provides access to the network ID.
Provides server functionality for clients.
Definition NetworkOPs.h:82
Represents the open ledger.
Definition OpenLedger.h:43
Tracks order books in the ledger.
Definition OrderBookDB.h:30
Keeps track of which ledgers haven't been fully saved.
class to create database, launch online delete thread, and related SQLite database
Definition SHAMapStore.h:24
Map/cache combination.
Definition TaggedCache.h:67
Manages various times used by the server.
Definition TimeKeeper.h:15
Transaction Queue.
Definition TxQ.h:58
Persistency layer for NodeObject.
Definition Database.h:45
Singleton class that maintains performance counters and optionally writes Json-formatted data to a di...
Definition PerfLog.h:31
Tracks load and resource consumption.
Simulate server's OverlayImpl.
Test implementation of Family for unit tests.
Definition TestFamily.h:30
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
resource::Manager & getResourceManager() override
ValidatorList & getValidators() override
ManifestCache & getPublisherManifests() override
DatabaseCon & getWalletDB() override
Retrieve the "wallet database".
boost::asio::io_context & getIOContext() 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
node_store::Database & getNodeStore() 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:16
Stopwatch & stopwatch()
Returns an instance of a wall clock.
Definition chrono.h:101
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:101