From 20b7e18c085b3f7b2d3169b4e553ca2a666fec69 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 14 Jun 2023 22:01:43 +0200 Subject: [PATCH] test(ipip-402): dag import this adds basic regression test that guards behavior around partial cars with or without pinning --- .../README.md | 4 ++++ .../partial-dag-scope-entity.car | Bin 0 -> 1711 bytes test/sharness/t0054-dag-car-import-export.sh | 22 ++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 test/sharness/t0054-dag-car-import-export-data/partial-dag-scope-entity.car diff --git a/test/sharness/t0054-dag-car-import-export-data/README.md b/test/sharness/t0054-dag-car-import-export-data/README.md index 033f837a092..786f9ade0e2 100644 --- a/test/sharness/t0054-dag-car-import-export-data/README.md +++ b/test/sharness/t0054-dag-car-import-export-data/README.md @@ -26,3 +26,7 @@ - lotus_devnet_genesis_v2.car - generated with `car index lotus_testnet_export_128.car > lotus_testnet_export_128_v2.car` - install `go-car` CLI from https://github.com/ipld/go-car + +- partial-dag-scope-entity.car + - unixfs directory entity exported from gateway via `?format=car&dag-scope=entity` ([IPIP-402](https://github.com/ipfs/specs/pull/402)) + - CAR roots includes directory CID, but only the root block is included in the CAR, making the DAG incomplete diff --git a/test/sharness/t0054-dag-car-import-export-data/partial-dag-scope-entity.car b/test/sharness/t0054-dag-car-import-export-data/partial-dag-scope-entity.car new file mode 100644 index 0000000000000000000000000000000000000000..b149a18df7ceb2921d2c53dd40b919e8ce25cdd1 GIT binary patch literal 1711 zcmai#dpJ~i7{?7(86*5m+eu8rw2PQQlT>vBb@4xeT-|z4Hd*APwpN}Zz zasuDhF?%&f53m_;rG~=4INA}rju?Y9X{4%*!|E}$tKg@X|Hj|&dO)0jC~;Jd(Z(46 z|1nrhw*&0>*#*V=+N6fI__`2bNd(g(+ub&OnzXT{u6@*0U>5_dU`(i#qe8AgqLj-J zuG@k+8uIWIm>6oBLKPYG9C-!%pBgZ~Qs(xej2i^JhG>Na%c_3-l$}!%nw;~WB6Hm5 zX~^@f$Pp&+)+tGqjIW*<+~Hpd*H?vBPB@;_uN6(z+4ACU=#=Ar~rosUBE&e zkQ)_i(*J7E_kBbDmh*NXu0$-riYzX;FF*Qtx=)U)1X#o=l-_KVYKOBZBXmEhLw-DgUO^q0iq!7sD0uKxH`tvuB$Vr zAet{J!WkF}<)jzKjVUi&pMMG*x6!hg0bcO6wFB!M zB#lq4t43krJ*V>4U>hE=5Wxw$SK_+O)3{MjebIno7x|TW2RN|~ExteeXTr1EerE5@ zlh2-q?zK%>W!|H0mi^1}=V{2~(x8hW3JfN*wKu0klqTxvha*!JK(WpuP>391biQOJw zX4zMI9BRnCARbJCUPKvs&uHr%V~SaK!6X#J30NwH>RJJC*IoaG9V2;@Q(o^|mz^bN zGgf*HIY!>9Og5>lvQewC@tQS&fntPGE>sB!GCrUZ9yPP7h?f3J*9A#$l8`oK_1Aj# z^U@DcW0TM!v7YS~w%Gufq6!hto$ET6l9(Azagn(vi)Pu(ys@+pO5A>V@};^ZcT=~p zmV4;&JPk4qV(q|G24koQ!3o|5ob2~bA9(6y_B|P#s4XZB>k7+yJo~2X^IkzD_Q&y~ zsZK?Cxe*1Oy8w{k1WIOro4c!qJl_H!;|IzXy^5L-5i?)MBWAvhsk<#(tY@wrim#b! za=v*W>x1uS8knR|$~Pba0&31Pru<*O;+@REzb3Y1;pTy3OY}}C_l>cl z``oSp`bHHhh$qcd5>UZ5BWfeXo`Gf-jsA$Esmx+i%p;c9lG>oW3=8owj`2j$bhZ{4 zD-jW*M92k$PSm?o8#!dKa{OnGSGJ>vC=@iqZ%_0lKhV%l9kwhD#yk2IazIzgj5qeAe;s{199=ZEcvpi_jcxAaa5H8R8<^lIfyiLR zx1efIqLy>F`FPp&+q1$}gg#7Jey1(1UD7||XgoTaneG|h7;$R?n5z*fnK=kIPK8Q^ P partial_nopin_import_expected << EOE +{"Stats":{"BlockCount":1,"BlockBytesCount":1618}} +EOE +test_expect_success "'ipfs dag import' without pinning works fine with incomplete DAG (unixfs dir exported as dag-scope=entity from IPIP-402)" ' + ipfs dag import --stats --enc=json --pin-roots=false ../t0054-dag-car-import-export-data/partial-dag-scope-entity.car >partial_nopin_import_out 2>&1 && + test_cmp partial_nopin_import_expected partial_nopin_import_out +' +test_expect_success "'ipfs dag import' with no params in CLI mode produces exit code 0 (unixfs dir exported as dag-scope=entity from IPIP-402)" ' + test_expect_code 0 ipfs dag import ../t0054-dag-car-import-export-data/partial-dag-scope-entity.car +' + +test_expect_success "'ipfs dag import' with pinning errors due to incomplete DAG (unixfs dir exported as dag-scope=entity from IPIP-402)" ' + ipfs dag import --stats --enc=json --pin-roots=true ../t0054-dag-car-import-export-data/partial-dag-scope-entity.car >partial_pin_import_out 2>&1 && + test_should_contain "\"PinErrorMsg\":\"block was not found locally" partial_pin_import_out +' + +test_expect_success "'ipfs dag import' pin error in default CLI mode produces exit code 1 (unixfs dir exported as dag-scope=entity from IPIP-402)" ' + test_expect_code 1 ipfs dag import --pin-roots ../t0054-dag-car-import-export-data/partial-dag-scope-entity.car >partial_pin_import_out 2>&1 && + test_should_contain "Error: pinning root \"QmPDC11yLAbVw3dX5jMeEuSdk4BiVjSd9X87zaYRdVjzW3\" FAILED: block was not found locally" partial_pin_import_out +' + test_done