test: use car fixtures in sharness t0118
Laurent Senta committed
Feb 20, 2023 at 16:13 UTC
26b493d3c58c5875bf74e580aa91fed37a966f31
5 files changed
+28
-9
test/sharness/t0118-gateway-car.sh
+8
-9
@@ -11,15 +11,14 @@ test_launch_ipfs_daemon_without_network
11
# but if we have a small file that fits into a single block, and export its CID
12
# we will get a CAR that is a deterministic array of bytes.
13
14
- test_expect_success "Create a deterministic CAR for testing" '
15
- mkdir -p subdir &&
16
- echo "hello application/vnd.ipld.car" > subdir/ascii.txt &&
17
- ROOT_DIR_CID=$(ipfs add -Qrw --cid-version 1 subdir) &&
18
- FILE_CID=$(ipfs resolve -r /ipfs/$ROOT_DIR_CID/subdir/ascii.txt | cut -d "/" -f3) &&
19
- ipfs dag export $ROOT_DIR_CID > test-dag.car &&
20
- ipfs dag export $FILE_CID > deterministic.car &&
21
- purge_blockstore
22
- '
14
+# Import test case
15
+# See the static fixtures in ./t0118-gateway-car/
16
+test_expect_success "Add the dir test directory" '
17
+ cp ../t0118-gateway-car/test-dag.car ./test-dag.car &&
18
+ cp ../t0118-gateway-car/deterministic.car ./deterministic.car
19
+'
20
+ROOT_DIR_CID=bafybeiefu3d7oytdumk5v7gn6s7whpornueaw7m7u46v2o6omsqcrhhkzi # ./
21
+FILE_CID=bafkreifkam6ns4aoolg3wedr4uzrs3kvq66p4pecirz6y2vlrngla62mxm # /subdir/ascii.txt
22
23
# GET a reference DAG with dag-cbor+dag-pb+raw blocks as CAR
24
test/sharness/t0118-gateway-car/README.md
+19
@@ -8,3 +8,22 @@
8
- description of the contents and layout of the raw CAR, encoded in DAG-JSON
9
- Source: https://ipld.io/specs/transport/car/fixture/carv1-basic/carv1-basic.json
10
11
+- test-dag.car + deterministic.car
12
+ - raw CARv1
13
+
14
+generated with:
15
+
16
+```shell
17
+mkdir -p subdir &&
18
+echo "hello application/vnd.ipld.car" > subdir/ascii.txt &&
19
+ROOT_DIR_CID=$(ipfs add -Qrw --cid-version 1 subdir) &&
20
+FILE_CID=$(ipfs resolve -r /ipfs/$ROOT_DIR_CID/subdir/ascii.txt | cut -d "/" -f3) &&
21
+ipfs dag export $ROOT_DIR_CID > test-dag.car &&
22
+ipfs dag export $FILE_CID > deterministic.car &&
23
+
24
+echo ROOT_DIR_CID=${ROOT_DIR_CID} # ./
25
+echo FILE_CID=${FILE_CID} # /\subdir/ascii.txt
26
+
27
+# ROOT_DIR_CID=bafybeiefu3d7oytdumk5v7gn6s7whpornueaw7m7u46v2o6omsqcrhhkzi # ./
28
+# FILE_CID=bafkreifkam6ns4aoolg3wedr4uzrs3kvq66p4pecirz6y2vlrngla62mxm # /subdir/ascii.txt
29
+```
test/sharness/t0118-gateway-car/deterministic.car
Binary files /dev/null and b/test/sharness/t0118-gateway-car/deterministic.car differ
test/sharness/t0118-gateway-car/subdir/ascii.txt
new
+1
@@ -0,0 +1 @@
1
+hello application/vnd.ipld.car
test/sharness/t0118-gateway-car/test-dag.car
Binary files /dev/null and b/test/sharness/t0118-gateway-car/test-dag.car differ