File tree 2 files changed +48
-8
lines changed
2 files changed +48
-8
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,31 @@ test_description="test http requests made by cli"
10
10
11
11
test_init_ipfs
12
12
13
- test_expect_success " can make http request against nc server" '
14
- nc -ld 5005 > nc_out &
13
+ test_expect_success " start nc" '
14
+ rm -f nc_out nc_status nc_in && mkfifo nc_in nc_status
15
+ nc -v -l 127.0.0.1 5005 < nc_in > nc_out 2>nc_status &
15
16
NCPID=$!
16
- go-sleep 0.5s && kill "$NCPID" &
17
- ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005 || true
17
+
18
+ # Needed to "prime" nc
19
+ echo -n "" > nc_in
20
+
21
+ # Wait for it to start
22
+ head -1 nc_status
23
+ '
24
+
25
+ test_expect_success " can make http request against nc server" '
26
+ cat >nc_in <<EOF
27
+ HTTP/1.1 200 OK
28
+ Content-Type: text/plain
29
+ Content-Length: 1
30
+
31
+ .
32
+ EOF
33
+ ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005
34
+ '
35
+
36
+ test_expect_success " wait for nc to exit" '
37
+ wait $NCPID
18
38
'
19
39
20
40
test_expect_success " output does not contain multipart info" '
Original file line number Diff line number Diff line change @@ -10,11 +10,31 @@ test_description="test dns resolution of api endpoint by cli"
10
10
11
11
test_init_ipfs
12
12
13
- test_expect_success " can make http request against dns resolved nc server" '
14
- nc -ld 5005 > nc_out &
13
+ test_expect_success " start nc" '
14
+ rm -f nc_out nc_status nc_in && mkfifo nc_in nc_status
15
+ nc -v -l 127.0.0.1 5005 < nc_in > nc_out 2>nc_status &
15
16
NCPID=$!
16
- go-sleep 1s && kill "$NCPID" &
17
- ipfs cat /ipfs/Qmabcdef --api /dns4/localhost/tcp/5005 || true
17
+
18
+ # Needed to "prime" nc
19
+ echo -n "" > nc_in
20
+
21
+ # Wait for it to start
22
+ head -1 nc_status
23
+ '
24
+
25
+ test_expect_success " can make http request against dns resolved nc server" '
26
+ cat >nc_in <<EOF
27
+ HTTP/1.1 200 OK
28
+ Content-Type: text/plain
29
+ Content-Length: 1
30
+
31
+ .
32
+ EOF
33
+ ipfs cat /ipfs/Qmabcdef --api /dns4/localhost/tcp/5005
34
+ '
35
+
36
+ test_expect_success " wait for nc to exit" '
37
+ wait $NCPID
18
38
'
19
39
20
40
test_expect_success " request was received by local nc server" '
You can’t perform that action at this time.
0 commit comments