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

Commit

Permalink
refactor: use low-level block api in refs-local interface test (#3005)
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Apr 24, 2020
1 parent d2579c0 commit b6521d0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/interface-ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"dirty-chai": "^2.0.1",
"ipfs-block": "^0.8.1",
"ipfs-unixfs": "^1.0.1",
"ipfs-unixfs-importer": "^2.0.0",
"ipfs-utils": "^2.2.0",
"ipld-dag-cbor": "^0.15.1",
"ipld-dag-pb": "^0.18.3",
Expand Down
6 changes: 5 additions & 1 deletion packages/interface-ipfs-core/src/dag/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const dagPB = require('ipld-dag-pb')
const DAGNode = dagPB.DAGNode
const dagCBOR = require('ipld-dag-cbor')
const importer = require('ipfs-unixfs-importer')
const Unixfs = require('ipfs-unixfs')
const all = require('it-all')
const { getDescribe, getIt, expect } = require('../utils/mocha')
Expand Down Expand Up @@ -154,7 +155,10 @@ module.exports = (common, options) => {
it('should get a node added as CIDv1 with a CIDv0', async () => {
const input = Buffer.from(`TEST${Math.random()}`)

const res = await all(ipfs.add(input, { cidVersion: 1, rawLeaves: false }))
const res = await all(importer([{ content: input }], ipfs.block, {
cidVersion: 1,
rawLeaves: false
}))

const cidv1 = res[0].cid
expect(cidv1.version).to.equal(1)
Expand Down
9 changes: 7 additions & 2 deletions packages/interface-ipfs-core/src/refs-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const { fixtures } = require('./utils')
const { getDescribe, getIt, expect } = require('./utils/mocha')
const all = require('it-all')
const importer = require('ipfs-unixfs-importer')

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

await all(ipfs.add(dirs))
const imported = await all(importer(dirs, ipfs.block))

const refs = await all(ipfs.refs.local())
// otherwise go-ipfs doesn't show them in the local refs
await Promise.all(
imported.map(i => ipfs.pin.add(i.cid))
)

const refs = await all(ipfs.refs.local())
const cids = refs.map(r => r.ref)
expect(cids).to.include('QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn')
expect(cids).to.include('QmR4nFjTu18TyANgC65ArNWp5Yaab1gPzQ4D8zp7Kx3vhr')
Expand Down

0 comments on commit b6521d0

Please sign in to comment.