Add a test for ENR to ENode conversion

This commit is contained in:
Zahary Karadjov 2020-02-06 16:35:51 +01:00 committed by zah
parent ee7c2c9dff
commit 94a0efd7f3
2 changed files with 12 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import # Unit test
./test_beacon_node,
./test_beaconstate,
./test_block_pool,
./test_discovery_helpers,
./test_helpers,
./test_interop,
./test_kvstore,

View File

@ -1,6 +1,6 @@
import
net, unittest, testutil,
eth/p2p/enode, libp2p/multiaddress,
eth/keys, eth/p2p/enode, libp2p/multiaddress,
../beacon_chain/eth2_discovery
suite "Discovery v5 utilities":
@ -15,3 +15,13 @@ suite "Discovery v5 utilities":
$enode.value.address.ip == "178.128.140.61"
enode.value.toMultiAddressStr == addrStr
timedTest "ENR to ENode":
let enr = "enr:-Iu4QPONEndy6aWOJLWBaCLS1KRg7YPeK0qptnxJzuBW8OcFP9tLgA_ewmAvHBzn9zPG6XIgdH83Mq_5cyLF5yWRYmYBgmlkgnY0gmlwhDaZ6cGJc2VjcDI1NmsxoQK-9tWOso2Kco7L5L-zKoj-MwPfeBbEP12bxr9bqzwZV4N0Y3CCIyiDdWRwgiMo"
let enrParsed = parseBootstrapAddress(enr)
check:
enrParsed.isOk
$enrParsed.value.address.ip == "193.233.153.54"
enrParsed.value.address.tcpPort == Port(9000)
$enrParsed.value.pubkey == "bef6d58eb28d8a728ecbe4bfb32a88fe3303df7816c43f5d9bc6bf5bab3c19571012d3dd5ab492b1b0d2b42e32ce32f6bafc1075dbaaabe1fa6be711be7a992a"