chore: No ALL_CAPS (#1760)

Fixes #1680
This commit is contained in:
Alex Kremer
2025-01-02 11:39:31 +00:00
committed by GitHub
parent efe5d08205
commit 820b32c6d7
361 changed files with 10061 additions and 9724 deletions

View File

@@ -42,17 +42,21 @@ using namespace rpc;
namespace json = boost::json;
using namespace testing;
constexpr static auto MINSEQ = 10;
constexpr static auto MAXSEQ = 30;
constexpr static auto ACCOUNT = "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn";
constexpr static auto ACCOUNT2 = "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun";
constexpr static auto LEDGERHASH = "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652";
constexpr static auto NFTID = "00010000A7CAD27B688D14BA1A9FA5366554D6ADCF9CE0875B974D9F00000004";
namespace {
constexpr auto kMIN_SEQ = 10;
constexpr auto kMAX_SEQ = 30;
constexpr auto kACCOUNT = "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn";
constexpr auto kACCOUNT2 = "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun";
constexpr auto kLEDGER_HASH = "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652";
constexpr auto kNFT_ID = "00010000A7CAD27B688D14BA1A9FA5366554D6ADCF9CE0875B974D9F00000004";
} // namespace
struct RPCNFTHistoryHandlerTest : HandlerBaseTest {
RPCNFTHistoryHandlerTest()
{
backend->setRange(MINSEQ, MAXSEQ);
backend_->setRange(kMIN_SEQ, kMAX_SEQ);
}
};
@@ -241,14 +245,14 @@ INSTANTIATE_TEST_CASE_P(
RPCNFTHistoryGroup1,
NFTHistoryParameterTest,
ValuesIn(generateTestValuesForParametersTest()),
tests::util::NameGenerator
tests::util::kNAME_GENERATOR
);
TEST_P(NFTHistoryParameterTest, InvalidParams)
{
auto const testBundle = GetParam();
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto const req = json::parse(testBundle.testJson);
auto const output = handler.process(req, Context{yield});
ASSERT_FALSE(output);
@@ -264,19 +268,19 @@ genTransactions(uint32_t seq1, uint32_t seq2)
{
auto transactions = std::vector<TransactionAndMetadata>{};
auto trans1 = TransactionAndMetadata();
ripple::STObject const obj = CreatePaymentTransactionObject(ACCOUNT, ACCOUNT2, 1, 1, 32);
ripple::STObject const obj = createPaymentTransactionObject(kACCOUNT, kACCOUNT2, 1, 1, 32);
trans1.transaction = obj.getSerializer().peekData();
trans1.ledgerSequence = seq1;
ripple::STObject const metaObj = CreatePaymentTransactionMetaObject(ACCOUNT, ACCOUNT2, 22, 23);
ripple::STObject const metaObj = createPaymentTransactionMetaObject(kACCOUNT, kACCOUNT2, 22, 23);
trans1.metadata = metaObj.getSerializer().peekData();
trans1.date = 1;
transactions.push_back(trans1);
auto trans2 = TransactionAndMetadata();
ripple::STObject const obj2 = CreatePaymentTransactionObject(ACCOUNT, ACCOUNT2, 1, 1, 32);
ripple::STObject const obj2 = createPaymentTransactionObject(kACCOUNT, kACCOUNT2, 1, 1, 32);
trans2.transaction = obj.getSerializer().peekData();
trans2.ledgerSequence = seq2;
ripple::STObject const metaObj2 = CreatePaymentTransactionMetaObject(ACCOUNT, ACCOUNT2, 22, 23);
ripple::STObject const metaObj2 = createPaymentTransactionMetaObject(kACCOUNT, kACCOUNT2, 22, 23);
trans2.metadata = metaObj2.getSerializer().peekData();
trans2.date = 2;
transactions.push_back(trans2);
@@ -285,35 +289,39 @@ genTransactions(uint32_t seq1, uint32_t seq2)
TEST_F(RPCNFTHistoryHandlerTest, IndexSpecificForwardTrue)
{
auto const transactions = genTransactions(MINSEQ + 1, MAXSEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
ON_CALL(*backend, fetchNFTTransactions).WillByDefault(Return(transCursor));
auto const transactions = genTransactions(kMIN_SEQ + 1, kMAX_SEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
ON_CALL(*backend_, fetchNFTTransactions).WillByDefault(Return(transCursor));
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_, testing::_, true, testing::Optional(testing::Eq(TransactionsCursor{MINSEQ + 1, 0})), testing::_
testing::_,
testing::_,
true,
testing::Optional(testing::Eq(TransactionsCursor{kMIN_SEQ + 1, 0})),
testing::_
)
)
.Times(1);
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index_min": {},
"ledger_index_max": {},
"forward": true
}})",
NFTID,
MINSEQ + 1,
MAXSEQ - 1
kNFT_ID,
kMIN_SEQ + 1,
kMAX_SEQ - 1
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_TRUE(output);
EXPECT_EQ(output.result->at("nft_id").as_string(), NFTID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), MINSEQ + 1);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), MAXSEQ - 1);
EXPECT_EQ(output.result->at("nft_id").as_string(), kNFT_ID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), kMIN_SEQ + 1);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), kMAX_SEQ - 1);
EXPECT_EQ(output.result->at("marker").as_object(), json::parse(R"({"ledger":12,"seq":34})"));
EXPECT_EQ(output.result->at("transactions").as_array().size(), 2);
EXPECT_FALSE(output.result->as_object().contains("limit"));
@@ -322,7 +330,7 @@ TEST_F(RPCNFTHistoryHandlerTest, IndexSpecificForwardTrue)
TEST_F(RPCNFTHistoryHandlerTest, IndexSpecificForwardFalseV1)
{
auto constexpr OUTPUT = R"({
constexpr auto kOUTPUT = R"({
"nft_id": "00010000A7CAD27B688D14BA1A9FA5366554D6ADCF9CE0875B974D9F00000004",
"ledger_index_min": 11,
"ledger_index_max": 29,
@@ -425,43 +433,43 @@ TEST_F(RPCNFTHistoryHandlerTest, IndexSpecificForwardFalseV1)
}
})";
auto const transactions = genTransactions(MINSEQ + 1, MAXSEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
ON_CALL(*backend, fetchNFTTransactions).WillByDefault(Return(transCursor));
auto const transactions = genTransactions(kMIN_SEQ + 1, kMAX_SEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
ON_CALL(*backend_, fetchNFTTransactions).WillByDefault(Return(transCursor));
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_,
testing::_,
false,
testing::Optional(testing::Eq(TransactionsCursor{MAXSEQ - 1, INT32_MAX})),
testing::Optional(testing::Eq(TransactionsCursor{kMAX_SEQ - 1, INT32_MAX})),
testing::_
)
)
.Times(1);
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index_min": {},
"ledger_index_max": {},
"forward": false
}})",
NFTID,
MINSEQ + 1,
MAXSEQ - 1
kNFT_ID,
kMIN_SEQ + 1,
kMAX_SEQ - 1
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_TRUE(output);
EXPECT_EQ(output.result.value(), boost::json::parse(OUTPUT));
EXPECT_EQ(output.result.value(), boost::json::parse(kOUTPUT));
});
}
TEST_F(RPCNFTHistoryHandlerTest, IndexSpecificForwardFalseV2)
{
auto constexpr OUTPUT = R"({
constexpr auto kOUTPUT = R"({
"nft_id": "00010000A7CAD27B688D14BA1A9FA5366554D6ADCF9CE0875B974D9F00000004",
"ledger_index_min": 11,
"ledger_index_max": 29,
@@ -576,74 +584,74 @@ TEST_F(RPCNFTHistoryHandlerTest, IndexSpecificForwardFalseV2)
}
})";
auto const transactions = genTransactions(MINSEQ + 1, MAXSEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
auto const transactions = genTransactions(kMIN_SEQ + 1, kMAX_SEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_,
testing::_,
false,
testing::Optional(testing::Eq(TransactionsCursor{MAXSEQ - 1, INT32_MAX})),
testing::Optional(testing::Eq(TransactionsCursor{kMAX_SEQ - 1, INT32_MAX})),
testing::_
)
)
.WillOnce(Return(transCursor));
auto const ledgerHeader = CreateLedgerHeader(LEDGERHASH, MAXSEQ);
ON_CALL(*backend, fetchLedgerBySequence).WillByDefault(Return(ledgerHeader));
EXPECT_CALL(*backend, fetchLedgerBySequence).Times(2);
auto const ledgerHeader = createLedgerHeader(kLEDGER_HASH, kMAX_SEQ);
ON_CALL(*backend_, fetchLedgerBySequence).WillByDefault(Return(ledgerHeader));
EXPECT_CALL(*backend_, fetchLedgerBySequence).Times(2);
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index_min": {},
"ledger_index_max": {},
"forward": false
}})",
NFTID,
MINSEQ + 1,
MAXSEQ - 1
kNFT_ID,
kMIN_SEQ + 1,
kMAX_SEQ - 1
));
auto const output = handler.process(input, Context{.yield = yield, .apiVersion = 2u});
auto const output = handler.process(kINPUT, Context{.yield = yield, .apiVersion = 2u});
ASSERT_TRUE(output);
EXPECT_EQ(output.result.value(), boost::json::parse(OUTPUT));
EXPECT_EQ(output.result.value(), boost::json::parse(kOUTPUT));
});
}
TEST_F(RPCNFTHistoryHandlerTest, IndexNotSpecificForwardTrue)
{
auto const transactions = genTransactions(MINSEQ + 1, MAXSEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
ON_CALL(*backend, fetchNFTTransactions).WillByDefault(Return(transCursor));
auto const transactions = genTransactions(kMIN_SEQ + 1, kMAX_SEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
ON_CALL(*backend_, fetchNFTTransactions).WillByDefault(Return(transCursor));
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_, testing::_, true, testing::Optional(testing::Eq(TransactionsCursor{MINSEQ, 0})), testing::_
testing::_, testing::_, true, testing::Optional(testing::Eq(TransactionsCursor{kMIN_SEQ, 0})), testing::_
)
)
.Times(1);
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index_min": {},
"ledger_index_max": {},
"forward": true
}})",
NFTID,
kNFT_ID,
-1,
-1
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_TRUE(output);
EXPECT_EQ(output.result->at("nft_id").as_string(), NFTID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), MINSEQ);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), MAXSEQ);
EXPECT_EQ(output.result->at("nft_id").as_string(), kNFT_ID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), kMIN_SEQ);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), kMAX_SEQ);
EXPECT_EQ(output.result->at("marker").as_object(), json::parse(R"({"ledger":12,"seq":34})"));
EXPECT_EQ(output.result->at("transactions").as_array().size(), 2);
EXPECT_FALSE(output.result->as_object().contains("limit"));
@@ -652,39 +660,39 @@ TEST_F(RPCNFTHistoryHandlerTest, IndexNotSpecificForwardTrue)
TEST_F(RPCNFTHistoryHandlerTest, IndexNotSpecificForwardFalse)
{
auto const transactions = genTransactions(MINSEQ + 1, MAXSEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
ON_CALL(*backend, fetchNFTTransactions).WillByDefault(Return(transCursor));
auto const transactions = genTransactions(kMIN_SEQ + 1, kMAX_SEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
ON_CALL(*backend_, fetchNFTTransactions).WillByDefault(Return(transCursor));
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_,
testing::_,
false,
testing::Optional(testing::Eq(TransactionsCursor{MAXSEQ, INT32_MAX})),
testing::Optional(testing::Eq(TransactionsCursor{kMAX_SEQ, INT32_MAX})),
testing::_
)
)
.Times(1);
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index_min": {},
"ledger_index_max": {},
"forward": false
}})",
NFTID,
kNFT_ID,
-1,
-1
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_TRUE(output);
EXPECT_EQ(output.result->at("nft_id").as_string(), NFTID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), MINSEQ);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), MAXSEQ);
EXPECT_EQ(output.result->at("nft_id").as_string(), kNFT_ID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), kMIN_SEQ);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), kMAX_SEQ);
EXPECT_EQ(output.result->at("marker").as_object(), json::parse(R"({"ledger":12,"seq":34})"));
EXPECT_EQ(output.result->at("transactions").as_array().size(), 2);
EXPECT_FALSE(output.result->as_object().contains("limit"));
@@ -693,39 +701,39 @@ TEST_F(RPCNFTHistoryHandlerTest, IndexNotSpecificForwardFalse)
TEST_F(RPCNFTHistoryHandlerTest, BinaryTrueV1)
{
auto const transactions = genTransactions(MINSEQ + 1, MAXSEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
ON_CALL(*backend, fetchNFTTransactions).WillByDefault(Return(transCursor));
auto const transactions = genTransactions(kMIN_SEQ + 1, kMAX_SEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
ON_CALL(*backend_, fetchNFTTransactions).WillByDefault(Return(transCursor));
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_,
testing::_,
false,
testing::Optional(testing::Eq(TransactionsCursor{MAXSEQ, INT32_MAX})),
testing::Optional(testing::Eq(TransactionsCursor{kMAX_SEQ, INT32_MAX})),
testing::_
)
)
.Times(1);
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index_min": {},
"ledger_index_max": {},
"binary": true
}})",
NFTID,
kNFT_ID,
-1,
-1
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_TRUE(output);
EXPECT_EQ(output.result->at("nft_id").as_string(), NFTID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), MINSEQ);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), MAXSEQ);
EXPECT_EQ(output.result->at("nft_id").as_string(), kNFT_ID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), kMIN_SEQ);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), kMAX_SEQ);
EXPECT_EQ(output.result->at("marker").as_object(), json::parse(R"({"ledger":12,"seq":34})"));
EXPECT_EQ(output.result->at("transactions").as_array().size(), 2);
EXPECT_EQ(
@@ -748,38 +756,38 @@ TEST_F(RPCNFTHistoryHandlerTest, BinaryTrueV1)
TEST_F(RPCNFTHistoryHandlerTest, BinaryTrueV2)
{
auto const transactions = genTransactions(MINSEQ + 1, MAXSEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
auto const transactions = genTransactions(kMIN_SEQ + 1, kMAX_SEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_,
testing::_,
false,
testing::Optional(testing::Eq(TransactionsCursor{MAXSEQ, INT32_MAX})),
testing::Optional(testing::Eq(TransactionsCursor{kMAX_SEQ, INT32_MAX})),
testing::_
)
)
.WillOnce(Return(transCursor));
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index_min": {},
"ledger_index_max": {},
"binary": true
}})",
NFTID,
kNFT_ID,
-1,
-1
));
auto const output = handler.process(input, Context{.yield = yield, .apiVersion = 2u});
auto const output = handler.process(kINPUT, Context{.yield = yield, .apiVersion = 2u});
ASSERT_TRUE(output);
EXPECT_EQ(output.result->at("nft_id").as_string(), NFTID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), MINSEQ);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), MAXSEQ);
EXPECT_EQ(output.result->at("nft_id").as_string(), kNFT_ID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), kMIN_SEQ);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), kMAX_SEQ);
EXPECT_EQ(output.result->at("marker").as_object(), json::parse(R"({"ledger":12,"seq":34})"));
EXPECT_EQ(output.result->at("transactions").as_array().size(), 2);
EXPECT_EQ(
@@ -802,11 +810,11 @@ TEST_F(RPCNFTHistoryHandlerTest, BinaryTrueV2)
TEST_F(RPCNFTHistoryHandlerTest, LimitAndMarker)
{
auto const transactions = genTransactions(MINSEQ + 1, MAXSEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
ON_CALL(*backend, fetchNFTTransactions).WillByDefault(Return(transCursor));
auto const transactions = genTransactions(kMIN_SEQ + 1, kMAX_SEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
ON_CALL(*backend_, fetchNFTTransactions).WillByDefault(Return(transCursor));
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_, testing::_, false, testing::Optional(testing::Eq(TransactionsCursor{10, 11})), testing::_
)
@@ -814,8 +822,8 @@ TEST_F(RPCNFTHistoryHandlerTest, LimitAndMarker)
.Times(1);
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index_min": {},
@@ -824,15 +832,15 @@ TEST_F(RPCNFTHistoryHandlerTest, LimitAndMarker)
"forward": false,
"marker": {{"ledger":10,"seq":11}}
}})",
NFTID,
kNFT_ID,
-1,
-1
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_TRUE(output);
EXPECT_EQ(output.result->at("nft_id").as_string(), NFTID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), MINSEQ);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), MAXSEQ);
EXPECT_EQ(output.result->at("nft_id").as_string(), kNFT_ID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), kMIN_SEQ);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), kMAX_SEQ);
EXPECT_EQ(output.result->at("limit").as_uint64(), 2);
EXPECT_EQ(output.result->at("marker").as_object(), json::parse(R"({"ledger":12,"seq":34})"));
EXPECT_EQ(output.result->at("transactions").as_array().size(), 2);
@@ -842,40 +850,40 @@ TEST_F(RPCNFTHistoryHandlerTest, LimitAndMarker)
TEST_F(RPCNFTHistoryHandlerTest, SpecificLedgerIndex)
{
// adjust the order for forward->false
auto const transactions = genTransactions(MAXSEQ - 1, MINSEQ + 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
ON_CALL(*backend, fetchNFTTransactions).WillByDefault(Return(transCursor));
auto const transactions = genTransactions(kMAX_SEQ - 1, kMIN_SEQ + 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
ON_CALL(*backend_, fetchNFTTransactions).WillByDefault(Return(transCursor));
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_,
testing::_,
false,
testing::Optional(testing::Eq(TransactionsCursor{MAXSEQ - 1, INT32_MAX})),
testing::Optional(testing::Eq(TransactionsCursor{kMAX_SEQ - 1, INT32_MAX})),
testing::_
)
)
.Times(1);
auto const ledgerHeader = CreateLedgerHeader(LEDGERHASH, MAXSEQ - 1);
EXPECT_CALL(*backend, fetchLedgerBySequence).Times(1);
ON_CALL(*backend, fetchLedgerBySequence(MAXSEQ - 1, _)).WillByDefault(Return(ledgerHeader));
auto const ledgerHeader = createLedgerHeader(kLEDGER_HASH, kMAX_SEQ - 1);
EXPECT_CALL(*backend_, fetchLedgerBySequence).Times(1);
ON_CALL(*backend_, fetchLedgerBySequence(kMAX_SEQ - 1, _)).WillByDefault(Return(ledgerHeader));
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index":{}
}})",
NFTID,
MAXSEQ - 1
kNFT_ID,
kMAX_SEQ - 1
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_TRUE(output);
EXPECT_EQ(output.result->at("nft_id").as_string(), NFTID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), MAXSEQ - 1);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), MAXSEQ - 1);
EXPECT_EQ(output.result->at("nft_id").as_string(), kNFT_ID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), kMAX_SEQ - 1);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), kMAX_SEQ - 1);
EXPECT_FALSE(output.result->as_object().contains("limit"));
EXPECT_FALSE(output.result->as_object().contains("marker"));
EXPECT_EQ(output.result->at("transactions").as_array().size(), 1);
@@ -884,20 +892,20 @@ TEST_F(RPCNFTHistoryHandlerTest, SpecificLedgerIndex)
TEST_F(RPCNFTHistoryHandlerTest, SpecificNonexistLedgerIntIndex)
{
EXPECT_CALL(*backend, fetchLedgerBySequence).Times(1);
ON_CALL(*backend, fetchLedgerBySequence(MAXSEQ - 1, _)).WillByDefault(Return(std::nullopt));
EXPECT_CALL(*backend_, fetchLedgerBySequence).Times(1);
ON_CALL(*backend_, fetchLedgerBySequence(kMAX_SEQ - 1, _)).WillByDefault(Return(std::nullopt));
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index":{}
}})",
NFTID,
MAXSEQ - 1
kNFT_ID,
kMAX_SEQ - 1
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_FALSE(output);
auto const err = rpc::makeError(output.result.error());
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
@@ -907,20 +915,20 @@ TEST_F(RPCNFTHistoryHandlerTest, SpecificNonexistLedgerIntIndex)
TEST_F(RPCNFTHistoryHandlerTest, SpecificNonexistLedgerStringIndex)
{
EXPECT_CALL(*backend, fetchLedgerBySequence).Times(1);
ON_CALL(*backend, fetchLedgerBySequence(MAXSEQ - 1, _)).WillByDefault(Return(std::nullopt));
EXPECT_CALL(*backend_, fetchLedgerBySequence).Times(1);
ON_CALL(*backend_, fetchLedgerBySequence(kMAX_SEQ - 1, _)).WillByDefault(Return(std::nullopt));
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index":"{}"
}})",
NFTID,
MAXSEQ - 1
kNFT_ID,
kMAX_SEQ - 1
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_FALSE(output);
auto const err = rpc::makeError(output.result.error());
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
@@ -931,40 +939,40 @@ TEST_F(RPCNFTHistoryHandlerTest, SpecificNonexistLedgerStringIndex)
TEST_F(RPCNFTHistoryHandlerTest, SpecificLedgerHash)
{
// adjust the order for forward->false
auto const transactions = genTransactions(MAXSEQ - 1, MINSEQ + 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
ON_CALL(*backend, fetchNFTTransactions).WillByDefault(Return(transCursor));
auto const transactions = genTransactions(kMAX_SEQ - 1, kMIN_SEQ + 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
ON_CALL(*backend_, fetchNFTTransactions).WillByDefault(Return(transCursor));
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_,
testing::_,
false,
testing::Optional(testing::Eq(TransactionsCursor{MAXSEQ - 1, INT32_MAX})),
testing::Optional(testing::Eq(TransactionsCursor{kMAX_SEQ - 1, INT32_MAX})),
testing::_
)
)
.Times(1);
auto const ledgerHeader = CreateLedgerHeader(LEDGERHASH, MAXSEQ - 1);
EXPECT_CALL(*backend, fetchLedgerByHash).Times(1);
ON_CALL(*backend, fetchLedgerByHash(ripple::uint256{LEDGERHASH}, _)).WillByDefault(Return(ledgerHeader));
auto const ledgerHeader = createLedgerHeader(kLEDGER_HASH, kMAX_SEQ - 1);
EXPECT_CALL(*backend_, fetchLedgerByHash).Times(1);
ON_CALL(*backend_, fetchLedgerByHash(ripple::uint256{kLEDGER_HASH}, _)).WillByDefault(Return(ledgerHeader));
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_hash":"{}"
}})",
NFTID,
LEDGERHASH
kNFT_ID,
kLEDGER_HASH
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_TRUE(output);
EXPECT_EQ(output.result->at("nft_id").as_string(), NFTID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), MAXSEQ - 1);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), MAXSEQ - 1);
EXPECT_EQ(output.result->at("nft_id").as_string(), kNFT_ID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), kMAX_SEQ - 1);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), kMAX_SEQ - 1);
EXPECT_FALSE(output.result->as_object().contains("limit"));
EXPECT_FALSE(output.result->as_object().contains("marker"));
EXPECT_EQ(output.result->at("transactions").as_array().size(), 1);
@@ -973,39 +981,39 @@ TEST_F(RPCNFTHistoryHandlerTest, SpecificLedgerHash)
TEST_F(RPCNFTHistoryHandlerTest, TxLessThanMinSeq)
{
auto const transactions = genTransactions(MAXSEQ - 1, MINSEQ + 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
ON_CALL(*backend, fetchNFTTransactions).WillByDefault(Return(transCursor));
auto const transactions = genTransactions(kMAX_SEQ - 1, kMIN_SEQ + 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
ON_CALL(*backend_, fetchNFTTransactions).WillByDefault(Return(transCursor));
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_,
testing::_,
false,
testing::Optional(testing::Eq(TransactionsCursor{MAXSEQ - 1, INT32_MAX})),
testing::Optional(testing::Eq(TransactionsCursor{kMAX_SEQ - 1, INT32_MAX})),
testing::_
)
)
.Times(1);
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index_min": {},
"ledger_index_max": {},
"forward": false
}})",
NFTID,
MINSEQ + 2,
MAXSEQ - 1
kNFT_ID,
kMIN_SEQ + 2,
kMAX_SEQ - 1
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_TRUE(output);
EXPECT_EQ(output.result->at("nft_id").as_string(), NFTID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), MINSEQ + 2);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), MAXSEQ - 1);
EXPECT_EQ(output.result->at("nft_id").as_string(), kNFT_ID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), kMIN_SEQ + 2);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), kMAX_SEQ - 1);
EXPECT_EQ(output.result->at("transactions").as_array().size(), 1);
EXPECT_FALSE(output.result->as_object().contains("limit"));
EXPECT_FALSE(output.result->as_object().contains("marker"));
@@ -1014,39 +1022,39 @@ TEST_F(RPCNFTHistoryHandlerTest, TxLessThanMinSeq)
TEST_F(RPCNFTHistoryHandlerTest, TxLargerThanMaxSeq)
{
auto const transactions = genTransactions(MAXSEQ - 1, MINSEQ + 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
ON_CALL(*backend, fetchNFTTransactions).WillByDefault(Return(transCursor));
auto const transactions = genTransactions(kMAX_SEQ - 1, kMIN_SEQ + 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
ON_CALL(*backend_, fetchNFTTransactions).WillByDefault(Return(transCursor));
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_,
testing::_,
false,
testing::Optional(testing::Eq(TransactionsCursor{MAXSEQ - 2, INT32_MAX})),
testing::Optional(testing::Eq(TransactionsCursor{kMAX_SEQ - 2, INT32_MAX})),
testing::_
)
)
.Times(1);
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index_min": {},
"ledger_index_max": {},
"forward": false
}})",
NFTID,
MINSEQ + 1,
MAXSEQ - 2
kNFT_ID,
kMIN_SEQ + 1,
kMAX_SEQ - 2
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_TRUE(output);
EXPECT_EQ(output.result->at("nft_id").as_string(), NFTID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), MINSEQ + 1);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), MAXSEQ - 2);
EXPECT_EQ(output.result->at("nft_id").as_string(), kNFT_ID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), kMIN_SEQ + 1);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), kMAX_SEQ - 2);
EXPECT_EQ(output.result->at("transactions").as_array().size(), 1);
EXPECT_FALSE(output.result->as_object().contains("limit"));
EXPECT_EQ(output.result->at("marker").as_object(), json::parse(R"({"ledger":12,"seq":34})"));
@@ -1055,24 +1063,24 @@ TEST_F(RPCNFTHistoryHandlerTest, TxLargerThanMaxSeq)
TEST_F(RPCNFTHistoryHandlerTest, LimitMoreThanMax)
{
auto const transactions = genTransactions(MINSEQ + 1, MAXSEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns = transactions, .cursor = TransactionsCursor{12, 34}};
ON_CALL(*backend, fetchNFTTransactions).WillByDefault(Return(transCursor));
auto const transactions = genTransactions(kMIN_SEQ + 1, kMAX_SEQ - 1);
auto const transCursor = TransactionsAndCursor{.txns=transactions, .cursor=TransactionsCursor{12, 34}};
ON_CALL(*backend_, fetchNFTTransactions).WillByDefault(Return(transCursor));
EXPECT_CALL(
*backend,
*backend_,
fetchNFTTransactions(
testing::_,
testing::_,
false,
testing::Optional(testing::Eq(TransactionsCursor{MAXSEQ - 1, INT32_MAX})),
testing::Optional(testing::Eq(TransactionsCursor{kMAX_SEQ - 1, INT32_MAX})),
testing::_
)
)
.Times(1);
runSpawn([&, this](auto yield) {
auto const handler = AnyHandler{NFTHistoryHandler{backend}};
auto static const input = json::parse(fmt::format(
auto const handler = AnyHandler{NFTHistoryHandler{backend_}};
auto static const kINPUT = json::parse(fmt::format(
R"({{
"nft_id":"{}",
"ledger_index_min": {},
@@ -1080,18 +1088,18 @@ TEST_F(RPCNFTHistoryHandlerTest, LimitMoreThanMax)
"forward": false,
"limit": {}
}})",
NFTID,
MINSEQ + 1,
MAXSEQ - 1,
NFTHistoryHandler::LIMIT_MAX + 1
kNFT_ID,
kMIN_SEQ + 1,
kMAX_SEQ - 1,
NFTHistoryHandler::kLIMIT_MAX + 1
));
auto const output = handler.process(input, Context{yield});
auto const output = handler.process(kINPUT, Context{yield});
ASSERT_TRUE(output);
EXPECT_EQ(output.result->at("nft_id").as_string(), NFTID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), MINSEQ + 1);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), MAXSEQ - 1);
EXPECT_EQ(output.result->at("nft_id").as_string(), kNFT_ID);
EXPECT_EQ(output.result->at("ledger_index_min").as_uint64(), kMIN_SEQ + 1);
EXPECT_EQ(output.result->at("ledger_index_max").as_uint64(), kMAX_SEQ - 1);
EXPECT_EQ(output.result->at("marker").as_object(), json::parse(R"({"ledger":12,"seq":34})"));
EXPECT_EQ(output.result->at("transactions").as_array().size(), 2);
EXPECT_EQ(output.result->as_object().at("limit").as_uint64(), NFTHistoryHandler::LIMIT_MAX);
EXPECT_EQ(output.result->as_object().at("limit").as_uint64(), NFTHistoryHandler::kLIMIT_MAX);
});
}