diff --git a/CHANGELOG.md b/CHANGELOG.md index 56ae67346..9faade599 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ + +## [0.70.3](https://github.com/ipfs/interface-ipfs-core/compare/v0.70.2...v0.70.3) (2018-07-03) + + +### Bug Fixes + +* allow passing only to suites with skip lists ([#321](https://github.com/ipfs/interface-ipfs-core/issues/321)) ([c47c4ce](https://github.com/ipfs/interface-ipfs-core/commit/c47c4ce)) +* allow skip with object but no reason ([#318](https://github.com/ipfs/interface-ipfs-core/issues/318)) ([ef91026](https://github.com/ipfs/interface-ipfs-core/commit/ef91026)) +* license ([#312](https://github.com/ipfs/interface-ipfs-core/issues/312)) ([8fa3e98](https://github.com/ipfs/interface-ipfs-core/commit/8fa3e98)) + + + ## [0.70.2](https://github.com/ipfs/interface-ipfs-core/compare/v0.70.1...v0.70.2) (2018-06-29) diff --git a/LICENSE b/LICENSE index ff6874839..7d3787470 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 IPFS +Copyright (c) 2018 Protocol Labs, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 57ad20721..9561adf29 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,6 @@ This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/c ## License -MIT +Copyright (c) Protocol Labs, Inc. under the **MIT License**. See [LICENSE.md](./LICENSE.md) for details. [UnixFS]: https://github.com/ipfs/specs/tree/master/unixfs diff --git a/SPEC/DAG.md b/SPEC/DAG.md index 354e8a5d2..e97aa583c 100644 --- a/SPEC/DAG.md +++ b/SPEC/DAG.md @@ -15,11 +15,15 @@ ##### `JavaScript` - ipfs.dag.put(dagNode, options, callback) - `dagNode` - a DAG node that follows one of the supported IPLD formats. -- `options` - a object that might contain the follwing values: +- `options` - a object that might contain the following values: - `format` - The IPLD format multicodec. - `hashAlg` - The hash algorithm to be used over the serialized dagNode. - or - `cid` - the CID of the node passed. + - or + - if no `options` are given, `ipfs.dag.put()` uses the following defaults: + - `format: 'dag-cbor'` + - `hashAlg: 'sha2-256'` - **Note** - You should only pass the CID or the format + hashAlg pair and not both - `callback` must follow `function (err, cid) {}` signature, where `err` is an error if the operation was not successful and CID is the CID generated through the process or the one that was passed diff --git a/js/src/dag/put.js b/js/src/dag/put.js index 4f465984e..eb88abe50 100644 --- a/js/src/dag/put.js +++ b/js/src/dag/put.js @@ -5,6 +5,7 @@ const dagPB = require('ipld-dag-pb') const DAGNode = dagPB.DAGNode const dagCBOR = require('ipld-dag-cbor') const CID = require('cids') +const multihash = require('multihashes') const { spawnNodeWithId } = require('../utils/spawn') const { getDescribe, getIt, expect } = require('../utils/mocha') @@ -95,6 +96,19 @@ module.exports = (createCommon, options) => { }) }) + it('should not fail when calling put without options', (done) => { + ipfs.dag.put(cborNode, done) + }) + + it('should set defaults when calling put without options', (done) => { + ipfs.dag.put(cborNode, (err, cid) => { + expect(err).to.not.exist() + expect(cid.codec).to.equal('dag-cbor') + expect(multihash.decode(cid.multihash).name).to.equal('sha2-256') + done() + }) + }) + it.skip('should put by passing the cid instead of format and hashAlg', (done) => {}) // TODO it.skip('Promises support', (done) => {}) diff --git a/js/src/utils/mocha.js b/js/src/utils/mocha.js index 951e997a8..9ea71a0fa 100644 --- a/js/src/utils/mocha.js +++ b/js/src/utils/mocha.js @@ -8,15 +8,18 @@ chai.use(dirtyChai) module.exports.expect = chai.expect +const isObject = (o) => Object.prototype.toString.call(o) === '[object Object]' + // Get a "describe" function that is optionally 'skipped' or 'onlyed' // If skip/only are boolean true, or an object with a reason property, then we // want to skip/only the whole suite function getDescribe (config) { if (config) { - if (config.only === true) return describe.only if (config.skip === true) return describe.skip - if (config.skip && typeof config.skip === 'object' && config.skip.reason) { + if (isObject(config.skip)) { + if (!config.skip.reason) return describe.skip + const _describe = (name, impl) => { describe.skip(`${name} (${config.skip.reason})`, impl) } @@ -26,6 +29,8 @@ function getDescribe (config) { return _describe } + + if (config.only === true) return describe.only } return describe @@ -44,7 +49,7 @@ function getIt (config) { const _it = (name, impl) => { if (Array.isArray(config.skip)) { const skip = config.skip - .map((s) => s && typeof s === 'object' ? s : { name: s }) + .map((s) => isObject(s) ? s : { name: s }) .find((s) => s.name === name) if (skip) { diff --git a/js/src/utils/suite.js b/js/src/utils/suite.js index 7e2c88c6a..b2ad52687 100644 --- a/js/src/utils/suite.js +++ b/js/src/utils/suite.js @@ -1,5 +1,7 @@ 'use strict' +const isObject = (o) => Object.prototype.toString.call(o) === '[object Object]' + function createSuite (tests, parent) { const suite = (createCommon, options) => { Object.keys(tests).forEach(t => { @@ -8,7 +10,7 @@ function createSuite (tests, parent) { if (Array.isArray(opts.skip)) { const skip = opts.skip - .map((s) => s && typeof s === 'object' ? s : { name: s }) + .map((s) => isObject(s) ? s : { name: s }) .find((s) => s.name === suiteName) if (skip) { diff --git a/package.json b/package.json index ca1ebefaa..be6606105 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "interface-ipfs-core", - "version": "0.70.2", + "version": "0.70.3", "description": "A test suite and interface you can use to implement a IPFS core interface.", "leadMaintainer": "Alan Shaw ", "main": "js/src/index.js", @@ -78,6 +78,7 @@ "Mikeal Rogers ", "Nicolás Santángelo ", "Oli Evans ", + "Pascal Precht ", "Pedro Teixeira ", "Richard Littauer ", "Richard Schneider ", @@ -85,6 +86,7 @@ "Sangwon Hong ", "Stephen Whitmore ", "Thiago Delgado ", + "Travis Person ", "Travis Person ", "Vasco Santos ", "Volker Mische ",