Skip to content

Commit 31789b4

Browse files
committed
Added test for the other direction
1 parent 67d3a6b commit 31789b4

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

run-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ function runTest() {
1515
}
1616

1717
runTest "simple reply" "test/simple-reply.sh"
18+
runTest "simple answer" "test/simple-answer.sh"
1819

1920
exit $RESULT

test/simple-answer.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
nc -w 5 -l -p 8811 | md5sum > /tmp/reply-hash &
4+
5+
"$1" -hosting "localhost:8800" -forward "localhost:8811" &
6+
proxy=$!
7+
8+
sleep 1
9+
dd if=/dev/urandom of=/tmp/answer bs=1M count=1 2>/dev/null
10+
cat /tmp/answer | nc localhost 8800
11+
12+
SUM="$(cat /tmp/reply-hash)"
13+
echo -e "Gotten: \t $SUM"
14+
EXPECTED_SUM=$(cat /tmp/answer | md5sum )
15+
echo -e "Expected: \t $EXPECTED_SUM"
16+
17+
kill $proxy || true
18+
19+
if [ "$SUM" = "$EXPECTED_SUM" ]; then
20+
exit 0
21+
else
22+
exit 1
23+
fi

0 commit comments

Comments
 (0)