@@ -769,14 +769,13 @@ TEST_F(RPCAccountTxHandlerTest, LimitAndMarker)
769
769
770
770
auto const transactions = genTransactions (MINSEQ + 1 , MAXSEQ - 1 );
771
771
auto const transCursor = TransactionsAndCursor{transactions, TransactionsCursor{12 , 34 }};
772
- ON_CALL (*backend, fetchAccountTransactions).WillByDefault (Return (transCursor));
773
772
EXPECT_CALL (
774
773
*backend,
775
774
fetchAccountTransactions (
776
775
testing::_, testing::_, false , testing::Optional (testing::Eq (TransactionsCursor{10 , 11 })), testing::_
777
776
)
778
777
)
779
- .Times ( 1 );
778
+ .WillOnce ( Return (transCursor) );
780
779
781
780
runSpawn ([&, this ](auto yield) {
782
781
auto const handler = AnyHandler{AccountTxHandler{backend}};
@@ -804,6 +803,73 @@ TEST_F(RPCAccountTxHandlerTest, LimitAndMarker)
804
803
});
805
804
}
806
805
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
+
807
873
TEST_F (RPCAccountTxHandlerTest, SpecificLedgerIndex)
808
874
{
809
875
backend->setRange (MINSEQ, MAXSEQ);
0 commit comments