diff --git a/tests/v2/standard_setup.nim b/tests/v2/standard_setup.nim index b227c58a5..aaef9868c 100644 --- a/tests/v2/standard_setup.nim +++ b/tests/v2/standard_setup.nim @@ -3,7 +3,7 @@ const libp2p_secure {.strdefine.} = "" import - options, tables, + options, tables, chronicles, libp2p/[switch, peer, peerinfo, connection, multiaddress, crypto/crypto], libp2p/transports/[transport, tcptransport], libp2p/muxers/[muxer, mplex/mplex, mplex/types], @@ -42,7 +42,7 @@ proc newStandardSwitch*(privKey = none(PrivateKey), else: # Creating switch from generate node # XXX: Hacky test, hijacking WakuSub here - echo "Using WakuSub here" + debug "Using WakuSub here" #PubSub newPubSub(FloodSub, peerInfo, triggerSelf) PubSub newPubSub(WakuSub, peerInfo, triggerSelf) diff --git a/tests/v2/test_waku.nim b/tests/v2/test_waku.nim index 3f5f28d9e..59bfe5817 100644 --- a/tests/v2/test_waku.nim +++ b/tests/v2/test_waku.nim @@ -7,8 +7,8 @@ # Apache License, version 2.0, (LICENSE-APACHEv2) # MIT license (LICENSE-MIT) -import unittest, sequtils, options, tables, sets -import chronos +import unittest, options, tables, sets +import chronos, chronicles import utils, libp2p/[errors, switch, @@ -29,7 +29,6 @@ proc waitSub(sender, receiver: auto; key: string) {.async, gcsafe.} = # turn things deterministic # this is for testing purposes only var ceil = 15 - #echo "isa thing", repr(sender.pubSub.get()) let fsub = cast[WakuSub](sender.pubSub.get()) while not fsub.floodsub.hasKey(key) or not fsub.floodsub[key].contains(receiver.peerInfo.id): @@ -56,7 +55,7 @@ suite "FloodSub": proc runTests(): Future[bool] {.async.} = var completionFut = newFuture[bool]() proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} = - echo "Hit handler", topic + debug "Hit handler", topic check topic == "foobar" completionFut.complete(true) diff --git a/waku/protocol/v2/waku_protocol.nim b/waku/protocol/v2/waku_protocol.nim index 96f122dc4..f05929b0e 100644 --- a/waku/protocol/v2/waku_protocol.nim +++ b/waku/protocol/v2/waku_protocol.nim @@ -3,13 +3,12 @@ ## This file should eventually correspond to waku_protocol as RLPx subprotocol. ## Instead, it should likely be on top of GossipSub with a similar interface. -import unittest -import sequtils, tables, options, sets, strutils +import strutils import chronos, chronicles import libp2p/protocols/pubsub/pubsub, libp2p/protocols/pubsub/pubsubpeer, libp2p/protocols/pubsub/floodsub, - libp2p/protocols/pubsub/rpc/[messages, message], + libp2p/protocols/pubsub/rpc/[messages], libp2p/connection logScope: @@ -20,8 +19,6 @@ const WakuSubCodec* = "/wakusub/0.0.1" #const wakuVersionStr = "2.0.0-alpha1" -# So this should already have floodsub table, seen, as well as peerinfo, topics, peers, etc -# How do we verify that in nim? type WakuSub* = ref object of FloodSub # XXX: just playing @@ -35,24 +32,17 @@ method init(w: WakuSub) = ## e.g. ``/wakusub/0.0.1``, etc... ## - echo "Incoming WakuSub connection" - assert(w of FloodSub) - echo "asserted w of floodsub" - assert(w of PubSub) - echo "asserted w of pubsub" - # Defer to parent object (I think) - # This isn't hit, possibly cause double link here? + debug "Incoming WakuSub connection" await w.handleConn(conn, proto) # XXX: Handler hijack FloodSub here? w.handler = handler w.codec = WakuSubCodec -# method initPubSub*(w: WakuSub) = debug "initWakuSub" w.text = "Foobar" - echo "w.text", w.text + debug "w.text", text = w.text # XXX procCall FloodSub(w).initPubSub() w.init() @@ -65,7 +55,7 @@ method subscribeTopic*(w: WakuSub, procCall FloodSub(w).subscribeTopic(topic, subscribe, peerId) method handleDisconnect*(w: WakuSub, peer: PubSubPeer) {.async.} = - debug "handleDisconnect NYI" + debug "handleDisconnect (NYI)" method rpcHandler*(w: WakuSub, peer: PubSubPeer,