Skip to content

Commit 20b7e18

Browse files
committed
test(ipip-402): dag import
this adds basic regression test that guards behavior around partial cars with or without pinning
1 parent 249c1b0 commit 20b7e18

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

test/sharness/t0054-dag-car-import-export-data/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@
2626
- lotus_devnet_genesis_v2.car
2727
- generated with `car index lotus_testnet_export_128.car > lotus_testnet_export_128_v2.car`
2828
- install `go-car` CLI from https://github.com/ipld/go-car
29+
30+
- partial-dag-scope-entity.car
31+
- unixfs directory entity exported from gateway via `?format=car&dag-scope=entity` ([IPIP-402](https://github.com/ipfs/specs/pull/402))
32+
- CAR roots includes directory CID, but only the root block is included in the CAR, making the DAG incomplete
Binary file not shown.

test/sharness/t0054-dag-car-import-export.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,26 @@ test_expect_success "'ipfs dag import' decode IPLD 'cbor' codec works" '
291291
rm cbor.car
292292
'
293293

294+
# IPIP-402
295+
cat > partial_nopin_import_expected << EOE
296+
{"Stats":{"BlockCount":1,"BlockBytesCount":1618}}
297+
EOE
298+
test_expect_success "'ipfs dag import' without pinning works fine with incomplete DAG (unixfs dir exported as dag-scope=entity from IPIP-402)" '
299+
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 &&
300+
test_cmp partial_nopin_import_expected partial_nopin_import_out
301+
'
302+
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)" '
303+
test_expect_code 0 ipfs dag import ../t0054-dag-car-import-export-data/partial-dag-scope-entity.car
304+
'
305+
306+
test_expect_success "'ipfs dag import' with pinning errors due to incomplete DAG (unixfs dir exported as dag-scope=entity from IPIP-402)" '
307+
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 &&
308+
test_should_contain "\"PinErrorMsg\":\"block was not found locally" partial_pin_import_out
309+
'
310+
311+
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)" '
312+
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 &&
313+
test_should_contain "Error: pinning root \"QmPDC11yLAbVw3dX5jMeEuSdk4BiVjSd9X87zaYRdVjzW3\" FAILED: block was not found locally" partial_pin_import_out
314+
'
315+
294316
test_done

0 commit comments

Comments
 (0)