From 94a0efd7f3c4da028836a23bfa2bb90498c5b063 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 6 Feb 2020 16:35:51 +0100 Subject: [PATCH] Add a test for ENR to ENode conversion --- tests/all_tests.nim | 1 + tests/test_discovery_helpers.nim | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/all_tests.nim b/tests/all_tests.nim index 3c7c1860c..0766f6936 100644 --- a/tests/all_tests.nim +++ b/tests/all_tests.nim @@ -16,6 +16,7 @@ import # Unit test ./test_beacon_node, ./test_beaconstate, ./test_block_pool, + ./test_discovery_helpers, ./test_helpers, ./test_interop, ./test_kvstore, diff --git a/tests/test_discovery_helpers.nim b/tests/test_discovery_helpers.nim index 6c2ed5b87..4989569ff 100644 --- a/tests/test_discovery_helpers.nim +++ b/tests/test_discovery_helpers.nim @@ -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" +