Got fix for #8 in go-libp2p-pubsub.

Enable full test.
This commit is contained in:
cheatfate 2018-12-14 11:00:49 +02:00
parent 0b807e7ee5
commit 9c2b8591d4
1 changed files with 12 additions and 14 deletions

View File

@ -48,16 +48,16 @@ proc provideBadCidTest(): Future[bool] {.async.} =
finally:
await api.close()
proc getOnlyOneIPv4Address(addresses: seq[MultiAddress]): seq[MultiAddress] =
## We doing this becuase of bug in `go-pubsub`
## https://github.com/libp2p/go-libp2p-pubsub/issues/130
if len(addresses) > 0:
result = newSeqOfCap[MultiAddress](len(addresses))
let ip4 = multiCodec("ip4")
for item in addresses:
if item.protoCode() == ip4:
result.add(item)
break
# proc getOnlyOneIPv4Address(addresses: seq[MultiAddress]): seq[MultiAddress] =
# ## We doing this becuase of bug in `go-pubsub`
# ## https://github.com/libp2p/go-libp2p-pubsub/issues/130
# if len(addresses) > 0:
# result = newSeqOfCap[MultiAddress](len(addresses))
# let ip4 = multiCodec("ip4")
# for item in addresses:
# if item.protoCode() == ip4:
# result.add(item)
# break
proc pubsubTest(f: set[P2PDaemonFlags]): Future[bool] {.async.} =
var pubsubData = "TEST MESSAGE"
@ -95,10 +95,8 @@ proc pubsubTest(f: set[P2PDaemonFlags]): Future[bool] {.async.} =
# Callback must return `false` to close subscription channel.
result = false
# Not subscribed to any topics everything must be 0.
# We are making only one connection, because of bug
# https://github.com/libp2p/go-libp2p-pubsub/issues/130
await api1.connect(id2.peer, getOnlyOneIPv4Address(id2.addresses))
await api1.connect(id2.peer, id2.addresses)
await api2.connect(id1.peer, id1.addresses)
var ticket1 = await api1.pubsubSubscribe("test-topic", pubsubHandler1)
var ticket2 = await api2.pubsubSubscribe("test-topic", pubsubHandler2)