Skip to content

Commit

Permalink
Got fix for #8 in go-libp2p-pubsub.
Browse files Browse the repository at this point in the history
Enable full test.
  • Loading branch information
cheatfate committed Dec 14, 2018
1 parent 0b807e7 commit 9c2b859
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions tests/testdaemon.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9c2b859

Please sign in to comment.