@@ -1328,6 +1328,35 @@ public void testLogFilterTagHandling() {
13281328 }
13291329 }
13301330
1331+ @ Test
1332+ public void testGetFilterLogsEnforcesBlockRange () throws Exception {
1333+ int oldMaxBlockRange = Args .getInstance ().getJsonRpcMaxBlockRange ();
1334+ Args .getInstance ().setJsonRpcMaxBlockRange (5_000 );
1335+ try {
1336+ // toBlock=0xf4240 (1_000_000) is clamped to head (LATEST_BLOCK_NUM = 10_000), so the span
1337+ // is min(1_000_000, 10_000) - 0 = 10_000 > 5_000 cap.
1338+ String wideFilterId = tronJsonRpc .newFilter (
1339+ new FilterRequest ("0x0" , "0xf4240" , null , null , null ));
1340+ Assert .assertNotNull (wideFilterId );
1341+
1342+ // eth_getFilterLogs must reject it at query time (previously bypassed -> unbounded scan).
1343+ JsonRpcInvalidParamsException ex = Assert .assertThrows (
1344+ JsonRpcInvalidParamsException .class ,
1345+ () -> tronJsonRpc .getFilterLogs (wideFilterId ));
1346+ Assert .assertEquals ("exceed max block range: 5000" , ex .getMessage ());
1347+
1348+ // A within-cap filter (span 0) is still served normally - no false rejection.
1349+ String headHex = ByteArray .toJsonHex (blockCapsule1 .getNum ());
1350+ int expectedLogs = blockCapsule1 .getTransactions ().size () * 2 ;
1351+ String okFilterId = tronJsonRpc .newFilter (
1352+ new FilterRequest (headHex , headHex , null , null , null ));
1353+ LogFilterElement [] okResult = tronJsonRpc .getFilterLogs (okFilterId );
1354+ Assert .assertEquals (expectedLogs , okResult .length );
1355+ } finally {
1356+ Args .getInstance ().setJsonRpcMaxBlockRange (oldMaxBlockRange );
1357+ }
1358+ }
1359+
13311360 @ Test
13321361 public void testGetBlockReceipts () {
13331362
0 commit comments