This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add support for resolving to the middle of an IPLD block
- Loading branch information
Showing
2 changed files
with
70 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* eslint max-nested-callbacks: ["error", 8] */ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
const dirtyChai = require('dirty-chai') | ||
const expect = chai.expect | ||
chai.use(dirtyChai) | ||
|
||
const IPFSFactory = require('ipfsd-ctl') | ||
const IPFS = require('../../src/core') | ||
|
||
describe('resolve', () => { | ||
let ipfsd, ipfs | ||
|
||
before(function (done) { | ||
this.timeout(20 * 1000) | ||
|
||
const factory = IPFSFactory.create({ type: 'proc' }) | ||
|
||
factory.spawn({ | ||
exec: IPFS, | ||
initOptions: { bits: 512 }, | ||
config: { Bootstrap: [] } | ||
}, (err, _ipfsd) => { | ||
expect(err).to.not.exist() | ||
ipfsd = _ipfsd | ||
ipfs = _ipfsd.api | ||
done() | ||
}) | ||
}) | ||
|
||
after((done) => { | ||
if (ipfsd) { | ||
ipfsd.stop(done) | ||
} else { | ||
done() | ||
} | ||
}) | ||
|
||
it('should resolve an IPFS path non-link', (done) => { | ||
const content = { path: { to: { file: 'foobar' } } } | ||
const options = { format: 'dag-cbor', hashAlg: 'sha2-256' } | ||
|
||
ipfs.dag.put(content, options, (err, cid) => { | ||
expect(err).to.not.exist() | ||
|
||
// FIXME: This should be /ipld/... but that's not supported yet. | ||
const path = `/ipfs/${cid.toBaseEncodedString()}/path/to/file` | ||
ipfs.resolve(path, (err, resolved) => { | ||
expect(err).to.not.exist() | ||
expect(resolved).to.equal(path) | ||
done() | ||
}) | ||
}) | ||
}) | ||
}) |