| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | test_description="Test ping over WebTransport command" |
| 4 | |
| 5 | . lib/test-lib.sh |
| 6 | |
| 7 | test_init_ipfs |
| 8 | |
| 9 | # start iptb + wait for peering |
| 10 | test_expect_success 'init iptb' ' |
| 11 | iptb testbed create -type localipfs -count 2 -init |
| 12 | ' |
| 13 | |
| 14 | addr1='"[\"/ip4/127.0.0.1/udp/0/quic-v1/webtransport\"]"' |
| 15 | addr2='"[\"/ip4/127.0.0.1/udp/0/quic-v1/webtransport\"]"' |
| 16 | test_expect_success "add WebTransport swarm addresses" ' |
| 17 | ipfsi 0 config --json Addresses.Swarm '$addr1' && |
| 18 | ipfsi 0 config --json Swarm.Transports.Network.WebTransport true && |
| 19 | ipfsi 1 config --json Addresses.Swarm '$addr2' && |
| 20 | ipfsi 1 config --json Swarm.Transports.Network.WebTransport true |
| 21 | ' |
| 22 | |
| 23 | startup_cluster 2 |
| 24 | |
| 25 | test_expect_success 'peer ids' ' |
| 26 | PEERID_0=$(iptb attr get 0 id) && |
| 27 | PEERID_1=$(iptb attr get 1 id) |
| 28 | ' |
| 29 | |
| 30 | test_expect_success "test ping other" ' |
| 31 | ipfsi 0 ping -n2 -- "$PEERID_1" && |
| 32 | ipfsi 1 ping -n2 -- "$PEERID_0" |
| 33 | ' |
| 34 | |
| 35 | test_expect_success "test ping self" ' |
| 36 | test_must_fail ipfsi 0 ping -n2 -- "$PEERID_0" && |
| 37 | test_must_fail ipfsi 1 ping -n2 -- "$PEERID_1" |
| 38 | ' |
| 39 | |
| 40 | test_expect_success "test ping 0" ' |
| 41 | test_must_fail ipfsi 0 ping -n0 -- "$PEERID_1" && |
| 42 | test_must_fail ipfsi 1 ping -n0 -- "$PEERID_0" |
| 43 | ' |
| 44 | |
| 45 | test_expect_success 'stop iptb' ' |
| 46 | iptb stop |
| 47 | ' |
| 48 | |
| 49 | test_done |