Skip to content

Commit

Permalink
test case comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Oct 26, 2023
1 parent fdc332f commit 98f5411
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions unittests/rpc/handlers/NFTsByIssuerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ TEST_F(RPCNFTsByIssuerHandlerTest, NonExistLedgerViaLedgerStringIndex)
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
// mock fetchLedgerBySequence return empty
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(std::optional<ripple::LedgerInfo>{}));
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).WillOnce(Return(std::optional<ripple::LedgerInfo>{}));
auto const input = json::parse(fmt::format(
R"({{
"issuer": "{}",
Expand All @@ -240,11 +239,11 @@ TEST_F(RPCNFTsByIssuerHandlerTest, NonExistLedgerViaLedgerStringIndex)
TEST_F(RPCNFTsByIssuerHandlerTest, NonExistLedgerViaLedgerIntIndex)
{
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
// mock fetchLedgerBySequence return empty
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(std::optional<ripple::LedgerInfo>{}));
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).WillOnce(Return(std::optional<ripple::LedgerInfo>{}));
auto const input = json::parse(fmt::format(
R"({{
"issuer": "{}",
Expand All @@ -267,6 +266,7 @@ TEST_F(RPCNFTsByIssuerHandlerTest, NonExistLedgerViaLedgerIntIndex)
TEST_F(RPCNFTsByIssuerHandlerTest, NonExistLedgerViaLedgerHash2)
{
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
// mock fetchLedgerByHash return ledger but seq is 31 > 30
Expand Down Expand Up @@ -295,6 +295,7 @@ TEST_F(RPCNFTsByIssuerHandlerTest, NonExistLedgerViaLedgerHash2)
TEST_F(RPCNFTsByIssuerHandlerTest, NonExistLedgerViaLedgerIndex2)
{
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
// no need to check from db,call fetchLedgerBySequence 0 time
Expand Down Expand Up @@ -331,6 +332,7 @@ TEST_F(RPCNFTsByIssuerHandlerTest, AccountNotFound)
ACCOUNT
);
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
auto ledgerinfo = CreateLedgerInfo(LEDGERHASH, 30);
Expand Down Expand Up @@ -372,11 +374,11 @@ TEST_F(RPCNFTsByIssuerHandlerTest, DefaultParameters)
NFT1OUT
);
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
auto ledgerInfo = CreateLedgerInfo(LEDGERHASH, 30);
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerInfo));
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).WillOnce(Return(ledgerInfo));
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, 30, _)).WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));

Expand Down Expand Up @@ -431,6 +433,7 @@ TEST_F(RPCNFTsByIssuerHandlerTest, SpecificLedgerIndex)
specificLedger
);
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
auto ledgerInfo = CreateLedgerInfo(LEDGERHASH, specificLedger);
Expand Down Expand Up @@ -482,11 +485,11 @@ TEST_F(RPCNFTsByIssuerHandlerTest, TaxonParameter)
NFT1OUT
);
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
auto ledgerInfo = CreateLedgerInfo(LEDGERHASH, 30);
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerInfo));
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).WillOnce(Return(ledgerInfo));
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, 30, _)).WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));

Expand Down Expand Up @@ -529,11 +532,11 @@ TEST_F(RPCNFTsByIssuerHandlerTest, MarkerParameter)
NFT3OUT
);
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
auto ledgerInfo = CreateLedgerInfo(LEDGERHASH, 30);
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerInfo));
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).WillOnce(Return(ledgerInfo));
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, 30, _)).WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));

Expand Down Expand Up @@ -578,11 +581,11 @@ TEST_F(RPCNFTsByIssuerHandlerTest, MultipleNFTs)
NFT3OUT
);
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
auto ledgerInfo = CreateLedgerInfo(LEDGERHASH, 30);
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerInfo));
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).WillOnce(Return(ledgerInfo));
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, 30, _)).WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));

Expand Down Expand Up @@ -626,11 +629,11 @@ TEST_F(RPCNFTsByIssuerHandlerTest, LimitMoreThanMAx)
NFT1OUT
);
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
ASSERT_NE(rawBackendPtr, nullptr);
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
auto ledgerInfo = CreateLedgerInfo(LEDGERHASH, 30);
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerInfo));
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).WillOnce(Return(ledgerInfo));
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, 30, _)).WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));

Expand Down

0 comments on commit 98f5411

Please sign in to comment.