diff --git a/tests/test_json_marshalling.nim b/tests/test_json_marshalling.nim index d4145e9..998c1db 100644 --- a/tests/test_json_marshalling.nim +++ b/tests/test_json_marshalling.nim @@ -194,3 +194,18 @@ suite "JSON-RPC Quantity": let c = JrpcConv.decode(x, RtBlockIdentifier) check c.kind == bidNumber check c.number == 77 + + let d = JrpcConv.decode("\"10\"", RtBlockIdentifier) + check d.kind == bidAlias + check d.alias == "10" + + expect JsonReaderError: + let d = JrpcConv.decode("10", RtBlockIdentifier) + discard d + + test "check address or list": + let a = AddressOrList(kind: slkNull) + let x = JrpcConv.encode(a) + let c = JrpcConv.decode(x, AddressOrList) + check c.kind == slkNull + diff --git a/web3/conversions.nim b/web3/conversions.nim index 5cf999b..8677e44 100644 --- a/web3/conversions.nim +++ b/web3/conversions.nim @@ -154,6 +154,10 @@ func valid(hex: string): bool = if hex.len >= 2: if hex[0] == '0' and hex[1] in {'x', 'X'}: start = 2 + else: + return false + else: + return false for i in start..