From aa6e1bd07becb5e1c52972baf4060a6326616169 Mon Sep 17 00:00:00 2001 From: maximo santoro Date: Thu, 27 Jul 2023 19:14:35 -0300 Subject: [PATCH] change to void on isValid HexValueValidator --- .../ethereum/rpc/validation/HexValueValidator.java | 3 +-- .../rpc/validation/HexValueValidatorTest.java | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/rskj-core/src/main/java/org/ethereum/rpc/validation/HexValueValidator.java b/rskj-core/src/main/java/org/ethereum/rpc/validation/HexValueValidator.java index 266b6ff1905..429f53a8257 100644 --- a/rskj-core/src/main/java/org/ethereum/rpc/validation/HexValueValidator.java +++ b/rskj-core/src/main/java/org/ethereum/rpc/validation/HexValueValidator.java @@ -24,10 +24,9 @@ public final class HexValueValidator { private HexValueValidator(){} - public static boolean isValid(String input){ + public static void isValid(String input){ if (!HexUtils.isHexWithPrefix(input)) { throw RskJsonRpcRequestException.invalidParamError("Invalid argument: " + input + ": param should be a hex value string."); } - return true; } } diff --git a/rskj-core/src/test/java/org/ethereum/rpc/validation/HexValueValidatorTest.java b/rskj-core/src/test/java/org/ethereum/rpc/validation/HexValueValidatorTest.java index 9e03381b06c..806a8fc78e1 100644 --- a/rskj-core/src/test/java/org/ethereum/rpc/validation/HexValueValidatorTest.java +++ b/rskj-core/src/test/java/org/ethereum/rpc/validation/HexValueValidatorTest.java @@ -27,12 +27,12 @@ class HexValueValidatorTest { @Test void testValidHexadecimals() { - assertTrue(HexValueValidator.isValid("0x0")); - assertTrue(HexValueValidator.isValid("0x123")); - assertTrue(HexValueValidator.isValid("0xabcdef")); - assertTrue(HexValueValidator.isValid("0x0000000000000000000000000000000001000008")); - assertTrue(HexValueValidator.isValid("0xABCDEF")); // Uppercase are not allowed in Ethereum - assertTrue(HexValueValidator.isValid("0x0123456789")); //Numbers staring by 0x0 is not allowed in Ethereum + assertDoesNotThrow(() -> HexValueValidator.isValid("0x0")); + assertDoesNotThrow(() -> HexValueValidator.isValid("0x123")); + assertDoesNotThrow(() -> HexValueValidator.isValid("0xabcdef")); + assertDoesNotThrow(() -> HexValueValidator.isValid("0x0000000000000000000000000000000001000008")); + assertDoesNotThrow(() -> HexValueValidator.isValid("0xABCDEF")); // Uppercase are not allowed in Ethereum + assertDoesNotThrow(() -> HexValueValidator.isValid("0x0123456789")); //Numbers staring by 0x0 is not allowed in Ethereum } @Test