I’m building a library that will read/write to IPFS and I need to setup an integration test suite for it.
This is what I currently have (using Jest):
const IPFS = require("ipfs");
describe("IPFS integration", () => {
let node;
const startNode = () =>
new Promise(resolve => {
node = new IPFS();
node.on("ready", resolve);
node.on("error", (err) => console.error(err));
});
const stopNode = async () => {
await node.stop();
};
beforeAll(() => startNode());
afterAll(() => stopNode());
it("should show the IPFS node to be online", () => {
expect(node.isOnline()).toBe(true);
});
});
And this is the error that I get from my CI (node.isOnline()
actually returns false
):
console.error src/storage/ipfs/test/integration.ts:11
Error: No resolver found for codec "undefined"
at IPLDResolver.put (/home/travis/build/ethpm/ethpm.js/node_modules/ipld/src/index.js:221:23)
at DAGNode.create (/home/travis/build/ethpm/ethpm.js/node_modules/ipfs/src/core/components/object.js:137:20)
at multihashing (/home/travis/build/ethpm/ethpm.js/node_modules/ipfs/node_modules/ipld-dag-pb/src/dag-node/create.js:53:7)
at Multihashing.Multihashing.digest (/home/travis/build/ethpm/ethpm.js/node_modules/multihashing-async/src/index.js:33:5)
at setImmediate (/home/travis/build/ethpm/ethpm.js/node_modules/multihashing-async/src/utils.js:8:7)
at Immediate.<anonymous> (/home/travis/build/ethpm/ethpm.js/node_modules/async/internal/setImmediate.js:27:16)
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)
console.error node_modules/jest-jasmine2/build/jasmine/Env.js:157
Unhandled error
console.error node_modules/jest-jasmine2/build/jasmine/Env.js:158
Error: second argument must be a CID
at new Block (/home/travis/build/ethpm/ethpm.js/node_modules/ipfs-block/src/index.js:23:13)
at new Block (/home/travis/build/ethpm/ethpm.js/node_modules/class-is/index.js:15:17)
at store.get (/home/travis/build/ethpm/ethpm.js/node_modules/ipfs-repo/src/blockstore.js:84:24)
at fs.readFile (/home/travis/build/ethpm/ethpm.js/node_modules/datastore-fs/src/index.js:218:7)
at /home/travis/build/ethpm/ethpm.js/node_modules/graceful-fs/graceful-fs.js:78:16
at /home/travis/build/ethpm/ethpm.js/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
Is there a better way to test integration with IPFS?