test: add dag get --ouput-codec test
Adin Schmahmann committed
Sep 27, 2021 at 15:09 UTC
d576e53c0454449fb60195ac7be9bf4e7ed39a05
1 file changed
+12
test/sharness/t0053-dag.sh
+12
@@ -165,6 +165,18 @@ test_dag_cmd() {
165
ipfs dag get $IPLDPBHASH >& dag-get-pb
166
'
167
168
+ test_expect_success "can get dag-pb block transcoded as dag-cbor" '
169
+ ipfs dag get --output-codec=dag-cbor $IPLDPBHASH >& dag-get-dagpb-transcoded-to-dagcbor &&
170
+ echo "122082a2e4c892e7dcf1d491b30d68aa73ba76bec94f87d4e1a887596ce0730a534a" >sha2_dagpb_to_dagcbor_expected &&
171
+ multihash -a=sha2-256 -e=hex dag-get-dagpb-transcoded-to-dagcbor >sha2_dagpb_to_dagcbor_actual &&
172
+ test_cmp sha2_dagpb_to_dagcbor_expected sha2_dagpb_to_dagcbor_actual
173
+ '
174
+
175
+ test_expect_success "dag put and dag get transcodings match" '
176
+ ROUNDTRIPDAGCBOR=$(ipfs dag put --input-codec=dag-cbor --store-codec=dag-cbor dag-get-dagpb-transcoded-to-dagcbor) &&
177
+ test $ROUNDTRIPDAGCBOR = $IPLDCBORHASH
178
+ '
179
+
180
# this doesn't tell us if they are correct, we test that better below
181
test_expect_success "outputs are the same" '
182
test_cmp dag-get-cbor dag-get-json &&