2018-11-29 23:06:40 +08:00
|
|
|
import multiaddr
|
2019-01-10 02:38:56 +08:00
|
|
|
|
|
|
|
from libp2p.peer.peerinfo import info_from_p2p_addr
|
2018-11-29 23:06:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
def test_info_from_p2p_addr():
|
|
|
|
# pylint: disable=line-too-long
|
2018-12-28 14:56:00 +08:00
|
|
|
m_addr = multiaddr.Multiaddr('/ip4/127.0.0.1/tcp/8000/p2p/3YgLAeMKSAPcGqZkAt8mREqhQXmJT8SN8VCMN4T6ih4GNX9wvK8mWJnWZ1qA2mLdCQ')
|
2018-11-29 23:06:40 +08:00
|
|
|
info = info_from_p2p_addr(m_addr)
|
|
|
|
assert info.peer_id.pretty() == '3YgLAeMKSAPcGqZkAt8mREqhQXmJT8SN8VCMN4T6ih4GNX9wvK8mWJnWZ1qA2mLdCQ'
|
|
|
|
assert len(info.addrs) == 1
|
|
|
|
assert str(info.addrs[0]) == '/ip4/127.0.0.1/tcp/8000'
|