Fix & test shortAgent
This commit is contained in:
parent
0d6c60df05
commit
15a107a368
|
@ -75,7 +75,9 @@ when defined(libp2p_agents_metrics):
|
|||
if p.sendConn.isNil:
|
||||
"unknown"
|
||||
else:
|
||||
p.sendConn.shortAgent
|
||||
#TODO the sendConn is setup before identify,
|
||||
#so we have to read the parents short agent..
|
||||
p.sendConn.getWrapped().shortAgent
|
||||
|
||||
func hash*(p: PubSubPeer): Hash =
|
||||
p.peerId.hash
|
||||
|
|
|
@ -57,5 +57,5 @@ when defined(libp2p_agents_metrics):
|
|||
err("toLowerAscii failed")
|
||||
|
||||
const
|
||||
KnownLibP2PAgents* {.strdefine.} = ""
|
||||
KnownLibP2PAgents* {.strdefine.} = "nim-libp2p"
|
||||
KnownLibP2PAgentsSeq* = KnownLibP2PAgents.safeToLowerAscii().tryGet().split(",")
|
||||
|
|
|
@ -19,7 +19,9 @@ import utils,
|
|||
protocols/pubsub/pubsub,
|
||||
protocols/pubsub/floodsub,
|
||||
protocols/pubsub/rpc/messages,
|
||||
protocols/pubsub/peertable]
|
||||
protocols/pubsub/peertable,
|
||||
protocols/pubsub/pubsubpeer
|
||||
]
|
||||
import ../../libp2p/protocols/pubsub/errors as pubsub_errors
|
||||
|
||||
import ../helpers
|
||||
|
@ -62,6 +64,14 @@ suite "FloodSub":
|
|||
check (await nodes[0].publish("foobar", "Hello!".toBytes())) > 0
|
||||
check (await completionFut.wait(5.seconds)) == true
|
||||
|
||||
when defined(libp2p_agents_metrics):
|
||||
let
|
||||
agentA = nodes[0].peers[nodes[1].switch.peerInfo.peerId].shortAgent
|
||||
agentB = nodes[1].peers[nodes[0].switch.peerInfo.peerId].shortAgent
|
||||
check:
|
||||
agentA == "nim-libp2p"
|
||||
agentB == "nim-libp2p"
|
||||
|
||||
await allFuturesThrowing(
|
||||
nodes[0].switch.stop(),
|
||||
nodes[1].switch.stop()
|
||||
|
|
Loading…
Reference in New Issue