You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
The primary goal of this module is to define and ensure that both IPFS core implementations and their respective HTTP client libraries offer the same interface, so that developers can quickly change between a local and a remote node without having to change their applications. In addition to the definition of the expected interface, this module offers a suite of tests that can be run in order to check if the interface is used as described.
The API is presented with both Node.js and Go primitives. However, there are no actual limitations keeping it from being extended for any other language, pushing forward cross compatibility and interoperability through different stacks.
Include this badge in your readme if you make a new module that implements interface-ipfs-core API.
[](https://github.com/ipfs/interface-ipfs-core)
Install
In JavaScript land:
npminstallinterface-ipfs-core
If you want to run these tests against a go-ipfs daemon, checkout ipfs-http-client and run test tests:
git clone https://github.com/ipfs/js-ipfs-http-client
npm install
npm test
Usage
Install interface-ipfs-core as one of the dependencies of your project and as a test file. Then, using mocha (for Node.js) or a test runner with compatible API, do:
consttests=require('interface-ipfs-core')constnodes=[]// Create common setup and teardownconstcreateCommon=()=>({// Do some setup common to all testssetup: async()=>{// Use ipfsd-ctl or other to spawn an IPFS node for testingconstnode=awaitspawnNode()nodes.push(node)returnnode.api},// Dispose of nodes created by the IPFS factory and any other teardownteardown: ()=>{returnPromise.all(nodes.map(n=>n.stop()))}})tests.block(createCommon)tests.config(createCommon)tests.dag(createCommon)// ...etc. (see src/index.js)
Running tests by command
tests.repo.version(createCommon)
Skipping tests
tests.repo.gc(createCommon,{skip: true})// pass an options object to skip these tests// OR, at the subsystem level// skips ALL the repo.gc teststests.repo(createCommon,{skip: ['gc']})// skips ALL the object.patch.addLink teststests.object(createCommon,{skip: ['patch.addLink']})
Skipping specific tests
tests.repo.gc(createCommon,{skip: ['should do a thing']})// named test(s) to skip// OR, at the subsystem leveltests.repo(createCommon,{skip: ['should do a thing']})
Running only some tests
tests.repo.gc(createCommon,{only: true})// pass an options object to run only these tests// OR, at the subsystem level// runs only ALL the repo.gc teststests.repo(createCommon,{only: ['gc']})// runs only ALL the object.patch.addLink teststests.object(createCommon,{only: ['patch.addLink']})
Running only specific tests
tests.repo.gc(createCommon,{only: ['should do a thing']})// only run these named test(s)// OR, at the subsystem leveltests.repo(createCommon,{only: ['should do a thing']})
API
In order to be considered "valid", an IPFS core implementation must expose the API described in /SPEC. You can also use this loose spec as documentation for consuming the core APIs. Here is an outline of the contents of that directory: