@@ -540,6 +540,46 @@ public void testMaxMessageSizePureNumber() {
540540 Args .clearParam ();
541541 }
542542
543+ @ Test
544+ public void testMaxMessageSizeNegativeValueRejected () {
545+ // Negative maxMessageSize must be rejected at startup which threw TronError(PARAMETER_INIT)
546+ // for negative values).
547+ for (String key : new String []{
548+ "node.rpc.maxMessageSize" , "node.http.maxMessageSize" , "node.jsonrpc.maxMessageSize" }) {
549+ Map <String , String > configMap = new HashMap <>();
550+ configMap .put ("storage.db.directory" , "database" );
551+ configMap .put (key , "-1" );
552+ Config config = ConfigFactory .defaultOverrides ()
553+ .withFallback (ConfigFactory .parseMap (configMap ))
554+ .withFallback (ConfigFactory .defaultReference ());
555+ try {
556+ Args .applyConfigParams (config );
557+ Assert .fail ("Expected TronError for negative " + key );
558+ } catch (TronError e ) {
559+ Assert .assertEquals (TronError .ErrCode .PARAMETER_INIT , e .getErrCode ());
560+ }
561+ Args .clearParam ();
562+ }
563+ }
564+
565+ @ Test
566+ public void testRpcMaxMessageSizeExceedsIntMax () {
567+ // HOCON's Config.getInt() throws when a numeric value exceeds int range.
568+ // This documents the failure mode for node.rpc.maxMessageSize (int field).
569+ Map <String , Object > configMap = new HashMap <>();
570+ configMap .put ("storage.db.directory" , "database" );
571+ configMap .put ("node.rpc.maxMessageSize" , (long ) Integer .MAX_VALUE + 1 );
572+ Config config = ConfigFactory .defaultOverrides ()
573+ .withFallback (ConfigFactory .parseMap (configMap ))
574+ .withFallback (ConfigFactory .defaultReference ());
575+ try {
576+ Args .applyConfigParams (config );
577+ Assert .fail ("Expected RuntimeException for maxMessageSize > Integer.MAX_VALUE" );
578+ } catch (RuntimeException e ) {
579+ // ConfigBeanFactory/HOCON throws when binding a long out of int range
580+ }
581+ }
582+
543583 // ===== checkBackupMembers() tests =====
544584
545585 @ Test
0 commit comments