Skip to content

Commit

Permalink
change to void on isValid HexValueValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
casiojapi committed Jul 27, 2023
1 parent 8a6f9fb commit aa6e1bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aa6e1bd

Please sign in to comment.