1#include <test/jtx/Env.h>
2#include <test/overlay/CapturePeer.h>
4#include <xrpld/app/main/Application.h>
5#include <xrpld/overlay/Compression.h>
6#include <xrpld/overlay/detail/OverlayImpl.h>
7#include <xrpld/overlay/detail/Tuning.h>
9#include <xrpl/basics/Blob.h>
10#include <xrpl/basics/base_uint.h>
11#include <xrpl/beast/unit_test/suite.h>
12#include <xrpl/nodestore/NodeObject.h>
13#include <xrpl/protocol/digest.h>
60 for (
int i = 0; i < numObjects; ++i)
65 Blob data(100,
static_cast<unsigned char>(i % 256));
72 request->set_type(protocol::TMGetObjectByHash_ObjectType_otLEDGER);
73 request->set_query(
true);
75 for (
int i = 0; i < numObjects; ++i)
77 auto object = request->add_objects();
78 object->set_hash(hashes[i].data(), hashes[i].size());
79 object->set_ledgerseq(i);
100 peer->runProcessGetObjectByHash(request);
103 auto sentMessage = peer->lastSent();
104 BEAST_EXPECT(sentMessage !=
nullptr);
109 BEAST_EXPECT(buffer.size() > 6);
111 protocol::TMGetObjectByHash reply;
112 BEAST_EXPECT(reply.ParseFromArray(buffer.data() + 6, buffer.size() - 6) ==
true);
115 BEAST_EXPECT(reply.objects_size() == expectedReplySize);
TestcaseT testcase
Memberspace for declaring test cases.
void processGetObjectByHash(std::shared_ptr< protocol::TMGetObjectByHash > const &m)
Process a generic-query TMGetObjectByHash message.
virtual node_store::Database & getNodeStore()=0
CapturePeer(Application &app, Peer::ID id, std::shared_ptr< peer_finder::Slot > const &slot, HttpRequestType request, PublicKey const &publicKey, ProtocolVersion protocol, resource::Consumer consumer, std::unique_ptr< StreamType > streamPtr, OverlayImpl &overlay)
Takes PeerImp's two rvalue-reference parameters by value instead, so a derived double can inherit thi...
Calls the JtLedgerReq-dispatched processor synchronously, so the reply is visible through sent().
void runProcessGetObjectByHash(std::shared_ptr< protocol::TMGetObjectByHash > const &m)
CapturePeer(Application &app, Peer::ID id, std::shared_ptr< peer_finder::Slot > const &slot, HttpRequestType request, PublicKey const &publicKey, ProtocolVersion protocol, resource::Consumer consumer, std::unique_ptr< StreamType > streamPtr, OverlayImpl &overlay)
Takes PeerImp's two rvalue-reference parameters by value instead, so a derived double can inherit thi...
Coverage for the TMGetObjectByHash object-count bound.
static std::shared_ptr< protocol::TMGetObjectByHash > createRequest(size_t const numObjects, Env &env)
void testReplyObjectCount(size_t const numObjects, int const expectedReplySize)
Check the object count a generic-query reply carries.
void run() override
Runs the suite.
A transaction testing environment.
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
std::shared_ptr< PeerType > makeCapturePeer(jtx::Env &env, std::optional< PublicKey > key=std::nullopt, HttpRequestType request={})
Build an active CapturePeer and register it with the overlay.
static constexpr auto kHardMaxReplyNodes
The hard cap on the number of ledger entries in a single reply.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::vector< unsigned char > Blob
Storage for linear binary data.
Sha512HalfHasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.