diff --git a/test/sharness/t0054-dag-car-import-export-data/README.md b/test/sharness/t0054-dag-car-import-export-data/README.md index 033f837a092..786f9ade0e2 100644 --- a/test/sharness/t0054-dag-car-import-export-data/README.md +++ b/test/sharness/t0054-dag-car-import-export-data/README.md @@ -26,3 +26,7 @@ - lotus_devnet_genesis_v2.car - generated with `car index lotus_testnet_export_128.car > lotus_testnet_export_128_v2.car` - install `go-car` CLI from https://github.com/ipld/go-car + +- partial-dag-scope-entity.car + - unixfs directory entity exported from gateway via `?format=car&dag-scope=entity` ([IPIP-402](https://github.com/ipfs/specs/pull/402)) + - CAR roots includes directory CID, but only the root block is included in the CAR, making the DAG incomplete diff --git a/test/sharness/t0054-dag-car-import-export-data/partial-dag-scope-entity.car b/test/sharness/t0054-dag-car-import-export-data/partial-dag-scope-entity.car new file mode 100644 index 00000000000..b149a18df7c Binary files /dev/null and b/test/sharness/t0054-dag-car-import-export-data/partial-dag-scope-entity.car differ diff --git a/test/sharness/t0054-dag-car-import-export.sh b/test/sharness/t0054-dag-car-import-export.sh index f67cf13e2d2..65195cb0509 100755 --- a/test/sharness/t0054-dag-car-import-export.sh +++ b/test/sharness/t0054-dag-car-import-export.sh @@ -291,4 +291,26 @@ test_expect_success "'ipfs dag import' decode IPLD 'cbor' codec works" ' rm cbor.car ' +# IPIP-402 +cat > partial_nopin_import_expected << EOE +{"Stats":{"BlockCount":1,"BlockBytesCount":1618}} +EOE +test_expect_success "'ipfs dag import' without pinning works fine with incomplete DAG (unixfs dir exported as dag-scope=entity from IPIP-402)" ' + ipfs dag import --stats --enc=json --pin-roots=false ../t0054-dag-car-import-export-data/partial-dag-scope-entity.car >partial_nopin_import_out 2>&1 && + test_cmp partial_nopin_import_expected partial_nopin_import_out +' +test_expect_success "'ipfs dag import' with no params in CLI mode produces exit code 0 (unixfs dir exported as dag-scope=entity from IPIP-402)" ' + test_expect_code 0 ipfs dag import ../t0054-dag-car-import-export-data/partial-dag-scope-entity.car +' + +test_expect_success "'ipfs dag import' with pinning errors due to incomplete DAG (unixfs dir exported as dag-scope=entity from IPIP-402)" ' + ipfs dag import --stats --enc=json --pin-roots=true ../t0054-dag-car-import-export-data/partial-dag-scope-entity.car >partial_pin_import_out 2>&1 && + test_should_contain "\"PinErrorMsg\":\"block was not found locally" partial_pin_import_out +' + +test_expect_success "'ipfs dag import' pin error in default CLI mode produces exit code 1 (unixfs dir exported as dag-scope=entity from IPIP-402)" ' + test_expect_code 1 ipfs dag import --pin-roots ../t0054-dag-car-import-export-data/partial-dag-scope-entity.car >partial_pin_import_out 2>&1 && + test_should_contain "Error: pinning root \"QmPDC11yLAbVw3dX5jMeEuSdk4BiVjSd9X87zaYRdVjzW3\" FAILED: block was not found locally" partial_pin_import_out +' + test_done