xrpld
Loading...
Searching...
No Matches
PeerStub.h
1#pragma once
2
3#include <xrpld/overlay/Message.h>
4#include <xrpld/overlay/Peer.h>
5
6#include <xrpl/basics/base_uint.h>
7#include <xrpl/beast/net/IPEndpoint.h>
8#include <xrpl/json/json_value.h>
9#include <xrpl/protocol/KeyType.h>
10#include <xrpl/protocol/PublicKey.h>
11#include <xrpl/protocol/SecretKey.h>
12
13#include <cstddef>
14#include <cstdint>
15#include <memory>
16#include <optional>
17#include <string>
18
19namespace xrpl::test {
20
30class PeerStub : public Peer
31{
32public:
36 explicit PeerStub(ID id = 0)
38 {
39 }
40
41 ~PeerStub() override = default;
42
43 void
45 {
46 }
47
48 [[nodiscard]] beast::ip::Endpoint
49 getRemoteAddress() const override
50 {
51 return {};
52 }
53
54 void
55 sendTxQueue() override
56 {
57 }
58
59 void
60 addTxQueue(UInt256 const&) override
61 {
62 }
63
64 void
65 removeTxQueue(UInt256 const&) override
66 {
67 }
68
69 void
70 charge(resource::Charge const&, std::string const&) override
71 {
72 }
73
74 [[nodiscard]] ID
75 id() const override
76 {
77 return id_;
78 }
79
80 [[nodiscard]] bool
81 cluster() const override
82 {
83 return false;
84 }
85
86 [[nodiscard]] bool
87 isHighLatency() const override
88 {
89 return false;
90 }
91
92 [[nodiscard]] int
93 getScore(bool) const override
94 {
95 return 0;
96 }
97
98 [[nodiscard]] PublicKey const&
99 getNodePublic() const override
100 {
101 return nodePublicKey_;
102 }
103
105 json() override
106 {
107 return {};
108 }
109
110 [[nodiscard]] bool
112 {
113 return false;
114 }
115
116 [[nodiscard]] std::optional<std::size_t>
117 publisherListSequence(PublicKey const&) const override
118 {
119 return {};
120 }
121
122 void
124 {
125 }
126
127 [[nodiscard]] std::string const&
128 fingerprint() const override
129 {
130 return fingerprint_;
131 }
132
133 [[nodiscard]] UInt256
134 getClosedLedgerHash() const override
135 {
136 return {};
137 }
138
139 [[nodiscard]] bool
140 hasLedger(UInt256 const&, std::uint32_t) const override
141 {
142 return false;
143 }
144
145 void
147 {
148 }
149
150 [[nodiscard]] bool
151 hasTxSet(UInt256 const&) const override
152 {
153 return false;
154 }
155
156 void
157 cycleStatus() override
158 {
159 }
160
161 bool
163 {
164 return false;
165 }
166
167 [[nodiscard]] bool
168 compressionEnabled() const override
169 {
170 return false;
171 }
172
173 [[nodiscard]] bool
174 txReduceRelayEnabled() const override
175 {
176 return false;
177 }
178
179private:
180 ID const id_;
183};
184
185} // namespace xrpl::test
A version-independent IP address and port combination.
Definition IPEndpoint.h:24
Represents a JSON value.
Definition json_value.h:117
A public key.
Definition PublicKey.h:53
A consumption charge.
Definition Charge.h:13
PublicKey const nodePublicKey_
Definition PeerStub.h:181
std::optional< std::size_t > publisherListSequence(PublicKey const &) const override
Definition PeerStub.h:117
bool compressionEnabled() const override
Definition PeerStub.h:168
bool cluster() const override
Definition PeerStub.h:81
void setPublisherListSequence(PublicKey const &, std::size_t const) override
Definition PeerStub.h:123
UInt256 getClosedLedgerHash() const override
Definition PeerStub.h:134
void charge(resource::Charge const &, std::string const &) override
Definition PeerStub.h:70
PublicKey const & getNodePublic() const override
Definition PeerStub.h:99
bool txReduceRelayEnabled() const override
Definition PeerStub.h:174
bool supportsFeature(ProtocolFeature) const override
Definition PeerStub.h:111
void ledgerRange(std::uint32_t &, std::uint32_t &) const override
Definition PeerStub.h:146
void sendTxQueue() override
Definition PeerStub.h:55
std::string const & fingerprint() const override
Definition PeerStub.h:128
void cycleStatus() override
Definition PeerStub.h:157
void removeTxQueue(UInt256 const &) override
Definition PeerStub.h:65
ID id() const override
Definition PeerStub.h:75
void addTxQueue(UInt256 const &) override
Definition PeerStub.h:60
std::string const fingerprint_
Definition PeerStub.h:182
void send(std::shared_ptr< Message > const &) override
Definition PeerStub.h:44
int getScore(bool) const override
Definition PeerStub.h:93
beast::ip::Endpoint getRemoteAddress() const override
Definition PeerStub.h:49
bool hasTxSet(UInt256 const &) const override
Definition PeerStub.h:151
bool hasRange(std::uint32_t, std::uint32_t) override
Definition PeerStub.h:162
bool hasLedger(UInt256 const &, std::uint32_t) const override
Definition PeerStub.h:140
bool isHighLatency() const override
Definition PeerStub.h:87
~PeerStub() override=default
json::Value json() override
Definition PeerStub.h:105
KeyType
Definition KeyType.h:8
PublicKey derivePublicKey(KeyType type, SecretKey const &sk)
Derive the public key from a secret key.
BaseUInt< 256 > UInt256
Definition base_uint.h:580
SecretKey randomSecretKey()
Create a secret key using secure random numbers.