Skip to content

Commit

Permalink
pubsub sharness tests after chriscool feedback
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jan Winkelmann <[email protected]>
  • Loading branch information
keks committed Nov 30, 2016
1 parent 1ce4920 commit b1c7f86
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
8 changes: 5 additions & 3 deletions test/sharness/lib/iptb-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ check_has_connection() {

startup_cluster() {
num_nodes="$1"
shift
other_args="$@"
bound=$(expr "$num_nodes" - 1)

if [ "$2" = "--enable-pubsub-experiment" ]; then
test_expect_success "start up nodes with pubsub enabled" '
iptb start --args --enable-pubsub-experiment
if test -n "$other_args"; then
test_expect_success "start up nodes with additional args" '
iptb start --args $other_args
'
else
test_expect_success "start up nodes" '
Expand Down
23 changes: 12 additions & 11 deletions test/sharness/t0180-pubsub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,26 @@ test_expect_success 'peer ids' '
# ipfs pubsub sub
test_expect_success 'pubsub' '
echo "testOK" > expected &&
mkfifo done &&
mkfifo wait &&
# ipfs pubsub sub is long-running so we need to start it in the background and
# wait put its output somewhere where we can access it
(
ipfsi 0 pubsub sub --enc=ndpayload testTopic |
while read line; do
ipfsi 0 pubsub sub --enc=ndpayload testTopic | if read line; then
echo $line > actual &&
echo > done
exit
done
echo > wait
fi
) &
ipfspid=$!
sleep 1
# wait until ipfs pubsub sub is ready to do work
sleep 1 &&
# publish something
ipfsi 1 pubsub pub testTopic "testOK" &> pubErr1 &&
cat done &&
test_cmp actual expected
# wait until `echo > wait` executed
cat wait &&
test_cmp expected actual
'

test_expect_success 'stop iptb' '
Expand Down

0 comments on commit b1c7f86

Please sign in to comment.