55
reset_blockstore 0
56
reset_blockstore 1
57
58
- cat > basic_import_expected <<EOE
58
+ cat > basic_import_stats_expected <<EOE
59
+Imported 1198 blocks (468513 bytes)
60
Pinned root${tab}bafkqaaa${tab}success
61
Pinned root${tab}bafy2bzaceaxm23epjsmh75yvzcecsrbavlmkcxnva66bkdebdcnyw3bjrc74u${tab}success
62
Pinned root${tab}bafy2bzaced4ueelaegfs5fqu4tzsh6ywbbpfk3cxppupmxfdhbpbhzawfw5oy${tab}success
63
EOE
64
+ # output without the --stats line at the top
65
+ tail -n +2 basic_import_stats_expected > basic_import_expected
66
67
+ # Explainer:
68
+ # naked_root_import_json_expected output is produced by dag import of combined_naked_roots_genesis_and_128.car
69
+ # executed when roots are already present in the repo - thus the BlockCount=0
70
+ # (if blocks were not present in the repo, blockstore: block not found would be returned)
71
cat >naked_root_import_json_expected <<EOE
72
{"Root":{"Cid":{"/":"bafy2bzaceaxm23epjsmh75yvzcecsrbavlmkcxnva66bkdebdcnyw3bjrc74u"},"PinErrorMsg":""}}
73
{"Root":{"Cid":{"/":"bafy2bzaced4ueelaegfs5fqu4tzsh6ywbbpfk3cxppupmxfdhbpbhzawfw5oy"},"PinErrorMsg":""}}
74
+{"Stats":{"BlockCount":0,"BlockBytesCount":0}}
75
EOE
76
69
-
77
test_expect_success "basic import" '
78
do_import 0 \
79
../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
86
test_cmp_sorted basic_import_expected basic_import_actual
87
'
88
89
+ test_expect_success "basic import with --stats" '
90
+ do_import 0 --stats \
91
+ ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
92
+ ../t0054-dag-car-import-export-data/lotus_testnet_export_128_shuffled_nulroot.car \
93
+ ../t0054-dag-car-import-export-data/lotus_devnet_genesis_shuffled_nulroot.car \
94
+ > basic_import_actual
95
+ '
96
+
97
+ test_expect_success "basic import output with --stats as expected" '
98
+ test_cmp_sorted basic_import_stats_expected basic_import_actual
99
+ '
100
+
101
test_expect_success "basic fetch+export 1" '
102
ipfsi 1 dag export bafy2bzaced4ueelaegfs5fqu4tzsh6ywbbpfk3cxppupmxfdhbpbhzawfw5oy > reexported_testnet_128.car
103
'
117
'
118
119
test_expect_success "import/pin naked roots only, relying on local blockstore having all the data" '
101
- ipfsi 1 dag import --enc=json ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
120
+ ipfsi 1 dag import --stats --enc=json ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
121
> naked_import_result_json_actual
122
'
123
136
cat ../t0054-dag-car-import-export-data/lotus_testnet_export_128_shuffled_nulroot.car > pipe_testnet &
137
cat ../t0054-dag-car-import-export-data/lotus_devnet_genesis_shuffled_nulroot.car > pipe_devnet &
138
120
- do_import 0 \
139
+ do_import 0 --stats \
140
pipe_testnet \
141
pipe_devnet \
142
../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
153
'
154
155
test_expect_success "fifo-import output as expected" '
137
- test_cmp_sorted basic_import_expected basic_fifo_import_actual
156
+ test_cmp_sorted basic_import_stats_expected basic_fifo_import_actual
157
'
158
}
159
187
test_cmp_sorted offline_fetch_error_expected offline_fetch_error_actual
188
'
189
171
-
172
-cat >multiroot_import_json_expected <<EOE
190
+cat >multiroot_import_json_stats_expected <<EOE
191
{"Root":{"Cid":{"/":"bafy2bzaceb55n7uxyfaelplulk3ev2xz7gnq6crncf3ahnvu46hqqmpucizcw"},"PinErrorMsg":""}}
192
{"Root":{"Cid":{"/":"bafy2bzacebedrc4n2ac6cqdkhs7lmj5e4xiif3gu7nmoborihajxn3fav3vdq"},"PinErrorMsg":""}}
193
{"Root":{"Cid":{"/":"bafy2bzacede2hsme6hparlbr4g2x6pylj43olp4uihwjq3plqdjyrdhrv7cp4"},"PinErrorMsg":""}}
194
+{"Stats":{"BlockCount":2825,"BlockBytesCount":1339709}}
195
EOE
177
-test_expect_success "multiroot import works" '
196
+# output without --stats line
197
+head -3 multiroot_import_json_stats_expected > multiroot_import_json_expected
198
+
199
+test_expect_success "multiroot import works (--enc=json)" '
200
ipfs dag import --enc=json ../t0054-dag-car-import-export-data/lotus_testnet_export_256_multiroot.car > multiroot_import_json_actual
201
'
202
test_expect_success "multiroot import expected output" '
203
test_cmp_sorted multiroot_import_json_expected multiroot_import_json_actual
204
'
205
206
+test_expect_success "multiroot import works with --stats" '
207
+ ipfs dag import --stats --enc=json ../t0054-dag-car-import-export-data/lotus_testnet_export_256_multiroot.car > multiroot_import_json_actual
208
+'
209
+test_expect_success "multiroot import expected output" '
210
+ test_cmp_sorted multiroot_import_json_stats_expected multiroot_import_json_actual
211
+'
212
+
213
214
+cat >pin_import_expected << EOE
215
+{"Stats":{"BlockCount":1198,"BlockBytesCount":468513}}
216
+EOE
217
test_expect_success "pin-less import works" '
186
- ipfs dag import --enc=json --pin-roots=false \
218
+ ipfs dag import --stats --enc=json --pin-roots=false \
219
../t0054-dag-car-import-export-data/lotus_devnet_genesis.car \
220
../t0054-dag-car-import-export-data/lotus_testnet_export_128.car \
221
> no-pin_import_actual
222
'
191
-test_expect_success "expected silence on --pin-roots=false" '
192
- test_cmp /dev/null no-pin_import_actual
223
+test_expect_success "expected no pins on --pin-roots=false" '
224
+ test_cmp pin_import_expected no-pin_import_actual
225
'
226
227
228
test_expect_success "naked root import works" '
197
- ipfs dag import --enc=json ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
229
+ ipfs dag import --stats --enc=json ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
230
> naked_root_import_json_actual
231
'
232
test_expect_success "naked root import expected output" '