Skip to content

Commit

Permalink
test(ipip-402): dag import
Browse files Browse the repository at this point in the history
this adds basic regression test that guards behavior
around partial cars with or without pinning
  • Loading branch information
lidel committed Jun 14, 2023
1 parent 249c1b0 commit 20b7e18
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/sharness/t0054-dag-car-import-export-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file not shown.
22 changes: 22 additions & 0 deletions test/sharness/t0054-dag-car-import-export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 20b7e18

Please sign in to comment.