diff --git a/rskj-core/src/main/java/co/rsk/config/RskSystemProperties.java b/rskj-core/src/main/java/co/rsk/config/RskSystemProperties.java index b833baee99e..c1dde0b6d68 100644 --- a/rskj-core/src/main/java/co/rsk/config/RskSystemProperties.java +++ b/rskj-core/src/main/java/co/rsk/config/RskSystemProperties.java @@ -189,10 +189,10 @@ public boolean isWalletEnabled() { public double gasPriceMultiplier() { double gasPriceMultiplier = getDouble(RPC_GAS_PRICE_MULTIPLIER_CONFIG, 1.1); - if(gasPriceMultiplier > 1.0) { + if(gasPriceMultiplier >= 0) { return gasPriceMultiplier; } else { - throw new RskConfigurationException(RPC_GAS_PRICE_MULTIPLIER_CONFIG + " must be greater than 1.0"); + throw new RskConfigurationException(RPC_GAS_PRICE_MULTIPLIER_CONFIG + " cannot be a negative number"); } } diff --git a/rskj-core/src/test/java/co/rsk/config/RskSystemPropertiesTest.java b/rskj-core/src/test/java/co/rsk/config/RskSystemPropertiesTest.java index b3ab7ba1fc1..f38c0334cd4 100644 --- a/rskj-core/src/test/java/co/rsk/config/RskSystemPropertiesTest.java +++ b/rskj-core/src/test/java/co/rsk/config/RskSystemPropertiesTest.java @@ -243,7 +243,7 @@ void testGasPriceMultiplierWithNull() { } @Test - void testGasPriceMultiplierThrowsError() { + void testGasPriceMultiplierThrowsErrorForInvalidType() { TestSystemProperties testSystemProperties = new TestSystemProperties(rawConfig -> ConfigFactory.parseString("{" + "rpc.gasPriceMultiplier = invalid" + @@ -251,4 +251,14 @@ void testGasPriceMultiplierThrowsError() { Assertions.assertThrows(ConfigException.WrongType.class, testSystemProperties::gasPriceMultiplier); } + + @Test + void testGasPriceMultiplierThrowsErrorForNegativeValue() { + TestSystemProperties testSystemProperties = new TestSystemProperties(rawConfig -> + ConfigFactory.parseString("{" + + "rpc.gasPriceMultiplier = -1" + + " }").withFallback(rawConfig)); + + Assertions.assertThrows(RskConfigurationException.class, testSystemProperties::gasPriceMultiplier); + } }