Skip to content

Commit

Permalink
update sharness
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Nov 14, 2021
1 parent b8dc042 commit 9e27b76
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions test/sharness/t0182-circuit-relay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,23 @@ test_expect_success 'start up nodes for configuration' '
iptb start -wait -- --routing=none
'

test_expect_success 'set ForceReachability to public relay node' '
test_expect_success 'peer ids' '
PEERID_0=$(iptb attr get 0 id) &&
PEERID_1=$(iptb attr get 1 id) &&
PEERID_2=$(iptb attr get 2 id)
'

relayaddrs=$(ipfsi 1 swarm addrs local | jq --raw-input . | jq --slurp .)
staticrelay=$(ipfsi 1 swarm addrs local | sed -e "s|$|/p2p/$PEERID_1|g" | jq --raw-input . | jq --slurp .)

test_expect_success 'configure the relay node as a static relay for node A' '
ipfsi 0 config Internal.Libp2pForceReachability private &&
ipfsi 0 config --json Swarm.EnableAutoRelay true &&
ipfsi 0 config --json Swarm.StaticRelays "$staticrelay"
'

test_expect_success 'configure the relay node' '
ipfsi 1 config --json Addresses.Swarm "$relayaddrs" &&
ipfsi 1 config Internal.Libp2pForceReachability public
'

Expand All @@ -29,10 +45,6 @@ test_expect_success 'connect A <-> Relay' '
iptb connect 0 1
'

test_expect_success 'wait until A gets a reservation' '
sleep 1
'

test_expect_success 'connect B <-> Relay' '
iptb connect 2 1
'
Expand All @@ -41,18 +53,12 @@ test_expect_success 'wait until relay is ready to do work' '
sleep 1
'

test_expect_success 'peer ids' '
PEERID_0=$(iptb attr get 0 id) &&
PEERID_1=$(iptb attr get 1 id) &&
PEERID_2=$(iptb attr get 2 id)
'

test_expect_success 'connect A <-Relay-> B' '
ipfsi 0 swarm connect /p2p/$PEERID_1/p2p-circuit/p2p/$PEERID_2 > peers_out
ipfsi 2 swarm connect /p2p/$PEERID_1/p2p-circuit/p2p/$PEERID_0 > peers_out
'

test_expect_success 'output looks good' '
echo "connect $PEERID_2 success" > peers_exp &&
echo "connect $PEERID_0 success" > peers_exp &&
test_cmp peers_exp peers_out
'

Expand All @@ -66,23 +72,6 @@ test_expect_success 'peers for B look good' '
test_should_contain "/p2p/$PEERID_1/p2p-circuit/p2p/$PEERID_0$" peers_out
'

test_expect_success 'add an object in A' '
echo "hello relay" | ipfsi 0 add > peers_out
'

test_expect_success 'object ID' '
OBJID=$(cut -f3 -d " " peers_out)
'

test_expect_success 'cat the object in B' '
ipfsi 2 cat $OBJID > peers_out
'

test_expect_success 'output looks good' '
echo "hello relay" > peers_exp &&
test_cmp peers_exp peers_out
'

test_expect_success 'stop iptb' '
iptb stop
'
Expand Down

0 comments on commit 9e27b76

Please sign in to comment.