Reformat codebase with 120 char limit (#583)

This commit is contained in:
Alex Kremer
2023-04-06 11:24:36 +01:00
committed by GitHub
parent e60fd3e58e
commit d816ef54ab
174 changed files with 5591 additions and 10450 deletions

View File

@@ -26,10 +26,8 @@
constexpr static auto ACCOUNT = "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn";
constexpr static auto ACCOUNT2 = "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun";
constexpr static auto LEDGERHASH =
"4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652";
constexpr static auto INDEX1 =
"1B8590C01B0006EDFA9ED60296DD052DC5E90F99659B25014D08E1BC983515BC";
constexpr static auto LEDGERHASH = "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652";
constexpr static auto INDEX1 = "1B8590C01B0006EDFA9ED60296DD052DC5E90F99659B25014D08E1BC983515BC";
using namespace RPCng;
namespace json = boost::json;
@@ -48,9 +46,8 @@ struct AccountOfferParamTestCaseBundle
};
// parameterized test cases for parameters check
struct AccountOfferParameterTest
: public RPCAccountOffersHandlerTest,
public WithParamInterface<AccountOfferParamTestCaseBundle>
struct AccountOfferParameterTest : public RPCAccountOffersHandlerTest,
public WithParamInterface<AccountOfferParamTestCaseBundle>
{
struct NameGenerator
{
@@ -58,8 +55,7 @@ struct AccountOfferParameterTest
std::string
operator()(const testing::TestParamInfo<ParamType>& info) const
{
auto bundle =
static_cast<AccountOfferParamTestCaseBundle>(info.param);
auto bundle = static_cast<AccountOfferParamTestCaseBundle>(info.param);
return bundle.testName;
}
};
@@ -154,9 +150,7 @@ TEST_P(AccountOfferParameterTest, InvalidParams)
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), testBundle.expectedError);
EXPECT_EQ(
err.at("error_message").as_string(),
testBundle.expectedErrorMessage);
EXPECT_EQ(err.at("error_message").as_string(), testBundle.expectedErrorMessage);
});
}
@@ -195,8 +189,7 @@ TEST_F(RPCAccountOffersHandlerTest, LedgerNotFoundViaStringIndex)
mockBackendPtr->updateRange(30); // max
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
// return empty ledgerinfo
ON_CALL(*rawBackendPtr, fetchLedgerBySequence(seq, _))
.WillByDefault(Return(std::optional<ripple::LedgerInfo>{}));
ON_CALL(*rawBackendPtr, fetchLedgerBySequence(seq, _)).WillByDefault(Return(std::optional<ripple::LedgerInfo>{}));
auto const static input = boost::json::parse(fmt::format(
R"({{
@@ -223,8 +216,7 @@ TEST_F(RPCAccountOffersHandlerTest, LedgerNotFoundViaIntIndex)
mockBackendPtr->updateRange(30); // max
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
// return empty ledgerinfo
ON_CALL(*rawBackendPtr, fetchLedgerBySequence(seq, _))
.WillByDefault(Return(std::optional<ripple::LedgerInfo>{}));
ON_CALL(*rawBackendPtr, fetchLedgerBySequence(seq, _)).WillByDefault(Return(std::optional<ripple::LedgerInfo>{}));
auto const static input = boost::json::parse(fmt::format(
R"({{
@@ -251,10 +243,8 @@ TEST_F(RPCAccountOffersHandlerTest, AccountNotFound)
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, 30);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
ON_CALL(*rawBackendPtr, fetchLedgerBySequence)
.WillByDefault(Return(ledgerinfo));
ON_CALL(*rawBackendPtr, doFetchLedgerObject)
.WillByDefault(Return(std::optional<Blob>{}));
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerinfo));
ON_CALL(*rawBackendPtr, doFetchLedgerObject).WillByDefault(Return(std::optional<Blob>{}));
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(1);
auto const static input = boost::json::parse(fmt::format(
@@ -307,17 +297,13 @@ TEST_F(RPCAccountOffersHandlerTest, DefaultParams)
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, ledgerSeq);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
ON_CALL(*rawBackendPtr, fetchLedgerBySequence)
.WillByDefault(Return(ledgerinfo));
auto const accountKk =
ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerinfo));
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, ledgerSeq, _))
.WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));
auto const ownerDir =
CreateOwnerDirLedgerObject({ripple::uint256{INDEX1}}, INDEX1);
auto const ownerDirKk =
ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
auto const ownerDir = CreateOwnerDirLedgerObject({ripple::uint256{INDEX1}}, INDEX1);
auto const ownerDirKk = ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(ownerDirKk, ledgerSeq, _))
.WillByDefault(Return(ownerDir.getSerializer().peekData()));
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(2);
@@ -360,17 +346,13 @@ TEST_F(RPCAccountOffersHandlerTest, Limit)
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, ledgerSeq);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
ON_CALL(*rawBackendPtr, fetchLedgerBySequence)
.WillByDefault(Return(ledgerinfo));
auto const accountKk =
ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerinfo));
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, ledgerSeq, _))
.WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));
auto const ownerDir = CreateOwnerDirLedgerObject(
std::vector{20, ripple::uint256{INDEX1}}, INDEX1);
auto const ownerDirKk =
ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
auto const ownerDir = CreateOwnerDirLedgerObject(std::vector{20, ripple::uint256{INDEX1}}, INDEX1);
auto const ownerDirKk = ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(ownerDirKk, ledgerSeq, _))
.WillByDefault(Return(ownerDir.getSerializer().peekData()));
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(2);
@@ -403,8 +385,7 @@ TEST_F(RPCAccountOffersHandlerTest, Limit)
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(output->at("offers").as_array().size(), 10);
EXPECT_EQ(
output->at("marker").as_string(), fmt::format("{},0", INDEX1));
EXPECT_EQ(output->at("marker").as_string(), fmt::format("{},0", INDEX1));
});
}
@@ -417,18 +398,14 @@ TEST_F(RPCAccountOffersHandlerTest, Marker)
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, ledgerSeq);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
ON_CALL(*rawBackendPtr, fetchLedgerBySequence)
.WillByDefault(Return(ledgerinfo));
auto const accountKk =
ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerinfo));
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, ledgerSeq, _))
.WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));
auto const startPage = 2;
auto const ownerDir = CreateOwnerDirLedgerObject(
std::vector{20, ripple::uint256{INDEX1}}, INDEX1);
auto const ownerDirKk =
ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
auto const ownerDir = CreateOwnerDirLedgerObject(std::vector{20, ripple::uint256{INDEX1}}, INDEX1);
auto const ownerDirKk = ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
auto const hintIndex = ripple::keylet::page(ownerDirKk, startPage).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(hintIndex, ledgerSeq, _))
@@ -478,20 +455,16 @@ TEST_F(RPCAccountOffersHandlerTest, MarkerNotExists)
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, ledgerSeq);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
ON_CALL(*rawBackendPtr, fetchLedgerBySequence)
.WillByDefault(Return(ledgerinfo));
auto const accountKk =
ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerinfo));
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, ledgerSeq, _))
.WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));
auto const startPage = 2;
auto const ownerDirKk =
ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
auto const ownerDirKk = ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
auto const hintIndex = ripple::keylet::page(ownerDirKk, startPage).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(hintIndex, ledgerSeq, _))
.WillByDefault(Return(std::nullopt));
ON_CALL(*rawBackendPtr, doFetchLedgerObject(hintIndex, ledgerSeq, _)).WillByDefault(Return(std::nullopt));
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(2);
auto const static input = boost::json::parse(fmt::format(