Skip to content

Commit

Permalink
test(car): export/import of (dag-)cbor/json codecs
Browse files Browse the repository at this point in the history
This ensures we have full test coverage.
  • Loading branch information
lidel committed Oct 13, 2022
1 parent 553d3e0 commit 41fb5f1
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions test/sharness/t0054-dag-car-import-export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,32 @@ test_expect_success "version 2 import output as expected" '
test_cmp_sorted version_2_import_expected version_2_import_actual
'

test_expect_success "'ipfs dag import' decode IPLD dag-json works" '
HASH=$(echo "dag-json content" | ipfs add -Q) &&
# We dont pipe because that doesnt release the repo lock
ipfs dag get $HASH > dag-json.out &&
NEW_HASH=$(ipfs dag put --store-codec dag-json dag-json.out) &&
test_expect_success "'ipfs dag import' decode IPLD 'dag-json' codec works" '
NEW_HASH=$(echo "{ \"test\": \"dag-json\" }" | ipfs dag put --store-codec dag-json) &&
ipfs dag export $NEW_HASH > dag-json.car &&
ipfs dag import dag-json.car &&
rm dag-json.out dag-json.car
rm dag-json.car
'

test_expect_success "'ipfs dag import' decode IPLD 'dag-cbor' codec works" '
NEW_HASH=$(echo "{ \"test\": \"dag-cbor\" }" | ipfs dag put --store-codec dag-cbor) &&
ipfs dag export $NEW_HASH > dag-cbor.car &&
ipfs dag import dag-cbor.car &&
rm dag-cbor.car
'

test_expect_success "'ipfs dag import' decode IPLD 'json' codec works" '
NEW_HASH=$(echo "{ \"test\": \"json\" }" | ipfs dag put --store-codec json) &&
ipfs dag export $NEW_HASH > json.car &&
ipfs dag import json.car &&
rm json.car
'

test_expect_success "'ipfs dag import' decode IPLD 'cbor' codec works" '
NEW_HASH=$(echo "{ \"test\": \"cbor\" }" | ipfs dag put --store-codec cbor) &&
ipfs dag export $NEW_HASH > cbor.car &&
ipfs dag import cbor.car &&
rm cbor.car
'

test_done

0 comments on commit 41fb5f1

Please sign in to comment.