Skip to content

Commit

Permalink
test: convert cbor <-> json
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Oct 19, 2022
1 parent c931950 commit 9eba2a9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/sharness/t0123-gateway-json-cbor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ test_codec () {
test_codec "JSON" "json"
test_codec "CBOR" "cbor"

test_expect_success "GET JSON as CBOR produces DAG-CBOR output" '
CID=$(echo "{ \"test\": \"json\" }" | ipfs dag put --input-codec json --store-codec json) &&
curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=cbor" > curl_output 2>&1 &&
ipfs dag get --output-codec dag-cbor $CID > ipfs_dag_get_output 2>&1 &&
test_cmp ipfs_dag_get_output curl_output
'

test_expect_success "GET CBOR as JSON produces DAG-JSON output" '
CID=$(echo "{ \"test\": \"json\" }" | ipfs dag put --input-codec json --store-codec cbor) &&
curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=json" > curl_output 2>&1 &&
ipfs dag get --output-codec dag-json $CID > ipfs_dag_get_output 2>&1 &&
test_cmp ipfs_dag_get_output curl_output
'

test_kill_ipfs_daemon

test_done

0 comments on commit 9eba2a9

Please sign in to comment.