diff --git a/libp2p/protocols/pubsub/pubsubpeer.nim b/libp2p/protocols/pubsub/pubsubpeer.nim index 5b9c1d596..09d7dff4a 100644 --- a/libp2p/protocols/pubsub/pubsubpeer.nim +++ b/libp2p/protocols/pubsub/pubsubpeer.nim @@ -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 diff --git a/libp2p/utility.nim b/libp2p/utility.nim index dd499b5bb..e4a7ac010 100644 --- a/libp2p/utility.nim +++ b/libp2p/utility.nim @@ -57,5 +57,5 @@ when defined(libp2p_agents_metrics): err("toLowerAscii failed") const - KnownLibP2PAgents* {.strdefine.} = "" + KnownLibP2PAgents* {.strdefine.} = "nim-libp2p" KnownLibP2PAgentsSeq* = KnownLibP2PAgents.safeToLowerAscii().tryGet().split(",") diff --git a/tests/pubsub/testfloodsub.nim b/tests/pubsub/testfloodsub.nim index ecac40554..74c314dcd 100644 --- a/tests/pubsub/testfloodsub.nim +++ b/tests/pubsub/testfloodsub.nim @@ -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()