From 150a3df54e34af12555ec9701835aa5a5ae317d2 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 26 Jul 2023 10:33:11 +0200 Subject: [PATCH] feat: CAR order and dups parameters from IPIP-412 (#87) --- Makefile | 2 +- fixtures/trustless_gateway_car/README.md | 29 +++ .../dir-with-duplicate-files.car | Bin 0 -> 1939 bytes go.mod | 6 +- go.sum | 11 +- tests/trustless_gateway_car_test.go | 172 +++++++++++++++++- tooling/ipns/record.go | 31 +++- tooling/specs/specs.go | 32 ++-- 8 files changed, 247 insertions(+), 36 deletions(-) create mode 100644 fixtures/trustless_gateway_car/dir-with-duplicate-files.car diff --git a/Makefile b/Makefile index 2f98ec76d..55300d517 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ provision-cargateway: ./fixtures.car car -c ./fixtures.car & provision-kubo: - find ./fixtures -name '*.car' -exec ipfs dag import {} \; + find ./fixtures -name '*.car' -exec ipfs dag import --stats --pin-roots=false {} \; find ./fixtures -name '*.ipns-record' -exec sh -c 'ipfs routing put --allow-offline /ipns/$$(basename -s .ipns-record "{}") "{}"' \; # tools diff --git a/fixtures/trustless_gateway_car/README.md b/fixtures/trustless_gateway_car/README.md index f60da5f32..f8f8f813c 100644 --- a/fixtures/trustless_gateway_car/README.md +++ b/fixtures/trustless_gateway_car/README.md @@ -16,4 +16,33 @@ ipfs dag export $CID > file-3k-and-3-blocks.car REMOVE_BLOCK=$(ipfs dag get $CID | jq '.Links[1].Hash["/"]' -r) echo $REMOVE_BLOCK | car filter --version 1 --inverse ./file-3k-and-3-blocks.car ./file-3k-and-3-blocks-missing-block.car ipfs pin rm $CID; ipfs repo gc +# First and third outputted CIDs are used in the missing blocks tests. +ipfs dag get $CID | jq .Links | jq -r '.[].Hash."/"' +``` + +### [dir-with-duplicate-files.car](./dir-with-duplicate-files.car) + +```sh +ipfs version +# ipfs version 0.21.0 +TEXT=$(cat <<-EOF +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non imperdiet nunc. Proin ac quam ut nibh eleifend aliquet. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Sed ligula dolor, imperdiet sagittis arcu et, semper tincidunt urna. Donec et tempor augue, quis sollicitudin metus. Curabitur semper ullamcorper aliquet. Mauris hendrerit sodales lectus eget fermentum. Proin sollicitudin vestibulum commodo. Vivamus nec lectus eu augue aliquet dignissim nec condimentum justo. In hac habitasse platea dictumst. Mauris vel sem neque. + +Vivamus finibus, enim at lacinia semper, arcu erat gravida lacus, sit amet gravida magna orci sit amet est. Sed non leo lacus. Nullam viverra ipsum a tincidunt dapibus. Nulla pulvinar ligula sit amet ante ultrices tempus. Proin purus urna, semper sed lobortis quis, gravida vitae ipsum. Aliquam mi urna, pulvinar eu bibendum quis, convallis ac dolor. In gravida justo sed risus ullamcorper, vitae luctus massa hendrerit. Pellentesque habitant amet. +EOF +) + +ASCII_CID=$(echo "hello application/vnd.ipld.car" | ipfs add --cid-version=1 -q) +HELLO_CID=$(echo "hello world" | ipfs add --cid-version=1 -q) +MULTIBLOCK_CID=$(echo -n $TEXT | ipfs add --cid-version=1 --chunker=size-256 -q) +# Print the Multiblock CIDs (required for some tests) +ipfs dag get $MULTIBLOCK_CID | jq .Links | jq -r '.[].Hash."/"' +ipfs files mkdir -p --cid-version 1 /dir-with-duplicate-files +ipfs files cp /ipfs/$ASCII_CID /dir-with-duplicate-files/ascii-copy.txt +ipfs files cp /ipfs/$ASCII_CID /dir-with-duplicate-files/ascii.txt +ipfs files cp /ipfs/$HELLO_CID /dir-with-duplicate-files/hello.txt +ipfs files cp /ipfs/$MULTIBLOCK_CID /dir-with-duplicate-files/multiblock.txt +ipfs files ls -l +# Manually CID of "dir-with-duplicate-files" and then... +ipfs dag export $CID ``` diff --git a/fixtures/trustless_gateway_car/dir-with-duplicate-files.car b/fixtures/trustless_gateway_car/dir-with-duplicate-files.car new file mode 100644 index 0000000000000000000000000000000000000000..d0accae1597921dc5f64832b872382a3af23c2bb GIT binary patch liter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