Skip to content

Commit

Permalink
chore: remove waku swap protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo Delgado committed Mar 31, 2023
1 parent 67fa736 commit 2b5fd2a
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 621 deletions.
8 changes: 0 additions & 8 deletions tests/all_tests_v2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,3 @@ when defined(rln):
./v2/waku_rln_relay/test_wakunode_rln_relay,
./v2/waku_rln_relay/test_rln_group_manager_onchain,
./v2/waku_rln_relay/test_rln_group_manager_static

# Waku swap test suite
import
./v2/test_waku_swap

# TODO: Only enable this once swap module is integrated more nicely as a dependency, i.e. as submodule with CI etc
# For PoC execute it manually and run separate module here: https://github.com/vacp2p/swap-contracts-module
# import ./v2/test_waku_swap_contracts
11 changes: 1 addition & 10 deletions tests/v2/test_peer_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import
../../waku/v2/protocol/waku_filter,
../../waku/v2/protocol/waku_lightpush,
../../waku/v2/protocol/waku_peer_exchange,
../../waku/v2/protocol/waku_swap/waku_swap,
./testlib/common,
./testlib/testutils,
./testlib/waku2
Expand Down Expand Up @@ -97,32 +96,24 @@ procSuite "Peer Manager":
# Create filter peer
filterLoc = MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet()
filterPeer = PeerInfo.new(generateEcdsaKey(), @[filterLoc])
# Create swap peer
swapLoc = MultiAddress.init("/ip4/127.0.0.2/tcp/2").tryGet()
swapPeer = PeerInfo.new(generateEcdsaKey(), @[swapLoc])
# Create store peer
storeLoc = MultiAddress.init("/ip4/127.0.0.3/tcp/4").tryGet()
storePeer = PeerInfo.new(generateEcdsaKey(), @[storeLoc])

await node.start()

await node.mountFilterClient()
await node.mountSwap()
node.mountStoreClient()

node.peerManager.addServicePeer(swapPeer.toRemotePeerInfo(), WakuSwapCodec)
node.peerManager.addServicePeer(storePeer.toRemotePeerInfo(), WakuStoreCodec)
node.peerManager.addServicePeer(filterPeer.toRemotePeerInfo(), WakuFilterCodec)

# Check peers were successfully added to peer manager
check:
node.peerManager.peerStore.peers().len == 3
node.peerManager.peerStore.peers().len == 2
node.peerManager.peerStore.peers(WakuFilterCodec).allIt(it.peerId == filterPeer.peerId and
it.addrs.contains(filterLoc) and
it.protocols.contains(WakuFilterCodec))
node.peerManager.peerStore.peers(WakuSwapCodec).allIt(it.peerId == swapPeer.peerId and
it.addrs.contains(swapLoc) and
it.protocols.contains(WakuSwapCodec))
node.peerManager.peerStore.peers(WakuStoreCodec).allIt(it.peerId == storePeer.peerId and
it.addrs.contains(storeLoc) and
it.protocols.contains(WakuStoreCodec))
Expand Down
44 changes: 0 additions & 44 deletions tests/v2/test_waku_swap.nim

This file was deleted.

78 changes: 0 additions & 78 deletions tests/v2/test_waku_swap_contracts.nim

This file was deleted.

1 change: 0 additions & 1 deletion tests/v2/wakunode_jsonrpc/test_jsonrpc_admin.nim
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ procSuite "Waku v2 JSON-RPC API - Admin":

await node.mountFilter()
await node.mountFilterClient()
await node.mountSwap()
let driver: ArchiveDriver = QueueDriver.new()
node.mountArchive(some(driver), none(MessageValidator), none(RetentionPolicy))
await node.mountStore()
Expand Down
17 changes: 0 additions & 17 deletions waku/v2/node/waku_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import
../protocol/waku_archive,
../protocol/waku_store,
../protocol/waku_store/client as store_client,
../protocol/waku_swap/waku_swap,
../protocol/waku_filter,
../protocol/waku_filter/client as filter_client,
../protocol/waku_lightpush,
Expand Down Expand Up @@ -90,7 +89,6 @@ type
wakuStoreClient*: WakuStoreClient
wakuFilter*: WakuFilter
wakuFilterClient*: WakuFilterClient
wakuSwap*: WakuSwap
when defined(rln):
wakuRlnRelay*: WakuRLNRelay
wakuLightPush*: WakuLightPush
Expand Down Expand Up @@ -651,21 +649,6 @@ proc unsubscribe*(node: WakuNode, pubsubTopic: PubsubTopic, contentTopics: Conte
await node.filterUnsubscribe(pubsubTopic, contentTopics, peer=peerOpt.get())


## Waku swap

# NOTE: If using the swap protocol, it must be mounted before store. This is
# because store is using a reference to the swap protocol.
proc mountSwap*(node: WakuNode, swapConfig: SwapConfig = SwapConfig.init()) {.async, raises: [Defect, LPError].} =
info "mounting swap", mode = $swapConfig.mode

node.wakuSwap = WakuSwap.init(node.peerManager, node.rng, swapConfig)
if node.started:
# Node has started already. Let's start swap too.
await node.wakuSwap.start()

node.switch.mount(node.wakuSwap, protocolMatcher(WakuSwapCodec))


## Waku archive

proc mountArchive*(node: WakuNode,
Expand Down

0 comments on commit 2b5fd2a

Please sign in to comment.