p2p: tests for report-peer-id
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Nov 13, 2018 at 18:28 UTC
d6626a5c529a7c871fc29d6db6dfd6e380eb3882
1 file changed
+43
test/sharness/t0180-p2p.sh
+43
@@ -299,6 +299,49 @@ test_expect_success "'ipfs p2p close' closes by listen addr" '
299
test_must_be_empty actual
300
'
301
302
+# Peer reporting
303
+
304
+test_expect_success 'start p2p listener reporting peer' '
305
+ ipfsi 0 p2p listen /x/p2p-test /ip4/127.0.0.1/tcp/10101 --report-peer-id 2>&1 > listener-stdouterr.log
306
+'
307
+
308
+test_expect_success 'C->S Spawn receiving server' '
309
+ ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 > server.out &
310
+
311
+ test_wait_for_file 30 100ms listener.pid &&
312
+ kill -0 $(cat listener.pid)
313
+'
314
+
315
+test_expect_success 'C->S Setup client side' '
316
+ ipfsi 1 p2p forward /x/p2p-test /ip4/127.0.0.1/tcp/10102 /ipfs/${PEERID_0} 2>&1 > dialer-stdouterr.log
317
+'
318
+
319
+test_expect_success 'C->S Connect and receive data' '
320
+ ma-pipe-unidir send /ip4/127.0.0.1/tcp/10102 < test1.bin
321
+'
322
+
323
+test_expect_success 'C->S Ensure server finished' '
324
+ go-sleep 250ms &&
325
+ test ! -f listener.pid
326
+'
327
+
328
+test_expect_success 'C->S Output looks good' '
329
+ echo ${PEERID_1} > expected &&
330
+ cat test1.bin >> expected &&
331
+ test_cmp server.out expected
332
+'
333
+
334
+test_expect_success 'C->S Close listeners' '
335
+ ipfsi 1 p2p close -p /x/p2p-test &&
336
+ ipfsi 0 p2p close -p /x/p2p-test &&
337
+
338
+ ipfsi 0 p2p ls > actual &&
339
+ test_must_be_empty actual &&
340
+
341
+ ipfsi 1 p2p ls > actual &&
342
+ test_must_be_empty actual
343
+'
344
+
345
test_expect_success "non /x/ scoped protocols are not allowed" '
346
test_must_fail ipfsi 0 p2p listen /its/not/a/x/path /ip4/127.0.0.1/tcp/10101 2> actual &&
347
echo "Error: protocol name must be within '"'"'/x/'"'"' namespace" > expected