| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | test_description="Test ping over QUIC 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\"]"' |
| 15 | addr2='"[\"/ip4/127.0.0.1/udp/0/quic-v1\"]"' |
| 16 | test_expect_success "add QUIC swarm addresses" ' |
| 17 | ipfsi 0 config --json Addresses.Swarm '$addr1' && |
| 18 | ipfsi 1 config --json Addresses.Swarm '$addr2' |
| 19 | ' |
| 20 | |
| 21 | startup_cluster 2 |
| 22 | |
| 23 | test_expect_success 'peer ids' ' |
| 24 | PEERID_0=$(iptb attr get 0 id) && |
| 25 | PEERID_1=$(iptb attr get 1 id) |
| 26 | ' |
| 27 | |
| 28 | test_expect_success "test ping other" ' |
| 29 | ipfsi 0 ping -n2 -- "$PEERID_1" && |
| 30 | ipfsi 1 ping -n2 -- "$PEERID_0" |
| 31 | ' |
| 32 | |
| 33 | test_expect_success "test ping self" ' |
| 34 | test_must_fail ipfsi 0 ping -n2 -- "$PEERID_0" && |
| 35 | test_must_fail ipfsi 1 ping -n2 -- "$PEERID_1" |
| 36 | ' |
| 37 | |
| 38 | test_expect_success "test ping 0" ' |
| 39 | test_must_fail ipfsi 0 ping -n0 -- "$PEERID_1" && |
| 40 | test_must_fail ipfsi 1 ping -n0 -- "$PEERID_0" |
| 41 | ' |
| 42 | |
| 43 | test_expect_success 'stop iptb' ' |
| 44 | iptb stop |
| 45 | ' |
| 46 | |
| 47 | test_done |