diff --git a/test/sharness/t0115-gateway-dir-listing.sh b/test/sharness/t0115-gateway-dir-listing.sh index cf95bf4b05e..4681e63ee62 100755 --- a/test/sharness/t0115-gateway-dir-listing.sh +++ b/test/sharness/t0115-gateway-dir-listing.sh @@ -13,14 +13,34 @@ test_description="Test directory listing (dir-index-html) on the HTTP gateway" test_expect_success "ipfs init" ' export IPFS_PATH="$(pwd)/.ipfs" && - ipfs init --profile=test > /dev/null + ipfs init --empty-repo --profile=test > /dev/null ' test_launch_ipfs_daemon_without_network +# HAMT-sharded directory test. We must execute this test first as we want to +# start from an empty repository and count the exact number of refs we want. +HAMT_CID=bafybeiggvykl7skb2ndlmacg2k5modvudocffxjesexlod2pfvg5yhwrqm +HAMT_REFS_CID=bafybeicv4utmj46mgbpamvw2k6zg4qjs5yvspfnlxz2y6iuey5smjfcn4a +HAMT_REFS_COUNT=963 + +test_expect_success "hamt: import fixture with necessary refs" ' + ipfs dag import ../t0115-gateway-dir-listing/hamt-refs.car && + ipfs refs local | wc -l | tr -d " " > refs_count_actual && + echo $HAMT_REFS_COUNT > refs_count_expected && + test_cmp refs_count_expected refs_count_actual +' + +test_expect_success "hamt: fetch directory from gateway in offline mode" ' + curl --max-time 1 -sD - http://127.0.0.1:$GWAY_PORT/ipfs/$HAMT_CID/ > hamt_list_response && + ipfs refs local | wc -l | tr -d " " > refs_count_actual && + echo $HAMT_REFS_COUNT > refs_count_expected && + test_cmp refs_count_expected refs_count_actual +' + # Import test case # See the static fixtures in ./t0115-gateway-dir-listing/ -test_expect_success "Add the test directory" ' +test_expect_success "add remaining test fixtures" ' ipfs dag import ../t0115-gateway-dir-listing/fixtures.car ' DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir/ diff --git a/test/sharness/t0115-gateway-dir-listing/README.md b/test/sharness/t0115-gateway-dir-listing/README.md index 937438bcd65..7da44078ba3 100644 --- a/test/sharness/t0115-gateway-dir-listing/README.md +++ b/test/sharness/t0115-gateway-dir-listing/README.md @@ -2,8 +2,12 @@ - fixtures.car - raw CARv1 +- hamt-refs.car + - raw CARv1 containing all the necessary blocks to present a directory listing + for `bafybeiggvykl7skb2ndlmacg2k5modvudocffxjesexlod2pfvg5yhwrqm`, which is + a directory containing over 10k items. -generated with: +fixutres.car generated with: ```sh # using ipfs version 0.18.1 @@ -30,3 +34,20 @@ ipfs dag export ${DIR_CID} > ./fixtures.car # FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt # FILE_SIZE=34 ``` + +hamt-refs.car generated with: + +```sh +# using ipfs version 0.18.1 +export IPFS_PATH=$(mktemp -d) +ipfs init --empty-repo +ipfs daemon & +curl http://127.0.0.1:8080/ipfs/bafybeiggvykl7skb2ndlmacg2k5modvudocffxjesexlod2pfvg5yhwrqm/ +killall ipfs +ipfs refs local >> refs +ipfs files mkdir --cid-version 1 /Test +cat refs | xargs -I {} ipfs files cp /ipfs/{} /Test/{} +ipfs files stat /Test +# Grab CID: bafybeicv4utmj46mgbpamvw2k6zg4qjs5yvspfnlxz2y6iuey5smjfcn4a +ipfs dag export bafybeicv4utmj46mgbpamvw2k6zg4qjs5yvspfnlxz2y6iuey5smjfcn4a > ./refs.car +``` diff --git a/test/sharness/t0115-gateway-dir-listing/hamt-refs.car b/test/sharness/t0115-gateway-dir-listing/hamt-refs.car new file mode 100644 index 00000000000..58069310cc4 Binary files /dev/null and b/test/sharness/t0115-gateway-dir-listing/hamt-refs.car differ