|
| 1 | +/* eslint-env mocha */ |
| 2 | +'use strict' |
| 3 | + |
| 4 | +const tests = require('interface-ipfs-core') |
| 5 | +const CommonFactory = require('../utils/interface-common-factory') |
| 6 | +const isNode = require('detect-node') |
| 7 | + |
| 8 | +describe('interface-ipfs-core tests', () => { |
| 9 | + const defaultCommonFactory = CommonFactory.create() |
| 10 | + |
| 11 | + tests.bitswap(defaultCommonFactory, { skip: !isNode }) |
| 12 | + |
| 13 | + tests.block(defaultCommonFactory) |
| 14 | + |
| 15 | + tests.bootstrap(defaultCommonFactory) |
| 16 | + |
| 17 | + tests.config(defaultCommonFactory) |
| 18 | + |
| 19 | + tests.dag(defaultCommonFactory) |
| 20 | + |
| 21 | + tests.dht(defaultCommonFactory, { |
| 22 | + skip: { reason: 'TODO: DHT is not implemented in js-ipfs yet!' } |
| 23 | + }) |
| 24 | + |
| 25 | + tests.files(defaultCommonFactory, { |
| 26 | + skip: [ |
| 27 | + { |
| 28 | + name: 'cp', |
| 29 | + reason: 'TODO: MFS is not implemented in js-ipfs yet!' |
| 30 | + }, |
| 31 | + { |
| 32 | + name: 'mkdir', |
| 33 | + reason: 'TODO: MFS is not implemented in js-ipfs yet!' |
| 34 | + }, |
| 35 | + { |
| 36 | + name: 'stat', |
| 37 | + reason: 'TODO: MFS is not implemented in js-ipfs yet!' |
| 38 | + }, |
| 39 | + { |
| 40 | + name: 'rm', |
| 41 | + reason: 'TODO: MFS is not implemented in js-ipfs yet!' |
| 42 | + }, |
| 43 | + { |
| 44 | + name: 'read', |
| 45 | + reason: 'TODO: MFS is not implemented in js-ipfs yet!' |
| 46 | + }, |
| 47 | + { |
| 48 | + name: 'readReadableStream', |
| 49 | + reason: 'TODO: MFS is not implemented in js-ipfs yet!' |
| 50 | + }, |
| 51 | + { |
| 52 | + name: 'readPullStream', |
| 53 | + reason: 'TODO: MFS is not implemented in js-ipfs yet!' |
| 54 | + }, |
| 55 | + { |
| 56 | + name: 'write', |
| 57 | + reason: 'TODO: MFS is not implemented in js-ipfs yet!' |
| 58 | + }, |
| 59 | + { |
| 60 | + name: 'mv', |
| 61 | + reason: 'TODO: MFS is not implemented in js-ipfs yet!' |
| 62 | + }, |
| 63 | + { |
| 64 | + name: 'flush', |
| 65 | + reason: 'TODO: MFS is not implemented in js-ipfs yet!' |
| 66 | + }, |
| 67 | + { |
| 68 | + name: 'ls', |
| 69 | + reason: 'TODO: MFS is not implemented in js-ipfs yet!' |
| 70 | + } |
| 71 | + ] |
| 72 | + }) |
| 73 | + |
| 74 | + tests.key(CommonFactory.create({ |
| 75 | + spawnOptions: { |
| 76 | + args: ['--pass ipfs-is-awesome-software'], |
| 77 | + initOptions: { bits: 512 } |
| 78 | + } |
| 79 | + })) |
| 80 | + |
| 81 | + tests.ls(defaultCommonFactory) |
| 82 | + |
| 83 | + tests.miscellaneous(CommonFactory.create({ |
| 84 | + // No need to stop, because the test suite does a 'stop' test. |
| 85 | + createTeardown: () => cb => cb() |
| 86 | + })) |
| 87 | + |
| 88 | + tests.object(defaultCommonFactory) |
| 89 | + |
| 90 | + tests.pin(defaultCommonFactory) |
| 91 | + |
| 92 | + tests.ping(defaultCommonFactory, { |
| 93 | + skip: isNode ? null : { |
| 94 | + reason: 'FIXME: ping implementation requires DHT' |
| 95 | + } |
| 96 | + }) |
| 97 | + |
| 98 | + tests.pubsub(CommonFactory.create({ |
| 99 | + spawnOptions: { |
| 100 | + args: ['--enable-pubsub-experiment'], |
| 101 | + initOptions: { bits: 512 } |
| 102 | + } |
| 103 | + }), { |
| 104 | + skip: isNode ? null : { |
| 105 | + reason: 'FIXME: disabled because no swarm addresses' |
| 106 | + } |
| 107 | + }) |
| 108 | + |
| 109 | + tests.repo(defaultCommonFactory, { |
| 110 | + skip: [ |
| 111 | + // repo.gc |
| 112 | + { |
| 113 | + name: 'gc', |
| 114 | + reason: 'TODO: repo.gc is not implemented in js-ipfs yet!' |
| 115 | + } |
| 116 | + ] |
| 117 | + }) |
| 118 | + |
| 119 | + tests.stats(defaultCommonFactory) |
| 120 | + |
| 121 | + tests.swarm(CommonFactory.create({ |
| 122 | + createSetup ({ ipfsFactory, nodes }) { |
| 123 | + return callback => { |
| 124 | + callback(null, { |
| 125 | + spawnNode (repoPath, config, cb) { |
| 126 | + if (typeof repoPath === 'function') { |
| 127 | + cb = repoPath |
| 128 | + repoPath = undefined |
| 129 | + } |
| 130 | + |
| 131 | + if (typeof config === 'function') { |
| 132 | + cb = config |
| 133 | + config = undefined |
| 134 | + } |
| 135 | + |
| 136 | + const spawnOptions = { repoPath, config, initOptions: { bits: 512 } } |
| 137 | + |
| 138 | + ipfsFactory.spawn(spawnOptions, (err, _ipfsd) => { |
| 139 | + if (err) { |
| 140 | + return cb(err) |
| 141 | + } |
| 142 | + |
| 143 | + nodes.push(_ipfsd) |
| 144 | + cb(null, _ipfsd.api) |
| 145 | + }) |
| 146 | + } |
| 147 | + }) |
| 148 | + } |
| 149 | + } |
| 150 | + }), { skip: !isNode }) |
| 151 | + |
| 152 | + tests.types(defaultCommonFactory, { skip: { reason: 'FIXME: currently failing' } }) |
| 153 | + |
| 154 | + tests.util(defaultCommonFactory, { skip: { reason: 'FIXME: currently failing' } }) |
| 155 | +}) |
0 commit comments