summary refs log tree commit diff stats
path: root/tests/arc/torcmisc.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/arc/torcmisc.nim')
-rw-r--r--tests/arc/torcmisc.nim32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/arc/torcmisc.nim b/tests/arc/torcmisc.nim
index 20dd18fb3..e41ad7c77 100644
--- a/tests/arc/torcmisc.nim
+++ b/tests/arc/torcmisc.nim
@@ -32,3 +32,35 @@ when true:
   waitFor hello(Flags())
   echo "success"
 
+# bug #18240
+import tables
+
+type
+  TopicHandler* = proc(topic: string,
+                       data: seq[byte]): Future[void] {.gcsafe, raises: [Defect].}
+
+  PeerID* = object
+    data*: seq[byte]
+
+  PeerInfo* = ref object of RootObj
+    peerId*: PeerID
+
+  Connection* = ref object of RootObj
+    peerInfo*: PeerInfo
+
+  PubSubPeer* = ref object of RootObj
+    codec*: string
+
+  PubSub* = ref object of RootObj
+    topics*: Table[string, seq[TopicHandler]]
+    peers*: Table[PeerID, PubSubPeer]
+
+proc getOrCreatePeer*(myParam: PubSub, peerId: PeerID, protos: seq[string]): PubSubPeer =
+  myParam.peers.withValue(peerId, peer):
+    return peer[]
+
+method handleConn*(myParam: PubSub,
+                  conn: Connection,
+                  proto: string) {.base, async.} =
+  myParam.peers.withValue(conn.peerInfo.peerId, peer):
+    let peerB = peer[]