Add tests for FetchBlocks gateway option
License: MIT Signed-off-by: Iaroslav Gridin <voker57@gmail.com>
Iaroslav Gridin committed
Oct 11, 2018 at 11:54 UTC
041c46e75c35e2412cfb31518b10640dbc9e3dfe
1 file changed
+32
test/sharness/t0110-gateway.sh
+32
@@ -215,4 +215,36 @@ test_expect_success "GET compact blocks succeeds" '
215
216
test_kill_ipfs_daemon
217
218
+
219
+GWPORT=32563
220
+
221
+test_expect_success "set up iptb testbed" '
222
+ iptb testbed create -type localipfs -count 2 -force -init &&
223
+ ipfsi 0 config Addresses.Gateway /ip4/127.0.0.1/tcp/$GWPORT
224
+'
225
+
226
+test_expect_success "set NoFetch to true in config of node 0" '
227
+ ipfsi 0 config --bool=true Gateway.NoFetch true
228
+'
229
+
230
+test_expect_success "start ipfs nodes" '
231
+ iptb start -wait &&
232
+ iptb connect 0 1
233
+'
234
+
235
+test_expect_success "try fetching not present key from node 0" '
236
+ echo "hi" | ipfsi 1 add -Q > hi.hash &&
237
+ test_expect_code 22 curl -f "http://127.0.0.1:$GWPORT/ipfs/$(cat hi.hash)"
238
+'
239
+
240
+test_expect_success "try fetching present key from from node 0" '
241
+ echo "hi" | ipfsi 0 add -Q > hi.hash &&
242
+ PORT1=$(ipfs config Addresses.Gateway | cut -d/ -f 5) &&
243
+ curl -f "http://127.0.0.1:$GWPORT/ipfs/$(cat hi.hash)"
244
+'
245
+
246
+test_expect_success "stop testbed" '
247
+ iptb stop
248
+'
249
+
250
test_done