Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit b6521d0

Browse files
authored
refactor: use low-level block api in refs-local interface test (#3005)
1 parent d2579c0 commit b6521d0

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

packages/interface-ipfs-core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"dirty-chai": "^2.0.1",
3939
"ipfs-block": "^0.8.1",
4040
"ipfs-unixfs": "^1.0.1",
41+
"ipfs-unixfs-importer": "^2.0.0",
4142
"ipfs-utils": "^2.2.0",
4243
"ipld-dag-cbor": "^0.15.1",
4344
"ipld-dag-pb": "^0.18.3",

packages/interface-ipfs-core/src/dag/get.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const dagPB = require('ipld-dag-pb')
55
const DAGNode = dagPB.DAGNode
66
const dagCBOR = require('ipld-dag-cbor')
7+
const importer = require('ipfs-unixfs-importer')
78
const Unixfs = require('ipfs-unixfs')
89
const all = require('it-all')
910
const { getDescribe, getIt, expect } = require('../utils/mocha')
@@ -154,7 +155,10 @@ module.exports = (common, options) => {
154155
it('should get a node added as CIDv1 with a CIDv0', async () => {
155156
const input = Buffer.from(`TEST${Math.random()}`)
156157

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+
}))
158162

159163
const cidv1 = res[0].cid
160164
expect(cidv1.version).to.equal(1)

packages/interface-ipfs-core/src/refs-local.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const { fixtures } = require('./utils')
55
const { getDescribe, getIt, expect } = require('./utils/mocha')
66
const all = require('it-all')
7+
const importer = require('ipfs-unixfs-importer')
78

89
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
910
/**
@@ -36,10 +37,14 @@ module.exports = (common, options) => {
3637
content('holmes.txt')
3738
]
3839

39-
await all(ipfs.add(dirs))
40+
const imported = await all(importer(dirs, ipfs.block))
4041

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+
)
4246

47+
const refs = await all(ipfs.refs.local())
4348
const cids = refs.map(r => r.ref)
4449
expect(cids).to.include('QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn')
4550
expect(cids).to.include('QmR4nFjTu18TyANgC65ArNWp5Yaab1gPzQ4D8zp7Kx3vhr')

0 commit comments

Comments
 (0)