Skip to content

Commit

Permalink
add sharness test for pubsub
Browse files Browse the repository at this point in the history
  • Loading branch information
keks committed Nov 28, 2016
1 parent 4e8015d commit 53ee3ad
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/sharness/lib/iptb-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ startup_cluster() {
num_nodes="$1"
bound=$(expr "$num_nodes" - 1)

test_expect_success "start up nodes" '
iptb start
'
if [ "$2" = "--enable-pubsub-experiment" ]; then
test_expect_success "start up nodes with pubsub enabled" '
iptb start --args --enable-pubsub-experiment
'
else
test_expect_success "start up nodes" '
iptb start
'
fi

test_expect_success "connect nodes to eachother" '
iptb connect [1-$bound] 0
Expand Down
48 changes: 48 additions & 0 deletions test/sharness/t0180-pubsub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh

test_description="Test dht command"

. lib/test-lib.sh

# start iptb + wait for peering
NUM_NODES=5
test_expect_success 'init iptb' '
iptb init -n $NUM_NODES --bootstrap=none --port=0
'

startup_cluster $NUM_NODES --enable-pubsub-experiment

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

# ipfs pubsub sub
test_expect_success 'pubsub' '
echo "testOK" > expected &&
mkfifo done &&
(
ipfsi 0 pubsub sub --enc=ndpayload testTopic |
while read line; do
echo $line > actual &&
echo > done
exit
done
) &
ipfspid=$!
sleep 1
ipfsi 1 pubsub pub testTopic "testOK" &> pubErr1 &&
cat done &&
test_cmp actual expected
'

test_expect_success 'stop iptb' '
iptb stop
'

test_done

1 comment on commit 53ee3ad

@GitCop
Copy link

@GitCop GitCop commented on 53ee3ad Nov 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were the following issues with your Pull Request

We ask for a few features in the commit message for Open Source licensing hygiene and commit message clarity.
git commit --amend can often help you quickly improve the commit message.
Guidelines and a script are available to help in the long run.
Your feedback on GitCop is welcome on this issue.


This message was auto-generated by https://gitcop.com

Please sign in to comment.