style: Fix formatting via clang-format (#1809)

For #1760
This commit is contained in:
Peter Chen
2025-01-03 23:00:03 -05:00
committed by GitHub
parent 820b32c6d7
commit cce7aa2893
13 changed files with 351 additions and 304 deletions

View File

@@ -310,7 +310,8 @@ TEST_F(MigrationCassandraManagerLedgerTableTest, MigrateExampleLedgerMigrator)
EXPECT_EQ(newTableSize, gLedgerHeaderRawData.size());
auto const getAccountHash = [this](std::uint32_t seq) {
return data::synchronous([&](auto ctx) { return testMigrationBackend_->fetchAccountHashViaSequence(seq, ctx); });
return data::synchronous([&](auto ctx) { return testMigrationBackend_->fetchAccountHashViaSequence(seq, ctx); }
);
};
EXPECT_EQ(

View File

@@ -649,11 +649,13 @@ generateNormalPathBookOffersTestBundles()
.testName = "PaysUSDGetsXRPNoFrozenOwnerFundEnough",
.inputJson = getsXRPPaysUSDInputJson,
// prepare offer dir index
.mockedSuccessors=std::map<ripple::uint256, std::optional<ripple::uint256>>{
.mockedSuccessors =
std::map<ripple::uint256, std::optional<ripple::uint256>>{
{getsXRPPaysUSDBook, ripple::uint256{kPAYS20_USD_GETS10_XRP_BOOK_DIR}},
{ripple::uint256{kPAYS20_USD_GETS10_XRP_BOOK_DIR}, std::optional<ripple::uint256>{}}
},
.mockedLedgerObjects=std::map<ripple::uint256, ripple::Blob>{
.mockedLedgerObjects =
std::map<ripple::uint256, ripple::Blob>{
// book dir object
{ripple::uint256{kPAYS20_USD_GETS10_XRP_BOOK_DIR},
createOwnerDirLedgerObject({ripple::uint256{kINDEX2}}, kINDEX1).getSerializer().peekData()},
@@ -707,11 +709,13 @@ generateNormalPathBookOffersTestBundles()
.testName = "PaysUSDGetsXRPNoFrozenOwnerFundNotEnough",
.inputJson = getsXRPPaysUSDInputJson,
// prepare offer dir index
.mockedSuccessors=std::map<ripple::uint256, std::optional<ripple::uint256>>{
.mockedSuccessors =
std::map<ripple::uint256, std::optional<ripple::uint256>>{
{getsXRPPaysUSDBook, ripple::uint256{kPAYS20_USD_GETS10_XRP_BOOK_DIR}},
{ripple::uint256{kPAYS20_USD_GETS10_XRP_BOOK_DIR}, std::optional<ripple::uint256>{}}
},
.mockedLedgerObjects=std::map<ripple::uint256, ripple::Blob>{
.mockedLedgerObjects =
std::map<ripple::uint256, ripple::Blob>{
// book dir object
{ripple::uint256{kPAYS20_USD_GETS10_XRP_BOOK_DIR},
createOwnerDirLedgerObject({ripple::uint256{kINDEX2}}, kINDEX1).getSerializer().peekData()},
@@ -772,11 +776,13 @@ generateNormalPathBookOffersTestBundles()
.testName = "PaysUSDGetsXRPFrozen",
.inputJson = getsXRPPaysUSDInputJson,
// prepare offer dir index
.mockedSuccessors=std::map<ripple::uint256, std::optional<ripple::uint256>>{
.mockedSuccessors =
std::map<ripple::uint256, std::optional<ripple::uint256>>{
{getsXRPPaysUSDBook, ripple::uint256{kPAYS20_USD_GETS10_XRP_BOOK_DIR}},
{ripple::uint256{kPAYS20_USD_GETS10_XRP_BOOK_DIR}, std::optional<ripple::uint256>{}}
},
.mockedLedgerObjects=std::map<ripple::uint256, ripple::Blob>{
.mockedLedgerObjects =
std::map<ripple::uint256, ripple::Blob>{
// book dir object
{ripple::uint256{kPAYS20_USD_GETS10_XRP_BOOK_DIR},
createOwnerDirLedgerObject({ripple::uint256{kINDEX2}}, kINDEX1).getSerializer().peekData()},
@@ -832,17 +838,21 @@ generateNormalPathBookOffersTestBundles()
.testName = "GetsUSDPaysXRPFrozen",
.inputJson = paysXRPGetsUSDInputJson,
// prepare offer dir index
.mockedSuccessors=std::map<ripple::uint256, std::optional<ripple::uint256>>{
.mockedSuccessors =
std::map<ripple::uint256, std::optional<ripple::uint256>>{
{getsUSDPaysXRPBook, ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR}},
{ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR}, std::optional<ripple::uint256>{}}
},
.mockedLedgerObjects=std::map<ripple::uint256, ripple::Blob>{
.mockedLedgerObjects =
std::map<ripple::uint256, ripple::Blob>{
// book dir object
{ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR},
createOwnerDirLedgerObject({ripple::uint256{kINDEX2}}, kINDEX1).getSerializer().peekData()},
// gets issuer account object
{ripple::keylet::account(account).key,
createAccountRootObject(kACCOUNT, ripple::lsfGlobalFreeze, 2, 200, 2, kINDEX1, 2, kTRANSFER_RATE_X2)
createAccountRootObject(
kACCOUNT, ripple::lsfGlobalFreeze, 2, 200, 2, kINDEX1, 2, kTRANSFER_RATE_X2
)
.getSerializer()
.peekData()}
},
@@ -893,11 +903,13 @@ generateNormalPathBookOffersTestBundles()
.testName = "PaysXRPGetsUSDWithTransferFee",
.inputJson = paysXRPGetsUSDInputJson,
// prepare offer dir index
.mockedSuccessors=std::map<ripple::uint256, std::optional<ripple::uint256>>{
.mockedSuccessors =
std::map<ripple::uint256, std::optional<ripple::uint256>>{
{getsUSDPaysXRPBook, ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR}},
{ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR}, std::optional<ripple::uint256>{}}
},
.mockedLedgerObjects=std::map<ripple::uint256, ripple::Blob>{
.mockedLedgerObjects =
std::map<ripple::uint256, ripple::Blob>{
// book dir object
{ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR},
createOwnerDirLedgerObject({ripple::uint256{kINDEX2}}, kINDEX1).getSerializer().peekData()},
@@ -957,11 +969,13 @@ generateNormalPathBookOffersTestBundles()
.testName = "PaysXRPGetsUSDWithMultipleOffers",
.inputJson = paysXRPGetsUSDInputJson,
// prepare offer dir index
.mockedSuccessors=std::map<ripple::uint256, std::optional<ripple::uint256>>{
.mockedSuccessors =
std::map<ripple::uint256, std::optional<ripple::uint256>>{
{getsUSDPaysXRPBook, ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR}},
{ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR}, std::optional<ripple::uint256>{}}
},
.mockedLedgerObjects=std::map<ripple::uint256, ripple::Blob>{
.mockedLedgerObjects =
std::map<ripple::uint256, ripple::Blob>{
// book dir object
{ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR},
createOwnerDirLedgerObject({ripple::uint256{kINDEX2}, ripple::uint256{kINDEX2}}, kINDEX1)
@@ -977,7 +991,8 @@ generateNormalPathBookOffersTestBundles()
trustline30Balance.getSerializer().peekData()},
},
.ledgerObjectCalls = 6,
.mockedOffers=std::vector<ripple::STObject>{// After offer1, balance is 30 - 2*10 = 10
.mockedOffers =
std::vector<ripple::STObject>{// After offer1, balance is 30 - 2*10 = 10
gets10USDPays20XRPOffer,
// offer2 not fully funded, balance is 10, rate is 2, so only
// gets 5
@@ -1050,11 +1065,13 @@ generateNormalPathBookOffersTestBundles()
.testName = "PaysXRPGetsUSDSellingOwnCurrency",
.inputJson = paysXRPGetsUSDInputJson,
// prepare offer dir index
.mockedSuccessors=std::map<ripple::uint256, std::optional<ripple::uint256>>{
.mockedSuccessors =
std::map<ripple::uint256, std::optional<ripple::uint256>>{
{getsUSDPaysXRPBook, ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR}},
{ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR}, std::optional<ripple::uint256>{}}
},
.mockedLedgerObjects=std::map<ripple::uint256, ripple::Blob>{
.mockedLedgerObjects =
std::map<ripple::uint256, ripple::Blob>{
// book dir object
{ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR},
createOwnerDirLedgerObject({ripple::uint256{kINDEX2}}, kINDEX1).getSerializer().peekData()},
@@ -1105,11 +1122,13 @@ generateNormalPathBookOffersTestBundles()
.testName = "PaysXRPGetsUSDTrustLineFrozen",
.inputJson = paysXRPGetsUSDInputJson,
// prepare offer dir index
.mockedSuccessors=std::map<ripple::uint256, std::optional<ripple::uint256>>{
.mockedSuccessors =
std::map<ripple::uint256, std::optional<ripple::uint256>>{
{getsUSDPaysXRPBook, ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR}},
{ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR}, std::optional<ripple::uint256>{}}
},
.mockedLedgerObjects=std::map<ripple::uint256, ripple::Blob>{
.mockedLedgerObjects =
std::map<ripple::uint256, ripple::Blob>{
// book dir object
{ripple::uint256{kPAYS20_XRP_GETS10_USD_BOOK_DIR},
createOwnerDirLedgerObject({ripple::uint256{kINDEX2}}, kINDEX1).getSerializer().peekData()},

View File

@@ -454,7 +454,9 @@ generateNormalPathTestBundles()
ripple::uint256{kINDEX2}},
kINDEX1
),
.mockedObjects=std::vector{// hotwallet
.mockedObjects =
std::vector{
// hotwallet
createRippleStateLedgerObject("USD", kISSUER, -10, kACCOUNT, 100, kACCOUNT2, 200, kTXN_ID, 123),
// hotwallet
createRippleStateLedgerObject("CNY", kISSUER, -20, kACCOUNT, 100, kACCOUNT2, 200, kTXN_ID, 123),
@@ -518,7 +520,9 @@ generateNormalPathTestBundles()
NormalTestBundle{
.testName = "NoHotwallet",
.mockedDir = createOwnerDirLedgerObject({ripple::uint256{kINDEX2}}, kINDEX1),
.mockedObjects=std::vector{createRippleStateLedgerObject("JPY", kISSUER, -50, kACCOUNT, 10, kACCOUNT3, 20, kTXN_ID, 123)},
.mockedObjects = std::vector{createRippleStateLedgerObject(
"JPY", kISSUER, -50, kACCOUNT, 10, kACCOUNT3, 20, kTXN_ID, 123
)},
.expectedJson = fmt::format(
R"({{
"obligations":{{
@@ -556,7 +560,9 @@ generateNormalPathTestBundles()
},
kINDEX1
),
.mockedObjects=std::vector{// hotwallet
.mockedObjects =
std::vector{
// hotwallet
createRippleStateLedgerObject("USD", kISSUER, 10, kACCOUNT2, 100, kACCOUNT, 200, kTXN_ID, 123),
// hotwallet
createRippleStateLedgerObject("CNY", kISSUER, 20, kACCOUNT2, 100, kACCOUNT, 200, kTXN_ID, 123),
@@ -603,7 +609,8 @@ generateNormalPathTestBundles()
.mockedDir = createOwnerDirLedgerObject(
{ripple::uint256{kINDEX2}, ripple::uint256{kINDEX2}, ripple::uint256{kINDEX2}}, kINDEX1
),
.mockedObjects=std::vector{
.mockedObjects =
std::vector{
createRippleStateLedgerObject("USD", kISSUER, -10, kACCOUNT, 100, kACCOUNT2, 200, kTXN_ID, 123),
createRippleStateLedgerObject("CNY", kISSUER, -20, kACCOUNT, 100, kACCOUNT2, 200, kTXN_ID, 123),
createRippleStateLedgerObject("EUR", kISSUER, -30, kACCOUNT, 100, kACCOUNT3, 200, kTXN_ID, 123)

View File

@@ -130,12 +130,30 @@ public:
{
// start from 2024-06-25T12:23:10Z to 2024-06-25T12:23:50Z with step 2
return std::vector<LedgerIndexTestsCaseBundle>{
{.testName="LaterThanMaxLedger", .json=R"({"date": "2024-06-25T12:23:55Z"})", .expectedLedgerIndex=kRANGE_MAX, .closeTimeIso="2024-06-25T12:23:50Z"},
{.testName="GreaterThanMinLedger", .json=R"({"date": "2024-06-25T12:23:11Z"})", .expectedLedgerIndex=kRANGE_MIN, .closeTimeIso="2024-06-25T12:23:10Z"},
{.testName="IsMinLedger", .json=R"({"date": "2024-06-25T12:23:10Z"})", .expectedLedgerIndex=kRANGE_MIN, .closeTimeIso="2024-06-25T12:23:10Z"},
{.testName="IsMaxLedger", .json=R"({"date": "2024-06-25T12:23:50Z"})", .expectedLedgerIndex=kRANGE_MAX, .closeTimeIso="2024-06-25T12:23:50Z"},
{.testName="IsMidLedger", .json=R"({"date": "2024-06-25T12:23:30Z"})", .expectedLedgerIndex=20, .closeTimeIso="2024-06-25T12:23:30Z"},
{.testName="BetweenLedgers", .json=R"({"date": "2024-06-25T12:23:29Z"})", .expectedLedgerIndex=19, .closeTimeIso="2024-06-25T12:23:28Z"}
{.testName = "LaterThanMaxLedger",
.json = R"({"date": "2024-06-25T12:23:55Z"})",
.expectedLedgerIndex = kRANGE_MAX,
.closeTimeIso = "2024-06-25T12:23:50Z"},
{.testName = "GreaterThanMinLedger",
.json = R"({"date": "2024-06-25T12:23:11Z"})",
.expectedLedgerIndex = kRANGE_MIN,
.closeTimeIso = "2024-06-25T12:23:10Z"},
{.testName = "IsMinLedger",
.json = R"({"date": "2024-06-25T12:23:10Z"})",
.expectedLedgerIndex = kRANGE_MIN,
.closeTimeIso = "2024-06-25T12:23:10Z"},
{.testName = "IsMaxLedger",
.json = R"({"date": "2024-06-25T12:23:50Z"})",
.expectedLedgerIndex = kRANGE_MAX,
.closeTimeIso = "2024-06-25T12:23:50Z"},
{.testName = "IsMidLedger",
.json = R"({"date": "2024-06-25T12:23:30Z"})",
.expectedLedgerIndex = 20,
.closeTimeIso = "2024-06-25T12:23:30Z"},
{.testName = "BetweenLedgers",
.json = R"({"date": "2024-06-25T12:23:29Z"})",
.expectedLedgerIndex = 19,
.closeTimeIso = "2024-06-25T12:23:28Z"}
};
}
};

View File

@@ -769,7 +769,8 @@ TEST_F(RPCLedgerHandlerTest, DiffNotBinary)
los.push_back(LedgerObject{.key = ripple::uint256{kINDEX2}, .blob = Blob{}}); // NOLINT(modernize-use-emplace)
los.push_back(LedgerObject{
.key = ripple::uint256{kINDEX1},
.blob=createAccountRootObject(kACCOUNT, ripple::lsfGlobalFreeze, 1, 10, 2, kINDEX1, 3).getSerializer().peekData()
.blob =
createAccountRootObject(kACCOUNT, ripple::lsfGlobalFreeze, 1, 10, 2, kINDEX1, 3).getSerializer().peekData()
});
ON_CALL(*backend_, fetchLedgerDiff(kRANGE_MAX, _)).WillByDefault(Return(los));
@@ -812,7 +813,8 @@ TEST_F(RPCLedgerHandlerTest, DiffBinary)
los.push_back(LedgerObject{.key = ripple::uint256{kINDEX2}, .blob = Blob{}}); // NOLINT(modernize-use-emplace)
los.push_back(LedgerObject{
.key = ripple::uint256{kINDEX1},
.blob=createAccountRootObject(kACCOUNT, ripple::lsfGlobalFreeze, 1, 10, 2, kINDEX1, 3).getSerializer().peekData()
.blob =
createAccountRootObject(kACCOUNT, ripple::lsfGlobalFreeze, 1, 10, 2, kINDEX1, 3).getSerializer().peekData()
});
ON_CALL(*backend_, fetchLedgerDiff(kRANGE_MAX, _)).WillByDefault(Return(los));

View File

@@ -509,7 +509,8 @@ TEST_F(RPCNFTsByIssuerHandlerTest, MarkerParameter)
std::vector<NFT> const nfts = {createNft(kNFT_ID3, kACCOUNT, 29)};
auto const account = getAccountIdWithString(kACCOUNT);
ON_CALL(*backend_, fetchNFTsByIssuer).WillByDefault(Return(NFTsAndCursor{.nfts=nfts, .cursor=ripple::uint256{kNFT_ID3}}));
ON_CALL(*backend_, fetchNFTsByIssuer)
.WillByDefault(Return(NFTsAndCursor{.nfts = nfts, .cursor = ripple::uint256{kNFT_ID3}}));
EXPECT_CALL(*backend_, fetchNFTsByIssuer(account, _, Const(30), _, Eq(ripple::uint256{kNFT_ID1}), _)).Times(1);
auto const input = json::parse(fmt::format(

View File

@@ -855,8 +855,13 @@ auto
generateInvalidVersions()
{
return std::vector<InvalidAPIVersionTestBundle>{
{.testName="v0", .version="0", .wsMessage=fmt::format("Requested API version is lower than minimum supported ({})", rpc::kAPI_VERSION_MIN)},
{.testName="v4", .version="4", .wsMessage=fmt::format("Requested API version is higher than maximum supported ({})", rpc::kAPI_VERSION_MAX)},
{.testName = "v0",
.version = "0",
.wsMessage = fmt::format("Requested API version is lower than minimum supported ({})", rpc::kAPI_VERSION_MIN)},
{.testName = "v4",
.version = "4",
.wsMessage = fmt::format("Requested API version is higher than maximum supported ({})", rpc::kAPI_VERSION_MAX)
},
{.testName = "null", .version = "null", .wsMessage = "API version must be an integer"},
{.testName = "str", .version = "\"bogus\"", .wsMessage = "API version must be an integer"},
{.testName = "bool", .version = "false", .wsMessage = "API version must be an integer"},

View File

@@ -69,13 +69,7 @@ struct ConnectionHandlerTest : SyncAsioContextTest {
: tagFactory{util::config::ClioConfigDefinition{
{"log_tag_style", config::ConfigValue{config::ConfigType::String}.defaultValue("uint")}
}}
, connectionHandler{
policy,
maxParallelConnections,
tagFactory,
std::nullopt,
onDisconnectMock.AsStdFunction()
}
, connectionHandler{policy, maxParallelConnections, tagFactory, std::nullopt, onDisconnectMock.AsStdFunction()}
{
}