Move to clang-format-16 (#908)

Fixes #848
This commit is contained in:
Alex Kremer
2023-10-19 16:55:04 +01:00
committed by GitHub
parent 5de87b9ef8
commit 1aab2b94b1
265 changed files with 3950 additions and 4743 deletions

View File

@@ -21,8 +21,7 @@
#include <functional>
struct FakeAmendmentBlockAction
{
struct FakeAmendmentBlockAction {
std::reference_wrapper<std::size_t> callCount;
void

View File

@@ -23,8 +23,7 @@
#include <string>
#include <vector>
class FakeBook
{
class FakeBook {
std::string base_;
std::string first_;
@@ -48,8 +47,7 @@ public:
}
};
class FakeBookSuccessors
{
class FakeBookSuccessors {
std::vector<FakeBook> books_;
public:
@@ -66,8 +64,7 @@ public:
}
};
class FakeLedgerObject
{
class FakeLedgerObject {
public:
enum ModType : int { MODIFIED, DELETED };
@@ -122,8 +119,7 @@ public:
}
};
class FakeLedgerObjects
{
class FakeLedgerObjects {
std::vector<FakeLedgerObject> objects;
public:
@@ -134,8 +130,7 @@ public:
}
};
class FakeTransactionsList
{
class FakeTransactionsList {
std::size_t size_ = 0;
public:
@@ -146,8 +141,7 @@ public:
}
};
class FakeObjectsList
{
class FakeObjectsList {
std::size_t size_ = 0;
public:
@@ -158,8 +152,7 @@ public:
}
};
struct FakeFetchResponse
{
struct FakeFetchResponse {
uint32_t id;
bool objectNeighborsIncluded;
FakeLedgerObjects ledgerObjects;

View File

@@ -36,14 +36,12 @@
/**
* @brief Fixture with util::Logger support.
*/
class LoggerFixture : virtual public ::testing::Test
{
class LoggerFixture : virtual public ::testing::Test {
/**
* @brief A simple string buffer that can be used to mock std::cout for
* console logging.
*/
class FakeBuffer final : public std::stringbuf
{
class FakeBuffer final : public std::stringbuf {
public:
std::string
getStrAndReset()
@@ -100,8 +98,7 @@ protected:
*
* This is meant to be used as a base for other fixtures.
*/
class NoLoggerFixture : virtual public LoggerFixture
{
class NoLoggerFixture : virtual public LoggerFixture {
protected:
void
SetUp() override
@@ -116,8 +113,7 @@ protected:
*
* This is meant to be used as a base for other fixtures.
*/
struct AsyncAsioContextTest : virtual public NoLoggerFixture
{
struct AsyncAsioContextTest : virtual public NoLoggerFixture {
AsyncAsioContextTest()
{
work.emplace(ctx); // make sure ctx does not stop on its own
@@ -156,8 +152,7 @@ private:
* Use `run_for(duration)` etc. directly on `ctx`.
* This is meant to be used as a base for other fixtures.
*/
struct SyncAsioContextTest : virtual public NoLoggerFixture
{
struct SyncAsioContextTest : virtual public NoLoggerFixture {
template <typename F>
void
runSpawn(F&& f)
@@ -182,8 +177,7 @@ protected:
/**
* @brief Fixture with a mock backend
*/
struct MockBackendTest : virtual public NoLoggerFixture
{
struct MockBackendTest : virtual public NoLoggerFixture {
void
SetUp() override
{
@@ -204,8 +198,7 @@ protected:
/**
* @brief Fixture with a mock subscription manager
*/
struct MockSubscriptionManagerTest : virtual public NoLoggerFixture
{
struct MockSubscriptionManagerTest : virtual public NoLoggerFixture {
void
SetUp() override
{
@@ -225,8 +218,7 @@ protected:
/**
* @brief Fixture with a mock etl balancer
*/
struct MockLoadBalancerTest : virtual public NoLoggerFixture
{
struct MockLoadBalancerTest : virtual public NoLoggerFixture {
void
SetUp() override
{
@@ -246,8 +238,7 @@ protected:
/**
* @brief Fixture with a mock subscription manager
*/
struct MockETLServiceTest : virtual public NoLoggerFixture
{
struct MockETLServiceTest : virtual public NoLoggerFixture {
void
SetUp() override
{
@@ -267,8 +258,7 @@ protected:
/**
* @brief Fixture with mock counters
*/
struct MockCountersTest : virtual public NoLoggerFixture
{
struct MockCountersTest : virtual public NoLoggerFixture {
void
SetUp() override
{
@@ -289,8 +279,7 @@ protected:
* @brief Fixture with an mock backend and an embedded boost::asio context
* Handler unittest base class
*/
struct HandlerBaseTest : public MockBackendTest, public SyncAsioContextTest, public MockETLServiceTest
{
struct HandlerBaseTest : public MockBackendTest, public SyncAsioContextTest, public MockETLServiceTest {
protected:
void
SetUp() override

View File

@@ -21,7 +21,6 @@
#include <gmock/gmock.h>
struct MockAmendmentBlockHandler
{
struct MockAmendmentBlockHandler {
MOCK_METHOD(void, onAmendmentBlock, (), ());
};

View File

@@ -24,8 +24,7 @@
using namespace data;
struct MockBackend : public BackendInterface
{
struct MockBackend : public BackendInterface {
MockBackend(util::Config)
{
}
@@ -34,31 +33,36 @@ struct MockBackend : public BackendInterface
std::optional<ripple::LedgerInfo>,
fetchLedgerBySequence,
(std::uint32_t const, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::optional<ripple::LedgerInfo>,
fetchLedgerByHash,
(ripple::uint256 const&, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::optional<std::uint32_t>,
fetchLatestLedgerSequence,
(boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::optional<TransactionAndMetadata>,
fetchTransaction,
(ripple::uint256 const&, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::vector<TransactionAndMetadata>,
fetchTransactions,
(std::vector<ripple::uint256> const&, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
TransactionsAndCursor,
@@ -68,25 +72,29 @@ struct MockBackend : public BackendInterface
bool,
std::optional<TransactionsCursor> const&,
boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::vector<TransactionAndMetadata>,
fetchAllTransactionsInLedger,
(std::uint32_t const, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::vector<ripple::uint256>,
fetchAllTransactionHashesInLedger,
(std::uint32_t const, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::optional<NFT>,
fetchNFT,
(ripple::uint256 const&, std::uint32_t const, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
TransactionsAndCursor,
@@ -96,31 +104,36 @@ struct MockBackend : public BackendInterface
bool const,
std::optional<TransactionsCursor> const&,
boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::vector<Blob>,
doFetchLedgerObjects,
(std::vector<ripple::uint256> const&, std::uint32_t const, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::optional<Blob>,
doFetchLedgerObject,
(ripple::uint256 const&, std::uint32_t const, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::vector<LedgerObject>,
fetchLedgerDiff,
(std::uint32_t const, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::optional<ripple::uint256>,
doFetchSuccessorKey,
(ripple::uint256, std::uint32_t const, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(std::optional<LedgerRange>, hardFetchLedgerRange, (boost::asio::yield_context), (const, override));
@@ -132,13 +145,14 @@ struct MockBackend : public BackendInterface
void,
writeTransaction,
(std::string&&, std::uint32_t const, std::uint32_t const, std::string&&, std::string&&),
(override));
(override)
);
MOCK_METHOD(void, writeNFTs, (std::vector<NFTsData> &&), (override));
MOCK_METHOD(void, writeNFTs, (std::vector<NFTsData>&&), (override));
MOCK_METHOD(void, writeAccountTransactions, (std::vector<AccountTransactionsData> &&), (override));
MOCK_METHOD(void, writeAccountTransactions, (std::vector<AccountTransactionsData>&&), (override));
MOCK_METHOD(void, writeNFTTransactions, (std::vector<NFTTransactionsData> &&), (override));
MOCK_METHOD(void, writeNFTTransactions, (std::vector<NFTTransactionsData>&&), (override));
MOCK_METHOD(void, writeSuccessor, (std::string && key, std::uint32_t const, std::string&&), (override));

View File

@@ -23,8 +23,7 @@
#include <gmock/gmock.h>
struct MockCache
{
struct MockCache {
virtual ~MockCache() = default;
MOCK_METHOD(void, updateImp, (std::vector<data::LedgerObject> const& a, uint32_t b, bool c), ());

View File

@@ -24,8 +24,7 @@
#include <chrono>
struct MockCounters
{
struct MockCounters {
MOCK_METHOD(void, rpcFailed, (std::string const&), ());
MOCK_METHOD(void, rpcErrored, (std::string const&), ());
MOCK_METHOD(void, rpcComplete, (std::string const&, std::chrono::microseconds const&), ());

View File

@@ -26,8 +26,7 @@
#include <chrono>
struct MockETLService
{
struct MockETLService {
MOCK_METHOD(boost::json::object, getInfo, (), (const));
MOCK_METHOD(std::chrono::time_point<std::chrono::system_clock>, getLastPublish, (), (const));
MOCK_METHOD(std::uint32_t, lastPublishAgeSeconds, (), (const));

View File

@@ -23,8 +23,7 @@
#include <chrono>
struct MockExtractionDataPipe
{
struct MockExtractionDataPipe {
MOCK_METHOD(void, push, (uint32_t, std::optional<FakeFetchResponse>&&), ());
MOCK_METHOD(std::optional<FakeFetchResponse>, popNext, (uint32_t), ());
MOCK_METHOD(uint32_t, getStride, (), (const));

View File

@@ -24,8 +24,7 @@
#include <gmock/gmock.h>
struct MockHandlerProvider : public rpc::HandlerProvider
{
struct MockHandlerProvider : public rpc::HandlerProvider {
public:
MOCK_METHOD(bool, contains, (std::string const&), (const, override));
MOCK_METHOD(std::optional<rpc::AnyHandler>, getHandler, (std::string const&), (const, override));

View File

@@ -25,8 +25,7 @@
#include <optional>
struct MockLedgerFetcher
{
struct MockLedgerFetcher {
MOCK_METHOD(std::optional<FakeFetchResponse>, fetchData, (uint32_t), ());
MOCK_METHOD(std::optional<FakeFetchResponse>, fetchDataAndDiff, (uint32_t), ());
};

View File

@@ -25,8 +25,7 @@
#include <optional>
struct MockLedgerLoader
{
struct MockLedgerLoader {
using GetLedgerResponseType = FakeFetchResponse;
using RawLedgerObjectType = FakeLedgerObject;
@@ -34,6 +33,7 @@ struct MockLedgerLoader
FormattedTransactionsData,
insertTransactions,
(ripple::LedgerInfo const&, GetLedgerResponseType& data),
());
()
);
MOCK_METHOD(std::optional<ripple::LedgerInfo>, loadInitialLedger, (uint32_t sequence), ());
};

View File

@@ -23,8 +23,7 @@
#include <optional>
struct MockLedgerPublisher
{
struct MockLedgerPublisher {
MOCK_METHOD(bool, publish, (uint32_t, std::optional<uint32_t>), ());
MOCK_METHOD(void, publish, (ripple::LedgerInfo const&), ());
MOCK_METHOD(std::uint32_t, lastPublishAgeSeconds, (), (const));

View File

@@ -28,8 +28,7 @@
#include <optional>
struct MockLoadBalancer
{
struct MockLoadBalancer {
using RawLedgerObjectType = FakeLedgerObject;
MOCK_METHOD(void, loadInitialLedger, (std::uint32_t, bool), ());
@@ -40,5 +39,6 @@ struct MockLoadBalancer
std::optional<boost::json::object>,
forwardToRippled,
(boost::json::object const&, std::optional<std::string> const&, boost::asio::yield_context),
(const));
(const)
);
};

View File

@@ -23,8 +23,7 @@
#include <optional>
struct MockNetworkValidatedLedgers
{
struct MockNetworkValidatedLedgers {
MOCK_METHOD(void, push, (uint32_t), ());
MOCK_METHOD(std::optional<uint32_t>, getMostRecent, (), ());
MOCK_METHOD(bool, waitUntilValidatedByNetwork, (uint32_t), ());

View File

@@ -26,8 +26,7 @@
#include <string>
struct MockAsyncRPCEngine
{
struct MockAsyncRPCEngine {
template <typename Fn>
bool
post(Fn&& func, [[maybe_unused]] std::string const& ip = "")
@@ -57,8 +56,7 @@ struct MockAsyncRPCEngine
MOCK_METHOD(rpc::Result, buildResponse, (web::Context const&), ());
};
struct MockRPCEngine
{
struct MockRPCEngine {
MOCK_METHOD(bool, post, (std::function<void(boost::asio::yield_context)>&&, std::string const&), ());
MOCK_METHOD(void, notifyComplete, (std::string const&, std::chrono::microseconds const&), ());
MOCK_METHOD(void, notifyErrored, (std::string const&), ());

View File

@@ -22,8 +22,7 @@
#include <gmock/gmock.h>
class MockSource : public etl::Source
{
class MockSource : public etl::Source {
public:
MOCK_METHOD(bool, isConnected, (), (const, override));
MOCK_METHOD(boost::json::object, toJson, (), (const override));
@@ -36,17 +35,20 @@ public:
(std::pair<grpc::Status, org::xrpl::rpc::v1::GetLedgerResponse>),
fetchLedger,
(uint32_t, bool, bool),
(override));
(override)
);
MOCK_METHOD((std::pair<std::vector<std::string>, bool>), loadInitialLedger, (uint32_t, uint32_t, bool), (override));
MOCK_METHOD(
std::optional<boost::json::object>,
forwardToRippled,
(boost::json::object const&, std::optional<std::string> const&, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(
std::optional<boost::json::object>,
requestFromRippled,
(boost::json::object const&, std::optional<std::string> const&, boost::asio::yield_context),
(const, override));
(const, override)
);
MOCK_METHOD(boost::uuids::uuid, token, (), (const, override));
};

View File

@@ -25,8 +25,7 @@
#include <boost/json.hpp>
#include <gmock/gmock.h>
struct MockSubscriptionManager
{
struct MockSubscriptionManager {
public:
using session_ptr = std::shared_ptr<web::ConnectionBase>;
MockSubscriptionManager()
@@ -39,13 +38,15 @@ public:
void,
pubLedger,
(ripple::LedgerInfo const&, ripple::Fees const&, std::string const&, std::uint32_t),
());
()
);
MOCK_METHOD(
void,
pubBookChanges,
(ripple::LedgerInfo const&, std::vector<data::TransactionAndMetadata> const&),
());
()
);
MOCK_METHOD(void, unsubLedger, (session_ptr), ());

View File

@@ -21,8 +21,7 @@
#include <web/interface/ConnectionBase.h>
struct MockSession : public web::ConnectionBase
{
struct MockSession : public web::ConnectionBase {
std::string message;
void
send(std::shared_ptr<std::string> msg_type) override
@@ -41,9 +40,9 @@ struct MockSession : public web::ConnectionBase
}
};
struct MockDeadSession : public web::ConnectionBase
{
void send(std::shared_ptr<std::string>) override
struct MockDeadSession : public web::ConnectionBase {
void
send(std::shared_ptr<std::string>) override
{
// err happen, the session should remove from subscribers
ec_.assign(2, boost::system::system_category());

View File

@@ -31,8 +31,7 @@ namespace net = boost::asio;
namespace ssl = boost::asio::ssl;
using tcp = boost::asio::ip::tcp;
struct WebHeader
{
struct WebHeader {
WebHeader(http::field name, std::string value) : name(name), value(std::move(value))
{
}
@@ -40,14 +39,14 @@ struct WebHeader
std::string value;
};
struct HttpSyncClient
{
struct HttpSyncClient {
static std::string
syncPost(
std::string const& host,
std::string const& port,
std::string const& body,
std::vector<WebHeader> additionalHeaders = {})
std::vector<WebHeader> additionalHeaders = {}
)
{
boost::asio::io_context ioc;
@@ -61,8 +60,7 @@ struct HttpSyncClient
req.set(http::field::host, host);
req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
for (auto& header : additionalHeaders)
{
for (auto& header : additionalHeaders) {
req.set(header.name, std::move(header.value));
}
@@ -81,8 +79,7 @@ struct HttpSyncClient
}
};
class WebSocketSyncClient
{
class WebSocketSyncClient {
net::io_context ioc_;
tcp::resolver resolver_{ioc_};
boost::beast::websocket::stream<tcp::socket> ws_{ioc_};
@@ -99,14 +96,13 @@ public:
// See https://tools.ietf.org/html/rfc7230#section-5.4
auto const hostPort = host + ':' + std::to_string(ep.port());
ws_.set_option(boost::beast::websocket::stream_base::decorator(
[additionalHeaders = std::move(additionalHeaders)](boost::beast::websocket::request_type& req) {
req.set(http::field::user_agent, std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro");
for (auto& header : additionalHeaders)
{
req.set(header.name, std::move(header.value));
}
}));
ws_.set_option(boost::beast::websocket::stream_base::decorator([additionalHeaders = std::move(additionalHeaders
)](boost::beast::websocket::request_type& req) {
req.set(http::field::user_agent, std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro");
for (auto& header : additionalHeaders) {
req.set(header.name, std::move(header.value));
}
}));
ws_.handshake(hostPort, "/");
}
@@ -129,8 +125,7 @@ public:
}
};
struct HttpsSyncClient
{
struct HttpsSyncClient {
static bool
verify_certificate(bool /* preverified */, boost::asio::ssl::verify_context& /* ctx */)
{
@@ -180,8 +175,7 @@ struct HttpsSyncClient
}
};
class WebServerSslSyncClient
{
class WebServerSslSyncClient {
net::io_context ioc_;
std::optional<boost::beast::websocket::stream<boost::beast::ssl_stream<tcp::socket>>> ws_;

View File

@@ -43,8 +43,7 @@ CreateLedgerInfo(std::string_view ledgerHash, ripple::LedgerIndex seq, std::opti
ledgerinfo.hash = ripple::uint256{ledgerHash};
ledgerinfo.seq = seq;
if (age)
{
if (age) {
auto const now = duration_cast<seconds>(system_clock::now().time_since_epoch());
auto const closeTime = (now - seconds{age.value()}).count() - rippleEpochStart;
ledgerinfo.closeTime = ripple::NetClock::time_point{seconds{closeTime}};
@@ -59,7 +58,8 @@ CreateFeeSettingLedgerObject(
uint32_t reserveInc,
uint32_t reserveBase,
uint32_t refFeeUnit,
uint32_t flag)
uint32_t flag
)
{
ripple::STObject obj(ripple::sfFee);
obj.setFieldU16(ripple::sfLedgerEntryType, ripple::ltFEE_SETTINGS);
@@ -84,7 +84,8 @@ CreatePaymentTransactionObject(
std::string_view accountId2,
int amount,
int fee,
uint32_t seq)
uint32_t seq
)
{
ripple::STObject obj(ripple::sfTransaction);
obj.setFieldU16(ripple::sfTransactionType, ripple::ttPAYMENT);
@@ -95,7 +96,7 @@ CreatePaymentTransactionObject(
auto account2 = ripple::parseBase58<ripple::AccountID>(std::string(accountId2));
obj.setAccountID(ripple::sfDestination, account2.value());
obj.setFieldU32(ripple::sfSequence, seq);
const char* key = "test";
char const* key = "test";
ripple::Slice const slice(key, 4);
obj.setFieldVL(ripple::sfSigningPubKey, slice);
return obj;
@@ -107,7 +108,8 @@ CreatePaymentTransactionMetaObject(
std::string_view accountId2,
int finalBalance1,
int finalBalance2,
uint32_t transactionIndex)
uint32_t transactionIndex
)
{
ripple::STObject finalFields(ripple::sfFinalFields);
finalFields.setAccountID(ripple::sfAccount, GetAccountIDWithString(accountId1));
@@ -142,7 +144,8 @@ CreateAccountRootObject(
uint32_t ownerCount,
std::string_view previousTxnID,
uint32_t previousTxnSeq,
uint32_t transferRate)
uint32_t transferRate
)
{
ripple::STObject accountRoot(ripple::sfAccount);
accountRoot.setFieldU16(ripple::sfLedgerEntryType, ripple::ltACCOUNT_ROOT);
@@ -166,7 +169,8 @@ CreateCreateOfferTransactionObject(
std::string_view issuer,
int takerGets,
int takerPays,
bool reverse)
bool reverse
)
{
ripple::STObject obj(ripple::sfTransaction);
obj.setFieldU16(ripple::sfTransactionType, ripple::ttOFFER_CREATE);
@@ -177,14 +181,12 @@ CreateCreateOfferTransactionObject(
obj.setFieldU32(ripple::sfSequence, seq);
// add amount
ripple::Issue const issue1(
ripple::Currency{currency}, ripple::parseBase58<ripple::AccountID>(std::string(issuer)).value());
if (reverse)
{
ripple::Currency{currency}, ripple::parseBase58<ripple::AccountID>(std::string(issuer)).value()
);
if (reverse) {
obj.setFieldAmount(ripple::sfTakerPays, ripple::STAmount(issue1, takerGets));
obj.setFieldAmount(ripple::sfTakerGets, ripple::STAmount(takerPays, false));
}
else
{
} else {
obj.setFieldAmount(ripple::sfTakerGets, ripple::STAmount(issue1, takerGets));
obj.setFieldAmount(ripple::sfTakerPays, ripple::STAmount(takerPays, false));
}
@@ -199,14 +201,15 @@ ripple::Issue
GetIssue(std::string_view currency, std::string_view issuerId)
{
// standard currency
if (currency.size() == 3)
{
if (currency.size() == 3) {
return ripple::Issue(
ripple::to_currency(std::string(currency)),
ripple::parseBase58<ripple::AccountID>(std::string(issuerId)).value());
ripple::parseBase58<ripple::AccountID>(std::string(issuerId)).value()
);
}
return ripple::Issue(
ripple::Currency{currency}, ripple::parseBase58<ripple::AccountID>(std::string(issuerId)).value());
ripple::Currency{currency}, ripple::parseBase58<ripple::AccountID>(std::string(issuerId)).value()
);
}
ripple::STObject
@@ -217,7 +220,8 @@ CreateMetaDataForBookChange(
int finalTakerGets,
int perviousTakerGets,
int finalTakerPays,
int perviousTakerPays)
int perviousTakerPays
)
{
ripple::STObject finalFields(ripple::sfFinalFields);
ripple::Issue const issue1 = GetIssue(currency, issueId);
@@ -246,17 +250,15 @@ CreateMetaDataForCreateOffer(
uint32_t transactionIndex,
int finalTakerGets,
int finalTakerPays,
bool reverse)
bool reverse
)
{
ripple::STObject finalFields(ripple::sfNewFields);
ripple::Issue const issue1 = GetIssue(currency, issueId);
if (reverse)
{
if (reverse) {
finalFields.setFieldAmount(ripple::sfTakerGets, ripple::STAmount(issue1, finalTakerPays));
finalFields.setFieldAmount(ripple::sfTakerPays, ripple::STAmount(finalTakerGets, false));
}
else
{
} else {
finalFields.setFieldAmount(ripple::sfTakerPays, ripple::STAmount(issue1, finalTakerPays));
finalFields.setFieldAmount(ripple::sfTakerGets, ripple::STAmount(finalTakerGets, false));
}
@@ -278,7 +280,8 @@ CreateMetaDataForCancelOffer(
std::string_view issueId,
uint32_t transactionIndex,
int finalTakerGets,
int finalTakerPays)
int finalTakerPays
)
{
ripple::STObject finalFields(ripple::sfFinalFields);
ripple::Issue const issue1 = GetIssue(currency, issueId);
@@ -315,7 +318,8 @@ CreatePaymentChannelLedgerObject(
int balance,
uint32_t settleDelay,
std::string_view previousTxnId,
uint32_t previousTxnSeq)
uint32_t previousTxnSeq
)
{
ripple::STObject channel(ripple::sfLedgerEntry);
channel.setFieldU16(ripple::sfLedgerEntryType, ripple::ltPAYCHAN);
@@ -346,7 +350,8 @@ CreateRippleStateLedgerObject(
int highLimit,
std::string_view previousTxnId,
uint32_t previousTxnSeq,
uint32_t flag)
uint32_t flag
)
{
auto line = ripple::STObject(ripple::sfLedgerEntry);
line.setFieldU16(ripple::sfLedgerEntryType, ripple::ltRIPPLE_STATE);
@@ -368,7 +373,8 @@ CreateOfferLedgerObject(
std::string_view paysCurrency,
std::string_view getsIssueId,
std::string_view paysIssueId,
std::string_view dirId)
std::string_view dirId
)
{
ripple::STObject offer(ripple::sfLedgerEntry);
offer.setFieldU16(ripple::sfLedgerEntryType, ripple::ltOFFER);
@@ -498,8 +504,7 @@ CreateSignerLists(std::vector<std::pair<std::string, uint32_t>> const& signers)
signerlists.setFieldU32(ripple::sfSignerListID, 0);
uint32_t quorum = 0;
ripple::STArray list;
for (auto const& signer : signers)
{
for (auto const& signer : signers) {
auto entry = ripple::STObject(ripple::sfSignerEntry);
entry.setAccountID(ripple::sfAccount, GetAccountIDWithString(signer.first));
entry.setFieldU16(ripple::sfSignerWeight, signer.second);
@@ -514,7 +519,8 @@ CreateSignerLists(std::vector<std::pair<std::string, uint32_t>> const& signers)
ripple::STObject
CreateNFTTokenPage(
std::vector<std::pair<std::string, std::string>> const& tokens,
std::optional<ripple::uint256> previousPage)
std::optional<ripple::uint256> previousPage
)
{
auto tokenPage = ripple::STObject(ripple::sfLedgerEntry);
tokenPage.setFieldU16(ripple::sfLedgerEntryType, ripple::ltNFTOKEN_PAGE);
@@ -524,8 +530,7 @@ CreateNFTTokenPage(
if (previousPage)
tokenPage.setFieldH256(ripple::sfPreviousPageMin, *previousPage);
ripple::STArray list;
for (auto const& token : tokens)
{
for (auto const& token : tokens) {
auto entry = ripple::STObject(ripple::sfNFToken);
entry.setFieldH256(ripple::sfNFTokenID, ripple::uint256{token.first.c_str()});
entry.setFieldVL(ripple::sfURI, ripple::Slice(token.second.c_str(), token.second.size()));
@@ -541,7 +546,8 @@ CreateMintNFTTxWithMetadata(
uint32_t seq,
uint32_t fee,
uint32_t nfTokenTaxon,
std::string_view nftID)
std::string_view nftID
)
{
// tx
ripple::STObject tx(ripple::sfTransaction);
@@ -553,7 +559,7 @@ CreateMintNFTTxWithMetadata(
// required field for ttNFTOKEN_MINT
tx.setFieldU32(ripple::sfNFTokenTaxon, nfTokenTaxon);
tx.setFieldU32(ripple::sfSequence, seq);
const char* key = "test";
char const* key = "test";
ripple::Slice const slice(key, 4);
tx.setFieldVL(ripple::sfSigningPubKey, slice);
@@ -569,7 +575,7 @@ CreateMintNFTTxWithMetadata(
// finalFields contain new NFT while previousFields does not
auto entry = ripple::STObject(ripple::sfNFToken);
entry.setFieldH256(ripple::sfNFTokenID, ripple::uint256{nftID});
const char* url = "testurl";
char const* url = "testurl";
entry.setFieldVL(ripple::sfURI, ripple::Slice(url, 7));
NFTArray1.push_back(entry);
@@ -609,7 +615,7 @@ CreateAcceptNFTOfferTxWithMetadata(std::string_view accountId, uint32_t seq, uin
tx.setFieldAmount(ripple::sfFee, amount);
tx.setFieldU32(ripple::sfSequence, seq);
tx.setFieldH256(ripple::sfNFTokenBuyOffer, ripple::uint256{INDEX1});
const char* key = "test";
char const* key = "test";
ripple::Slice const slice(key, 4);
tx.setFieldVL(ripple::sfSigningPubKey, slice);
@@ -641,7 +647,8 @@ CreateCancelNFTOffersTxWithMetadata(
std::string_view accountId,
uint32_t seq,
uint32_t fee,
std::vector<std::string> const& nftOffers)
std::vector<std::string> const& nftOffers
)
{
// tx
ripple::STObject tx(ripple::sfTransaction);
@@ -657,7 +664,7 @@ CreateCancelNFTOffersTxWithMetadata(
return ripple::uint256{nftId.c_str()};
});
tx.setFieldV256(ripple::sfNFTokenOffers, offers);
const char* key = "test";
char const* key = "test";
ripple::Slice const slice(key, 4);
tx.setFieldVL(ripple::sfSigningPubKey, slice);
@@ -666,8 +673,7 @@ CreateCancelNFTOffersTxWithMetadata(
// reuse the offer id as nft id
ripple::STObject metaObj(ripple::sfTransactionMetaData);
ripple::STArray metaArray{nftOffers.size()};
for (auto const& nftId : nftOffers)
{
for (auto const& nftId : nftOffers) {
ripple::STObject node(ripple::sfDeletedNode);
node.setFieldU16(ripple::sfLedgerEntryType, ripple::ltNFTOKEN_OFFER);
@@ -695,7 +701,8 @@ CreateCreateNFTOfferTxWithMetadata(
uint32_t fee,
std::string_view nftId,
std::uint32_t offerPrice,
std::string_view offerId)
std::string_view offerId
)
{
// tx
ripple::STObject tx(ripple::sfTransaction);
@@ -708,7 +715,7 @@ CreateCreateNFTOfferTxWithMetadata(
tx.setFieldAmount(ripple::sfAmount, price);
tx.setFieldU32(ripple::sfSequence, seq);
tx.setFieldH256(ripple::sfNFTokenID, ripple::uint256{nftId});
const char* key = "test";
char const* key = "test";
ripple::Slice const slice(key, 4);
tx.setFieldVL(ripple::sfSigningPubKey, slice);

View File

@@ -51,7 +51,8 @@ CreateFeeSettingLedgerObject(
uint32_t reserveInc,
uint32_t reserveBase,
uint32_t refFeeUnit,
uint32_t flag);
uint32_t flag
);
/*
* Create a FeeSetting ledger object and return its blob
@@ -68,7 +69,8 @@ CreatePaymentTransactionObject(
std::string_view accountId2,
int amount,
int fee,
uint32_t seq);
uint32_t seq
);
[[nodiscard]] ripple::STObject
CreatePaymentTransactionMetaObject(
@@ -76,7 +78,8 @@ CreatePaymentTransactionMetaObject(
std::string_view accountId2,
int finalBalance1,
int finalBalance2,
uint32_t transactionIndex = 0);
uint32_t transactionIndex = 0
);
/*
* Create an account root ledger object
@@ -90,7 +93,8 @@ CreateAccountRootObject(
uint32_t ownerCount,
std::string_view previousTxnID,
uint32_t previousTxnSeq,
uint32_t transferRate = 0);
uint32_t transferRate = 0
);
/*
* Create a createoffer treansaction
@@ -106,7 +110,8 @@ CreateCreateOfferTransactionObject(
std::string_view issuer,
int takerGets,
int takerPays,
bool reverse = false);
bool reverse = false
);
/*
* Return an issue object with given currency and issue account
@@ -125,7 +130,8 @@ CreateMetaDataForBookChange(
int finalTakerGets,
int perviousTakerGets,
int finalTakerPays,
int perviousTakerPays);
int perviousTakerPays
);
/*
* Meta data for adding a offer object
@@ -139,7 +145,8 @@ CreateMetaDataForCreateOffer(
uint32_t transactionIndex,
int finalTakerGets,
int finalTakerPays,
bool reverse = false);
bool reverse = false
);
/*
* Meta data for removing a offer object
@@ -150,7 +157,8 @@ CreateMetaDataForCancelOffer(
std::string_view issueId,
uint32_t transactionIndex,
int finalTakerGets,
int finalTakerPays);
int finalTakerPays
);
/*
* Create a owner dir ledger object
@@ -169,7 +177,8 @@ CreatePaymentChannelLedgerObject(
int balance,
uint32_t settleDelay,
std::string_view previousTxnId,
uint32_t previousTxnSeq);
uint32_t previousTxnSeq
);
[[nodiscard]] ripple::STObject
CreateRippleStateLedgerObject(
@@ -182,7 +191,8 @@ CreateRippleStateLedgerObject(
int highLimit,
std::string_view previousTxnId,
uint32_t previousTxnSeq,
uint32_t flag = 0);
uint32_t flag = 0
);
[[nodiscard]] ripple::STObject
CreateOfferLedgerObject(
@@ -193,7 +203,8 @@ CreateOfferLedgerObject(
std::string_view paysCurrency,
std::string_view getsIssueId,
std::string_view paysIssueId,
std::string_view bookDirId);
std::string_view bookDirId
);
[[nodiscard]] ripple::STObject
CreateTicketLedgerObject(std::string_view account, uint32_t sequence);
@@ -213,7 +224,8 @@ CreateNFT(
std::string_view account,
ripple::LedgerIndex seq = 1234u,
ripple::Blob uri = ripple::Blob{'u', 'r', 'i'},
bool isBurned = false);
bool isBurned = false
);
[[nodiscard]] ripple::STObject
CreateNFTBuyOffer(std::string_view tokenID, std::string_view account);
@@ -227,7 +239,8 @@ CreateSignerLists(std::vector<std::pair<std::string, uint32_t>> const& signers);
[[nodiscard]] ripple::STObject
CreateNFTTokenPage(
std::vector<std::pair<std::string, std::string>> const& tokens,
std::optional<ripple::uint256> previousPage);
std::optional<ripple::uint256> previousPage
);
[[nodiscard]] data::TransactionAndMetadata
CreateMintNFTTxWithMetadata(
@@ -235,7 +248,8 @@ CreateMintNFTTxWithMetadata(
uint32_t seq,
uint32_t fee,
uint32_t nfTokenTaxon,
std::string_view nftID);
std::string_view nftID
);
[[nodiscard]] data::TransactionAndMetadata
CreateAcceptNFTOfferTxWithMetadata(std::string_view accountId, uint32_t seq, uint32_t fee, std::string_view nftId);
@@ -245,7 +259,8 @@ CreateCancelNFTOffersTxWithMetadata(
std::string_view accountId,
uint32_t seq,
uint32_t fee,
std::vector<std::string> const& nftOffers);
std::vector<std::string> const& nftOffers
);
[[nodiscard]] data::TransactionAndMetadata
CreateCreateNFTOfferTxWithMetadata(std::string_view accountId, uint32_t seq, uint32_t fee, std::string_view offerId);
@@ -257,7 +272,8 @@ CreateCreateNFTOfferTxWithMetadata(
uint32_t fee,
std::string_view nftId,
std::uint32_t offerPrice,
std::string_view offerId);
std::string_view offerId
);
[[nodiscard]] ripple::STObject
CreateAmendmentsObject(std::vector<ripple::uint256> const& enabledAmendments);

View File

@@ -23,8 +23,7 @@
#include <filesystem>
#include <fstream>
struct TmpFile
{
struct TmpFile {
std::string const path;
TmpFile(std::string_view content) : path{std::tmpnam(nullptr)}