UNPKG

interface-ipfs-core

Version:

A test suite and interface you can use to implement a IPFS core interface.

46 lines (35 loc) 1.12 kB
/* eslint-env mocha */ import { nanoid } from 'nanoid' import { expect } from 'aegir/chai' import { getDescribe, getIt } from '../utils/mocha.js' /** * @typedef {import('ipfsd-ctl').Factory} Factory */ /** * @param {Factory} factory * @param {object} options */ export function testList (factory, options) { const describe = getDescribe(options) const it = getIt(options) describe('.key.list', () => { /** @type {import('ipfs-core-types').IPFS} */ let ipfs before(async () => { ipfs = (await factory.spawn()).api }) after(() => factory.clean()) it('should list all the keys', async function () { this.timeout(60 * 1000) const keys = await Promise.all([1, 2, 3].map(() => ipfs.key.gen(nanoid(), { type: 'rsa', size: 2048 }))) const res = await ipfs.key.list() expect(res).to.exist() expect(res).to.be.an('array') expect(res.length).to.be.above(keys.length - 1) keys.forEach(key => { const found = res.find(({ id, name }) => name === key.name && id === key.id) expect(found).to.exist() }) }) }) }