Included tests for EthAddressStr

This commit is contained in:
coffeepots 2018-08-13 17:34:14 +01:00
parent e4d1c6817a
commit 6aab8b05c5
1 changed files with 25 additions and 0 deletions

View File

@ -97,3 +97,28 @@ proc doHexStrTests* =
source = "0x0123"
x = hexDataStr source
check %x == %source
suite "[RPC] Eth address strings":
test "Valid address":
let
e = "0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
e_addr = e.ethAddressStr
check e == e_addr.string
let
short_e = "0x0f572e5295c57f"
short_e_addr = short_e.ethAddressStr
check short_e == short_e_addr.string
test "Too long":
expect ValueError:
let
# too long
e = "0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec66"
e_addr = e.ethAddressStr
check e == e_addr.string
test "Wrong format":
expect ValueError:
let
# too long
e = "000f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
e_addr = e.ethAddressStr
check e == e_addr.string