@@ -769,14 +769,13 @@ TEST_F(RPCAccountTxHandlerTest, LimitAndMarker)
769769
770770 auto const transactions = genTransactions (MINSEQ + 1 , MAXSEQ - 1 );
771771 auto const transCursor = TransactionsAndCursor{transactions, TransactionsCursor{12 , 34 }};
772- ON_CALL (*backend, fetchAccountTransactions).WillByDefault (Return (transCursor));
773772 EXPECT_CALL (
774773 *backend,
775774 fetchAccountTransactions (
776775 testing::_, testing::_, false , testing::Optional (testing::Eq (TransactionsCursor{10 , 11 })), testing::_
777776 )
778777 )
779- .Times ( 1 );
778+ .WillOnce ( Return (transCursor) );
780779
781780 runSpawn ([&, this ](auto yield) {
782781 auto const handler = AnyHandler{AccountTxHandler{backend}};
@@ -804,6 +803,73 @@ TEST_F(RPCAccountTxHandlerTest, LimitAndMarker)
804803 });
805804}
806805
806+ TEST_F (RPCAccountTxHandlerTest, LimitIsCapped)
807+ {
808+ backend->setRange (MINSEQ, MAXSEQ);
809+
810+ auto const transactions = genTransactions (MINSEQ + 1 , MAXSEQ - 1 );
811+ auto const transCursor = TransactionsAndCursor{transactions, TransactionsCursor{12 , 34 }};
812+ EXPECT_CALL (*backend, fetchAccountTransactions (testing::_, testing::_, false , testing::_, testing::_))
813+ .WillOnce (Return (transCursor));
814+
815+ runSpawn ([&, this ](auto yield) {
816+ auto const handler = AnyHandler{AccountTxHandler{backend}};
817+ auto static const input = json::parse (fmt::format (
818+ R"( {{
819+ "account": "{}",
820+ "ledger_index_min": {},
821+ "ledger_index_max": {},
822+ "limit": 100000,
823+ "forward": false
824+ }})" ,
825+ ACCOUNT,
826+ -1 ,
827+ -1
828+ ));
829+ auto const output = handler.process (input, Context{yield});
830+ ASSERT_TRUE (output);
831+ EXPECT_EQ (output.result ->at (" account" ).as_string (), ACCOUNT);
832+ EXPECT_EQ (output.result ->at (" ledger_index_min" ).as_uint64 (), MINSEQ);
833+ EXPECT_EQ (output.result ->at (" ledger_index_max" ).as_uint64 (), MAXSEQ);
834+ EXPECT_EQ (output.result ->at (" limit" ).as_uint64 (), AccountTxHandler::LIMIT_MAX);
835+ EXPECT_EQ (output.result ->at (" transactions" ).as_array ().size (), 2 );
836+ });
837+ }
838+
839+ TEST_F (RPCAccountTxHandlerTest, LimitAllowedUpToCap)
840+ {
841+ backend->setRange (MINSEQ, MAXSEQ);
842+
843+ auto const transactions = genTransactions (MINSEQ + 1 , MAXSEQ - 1 );
844+ auto const transCursor = TransactionsAndCursor{transactions, TransactionsCursor{12 , 34 }};
845+ EXPECT_CALL (*backend, fetchAccountTransactions (testing::_, testing::_, false , testing::_, testing::_))
846+ .WillOnce (Return (transCursor));
847+
848+ runSpawn ([&, this ](auto yield) {
849+ auto const handler = AnyHandler{AccountTxHandler{backend}};
850+ auto static const input = json::parse (fmt::format (
851+ R"( {{
852+ "account": "{}",
853+ "ledger_index_min": {},
854+ "ledger_index_max": {},
855+ "limit": {},
856+ "forward": false
857+ }})" ,
858+ ACCOUNT,
859+ -1 ,
860+ -1 ,
861+ AccountTxHandler::LIMIT_MAX - 1
862+ ));
863+ auto const output = handler.process (input, Context{yield});
864+ ASSERT_TRUE (output);
865+ EXPECT_EQ (output.result ->at (" account" ).as_string (), ACCOUNT);
866+ EXPECT_EQ (output.result ->at (" ledger_index_min" ).as_uint64 (), MINSEQ);
867+ EXPECT_EQ (output.result ->at (" ledger_index_max" ).as_uint64 (), MAXSEQ);
868+ EXPECT_EQ (output.result ->at (" limit" ).as_uint64 (), AccountTxHandler::LIMIT_MAX - 1 );
869+ EXPECT_EQ (output.result ->at (" transactions" ).as_array ().size (), 2 );
870+ });
871+ }
872+
807873TEST_F (RPCAccountTxHandlerTest, SpecificLedgerIndex)
808874{
809875 backend->setRange (MINSEQ, MAXSEQ);
0 commit comments