Skip to content

Commit 9eba2a9

Browse files
committed
test: convert cbor <-> json
1 parent c931950 commit 9eba2a9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/sharness/t0123-gateway-json-cbor.sh

+14
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ test_codec () {
9494
test_codec "JSON" "json"
9595
test_codec "CBOR" "cbor"
9696

97+
test_expect_success "GET JSON as CBOR produces DAG-CBOR output" '
98+
CID=$(echo "{ \"test\": \"json\" }" | ipfs dag put --input-codec json --store-codec json) &&
99+
curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=cbor" > curl_output 2>&1 &&
100+
ipfs dag get --output-codec dag-cbor $CID > ipfs_dag_get_output 2>&1 &&
101+
test_cmp ipfs_dag_get_output curl_output
102+
'
103+
104+
test_expect_success "GET CBOR as JSON produces DAG-JSON output" '
105+
CID=$(echo "{ \"test\": \"json\" }" | ipfs dag put --input-codec json --store-codec cbor) &&
106+
curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=json" > curl_output 2>&1 &&
107+
ipfs dag get --output-codec dag-json $CID > ipfs_dag_get_output 2>&1 &&
108+
test_cmp ipfs_dag_get_output curl_output
109+
'
110+
97111
test_kill_ipfs_daemon
98112

99113
test_done

0 commit comments

Comments
 (0)