Skip to content

Commit

Permalink
Update config value range check
Browse files Browse the repository at this point in the history
  • Loading branch information
rmoreliovlabs committed Jan 29, 2024
1 parent 65dd358 commit dafb20a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,22 @@ void testGasPriceMultiplierWithNull() {
}

@Test
void testGasPriceMultiplierThrowsError() {
void testGasPriceMultiplierThrowsErrorForInvalidType() {
TestSystemProperties testSystemProperties = new TestSystemProperties(rawConfig ->
ConfigFactory.parseString("{" +
"rpc.gasPriceMultiplier = invalid" +
" }").withFallback(rawConfig));

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);
}
}

0 comments on commit dafb20a

Please sign in to comment.