xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
test
jtx
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
19
namespace
xrpl::test
{
20
30
class
PeerStub
:
public
Peer
31
{
32
public
:
36
explicit
PeerStub
(ID
id
= 0)
37
:
id_
(
id
),
nodePublicKey_
(
derivePublicKey
(
KeyType
::
Ed25519
,
randomSecretKey
()))
38
{
39
}
40
41
~PeerStub
()
override
=
default
;
42
43
void
44
send
(
std::shared_ptr<Message>
const
&)
override
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
104
json::Value
105
json
()
override
106
{
107
return
{};
108
}
109
110
[[nodiscard]]
bool
111
supportsFeature
(
ProtocolFeature
)
const override
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
123
setPublisherListSequence
(
PublicKey
const
&,
std::size_t
const
)
override
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
146
ledgerRange
(
std::uint32_t
&,
std::uint32_t
&)
const override
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
162
hasRange
(
std::uint32_t
,
std::uint32_t
)
override
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
179
private
:
180
ID
const
id_
;
181
PublicKey
const
nodePublicKey_
;
182
std::string
const
fingerprint_
;
183
};
184
185
}
// namespace xrpl::test
std::string
beast::ip::Endpoint
A version-independent IP address and port combination.
Definition
IPEndpoint.h:24
json::Value
Represents a JSON value.
Definition
json_value.h:117
xrpl::PublicKey
A public key.
Definition
PublicKey.h:53
xrpl::resource::Charge
A consumption charge.
Definition
Charge.h:13
xrpl::test::PeerStub::nodePublicKey_
PublicKey const nodePublicKey_
Definition
PeerStub.h:181
xrpl::test::PeerStub::publisherListSequence
std::optional< std::size_t > publisherListSequence(PublicKey const &) const override
Definition
PeerStub.h:117
xrpl::test::PeerStub::compressionEnabled
bool compressionEnabled() const override
Definition
PeerStub.h:168
xrpl::test::PeerStub::cluster
bool cluster() const override
Definition
PeerStub.h:81
xrpl::test::PeerStub::setPublisherListSequence
void setPublisherListSequence(PublicKey const &, std::size_t const) override
Definition
PeerStub.h:123
xrpl::test::PeerStub::getClosedLedgerHash
UInt256 getClosedLedgerHash() const override
Definition
PeerStub.h:134
xrpl::test::PeerStub::charge
void charge(resource::Charge const &, std::string const &) override
Definition
PeerStub.h:70
xrpl::test::PeerStub::getNodePublic
PublicKey const & getNodePublic() const override
Definition
PeerStub.h:99
xrpl::test::PeerStub::txReduceRelayEnabled
bool txReduceRelayEnabled() const override
Definition
PeerStub.h:174
xrpl::test::PeerStub::supportsFeature
bool supportsFeature(ProtocolFeature) const override
Definition
PeerStub.h:111
xrpl::test::PeerStub::ledgerRange
void ledgerRange(std::uint32_t &, std::uint32_t &) const override
Definition
PeerStub.h:146
xrpl::test::PeerStub::sendTxQueue
void sendTxQueue() override
Definition
PeerStub.h:55
xrpl::test::PeerStub::fingerprint
std::string const & fingerprint() const override
Definition
PeerStub.h:128
xrpl::test::PeerStub::cycleStatus
void cycleStatus() override
Definition
PeerStub.h:157
xrpl::test::PeerStub::removeTxQueue
void removeTxQueue(UInt256 const &) override
Definition
PeerStub.h:65
xrpl::test::PeerStub::id
ID id() const override
Definition
PeerStub.h:75
xrpl::test::PeerStub::addTxQueue
void addTxQueue(UInt256 const &) override
Definition
PeerStub.h:60
xrpl::test::PeerStub::fingerprint_
std::string const fingerprint_
Definition
PeerStub.h:182
xrpl::test::PeerStub::send
void send(std::shared_ptr< Message > const &) override
Definition
PeerStub.h:44
xrpl::test::PeerStub::getScore
int getScore(bool) const override
Definition
PeerStub.h:93
xrpl::test::PeerStub::getRemoteAddress
beast::ip::Endpoint getRemoteAddress() const override
Definition
PeerStub.h:49
xrpl::test::PeerStub::id_
ID const id_
Definition
PeerStub.h:180
xrpl::test::PeerStub::hasTxSet
bool hasTxSet(UInt256 const &) const override
Definition
PeerStub.h:151
xrpl::test::PeerStub::hasRange
bool hasRange(std::uint32_t, std::uint32_t) override
Definition
PeerStub.h:162
xrpl::test::PeerStub::hasLedger
bool hasLedger(UInt256 const &, std::uint32_t) const override
Definition
PeerStub.h:140
xrpl::test::PeerStub::isHighLatency
bool isHighLatency() const override
Definition
PeerStub.h:87
xrpl::test::PeerStub::PeerStub
PeerStub(ID id=0)
Definition
PeerStub.h:36
xrpl::test::PeerStub::~PeerStub
~PeerStub() override=default
xrpl::test::PeerStub::json
json::Value json() override
Definition
PeerStub.h:105
cstddef
cstdint
std::uint32_t
memory
xrpl::test
Definition
STLedgerEntry.h:21
xrpl::KeyType
KeyType
Definition
KeyType.h:8
xrpl::KeyType::Ed25519
@ Ed25519
Definition
KeyType.h:10
xrpl::derivePublicKey
PublicKey derivePublicKey(KeyType type, SecretKey const &sk)
Derive the public key from a secret key.
Definition
SecretKey.cpp:306
xrpl::ProtocolFeature
ProtocolFeature
Definition
xrpld/overlay/Peer.h:22
xrpl::UInt256
BaseUInt< 256 > UInt256
Definition
base_uint.h:580
xrpl::randomSecretKey
SecretKey randomSecretKey()
Create a secret key using secure random numbers.
Definition
SecretKey.cpp:274
optional
std::shared_ptr
std::size_t
string
Generated by
1.17.0