From 9eba2a914f97baf46e4973f19170469092e0bf2f Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 17 Oct 2022 13:08:09 +0200 Subject: [PATCH] test: convert cbor <-> json --- test/sharness/t0123-gateway-json-cbor.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/sharness/t0123-gateway-json-cbor.sh b/test/sharness/t0123-gateway-json-cbor.sh index 7bf312b17443..ac446c3df7f4 100755 --- a/test/sharness/t0123-gateway-json-cbor.sh +++ b/test/sharness/t0123-gateway-json-cbor.sh @@ -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 \ No newline at end of file