This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
packages/interface-ipfs-core Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 38
38
"dirty-chai" : " ^2.0.1" ,
39
39
"ipfs-block" : " ^0.8.1" ,
40
40
"ipfs-unixfs" : " ^1.0.1" ,
41
+ "ipfs-unixfs-importer" : " ^2.0.0" ,
41
42
"ipfs-utils" : " ^2.2.0" ,
42
43
"ipld-dag-cbor" : " ^0.15.1" ,
43
44
"ipld-dag-pb" : " ^0.18.3" ,
Original file line number Diff line number Diff line change 4
4
const dagPB = require ( 'ipld-dag-pb' )
5
5
const DAGNode = dagPB . DAGNode
6
6
const dagCBOR = require ( 'ipld-dag-cbor' )
7
+ const importer = require ( 'ipfs-unixfs-importer' )
7
8
const Unixfs = require ( 'ipfs-unixfs' )
8
9
const all = require ( 'it-all' )
9
10
const { getDescribe, getIt, expect } = require ( '../utils/mocha' )
@@ -154,7 +155,10 @@ module.exports = (common, options) => {
154
155
it ( 'should get a node added as CIDv1 with a CIDv0' , async ( ) => {
155
156
const input = Buffer . from ( `TEST${ Math . random ( ) } ` )
156
157
157
- const res = await all ( ipfs . add ( input , { cidVersion : 1 , rawLeaves : false } ) )
158
+ const res = await all ( importer ( [ { content : input } ] , ipfs . block , {
159
+ cidVersion : 1 ,
160
+ rawLeaves : false
161
+ } ) )
158
162
159
163
const cidv1 = res [ 0 ] . cid
160
164
expect ( cidv1 . version ) . to . equal ( 1 )
Original file line number Diff line number Diff line change 4
4
const { fixtures } = require ( './utils' )
5
5
const { getDescribe, getIt, expect } = require ( './utils/mocha' )
6
6
const all = require ( 'it-all' )
7
+ const importer = require ( 'ipfs-unixfs-importer' )
7
8
8
9
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
9
10
/**
@@ -36,10 +37,14 @@ module.exports = (common, options) => {
36
37
content ( 'holmes.txt' )
37
38
]
38
39
39
- await all ( ipfs . add ( dirs ) )
40
+ const imported = await all ( importer ( dirs , ipfs . block ) )
40
41
41
- const refs = await all ( ipfs . refs . local ( ) )
42
+ // otherwise go-ipfs doesn't show them in the local refs
43
+ await Promise . all (
44
+ imported . map ( i => ipfs . pin . add ( i . cid ) )
45
+ )
42
46
47
+ const refs = await all ( ipfs . refs . local ( ) )
43
48
const cids = refs . map ( r => r . ref )
44
49
expect ( cids ) . to . include ( 'QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn' )
45
50
expect ( cids ) . to . include ( 'QmR4nFjTu18TyANgC65ArNWp5Yaab1gPzQ4D8zp7Kx3vhr' )
You can’t perform that action at this time.
0 commit comments