diff --git a/package.json b/package.json index ffea9bc97a..6fe068e095 100644 --- a/package.json +++ b/package.json @@ -127,10 +127,10 @@ "joi": "^13.4.0", "joi-browser": "^13.4.0", "joi-multiaddr": "^3.0.0", - "libp2p": "~0.24.0", + "libp2p": "~0.24.1", "libp2p-bootstrap": "~0.9.3", "libp2p-crypto": "~0.14.1", - "libp2p-kad-dht": "~0.11.1", + "libp2p-kad-dht": "~0.12.1", "libp2p-keychain": "~0.3.3", "libp2p-mdns": "~0.12.0", "libp2p-mplex": "~0.8.4", diff --git a/src/core/components/init.js b/src/core/components/init.js index 51c197e977..29cac89402 100644 --- a/src/core/components/init.js +++ b/src/core/components/init.js @@ -117,7 +117,7 @@ module.exports = function init (self) { (_, cb) => { const offlineDatastore = new OfflineDatastore(self._repo) - self._ipns = new IPNS(offlineDatastore, self._repo, self._peerInfo, self._keychain, self._options) + self._ipns = new IPNS(offlineDatastore, self._repo.datastore, self._peerInfo, self._keychain, self._options) cb(null, true) }, // add empty unixfs dir object (go-ipfs assumes this exists) diff --git a/src/core/components/libp2p.js b/src/core/components/libp2p.js index 87838cb1e7..d195623467 100644 --- a/src/core/components/libp2p.js +++ b/src/core/components/libp2p.js @@ -3,6 +3,7 @@ const promisify = require('promisify-es6') const get = require('lodash/get') const defaultsDeep = require('@nodeutils/defaults-deep') +const ipnsUtils = require('../ipns/routing/utils') module.exports = function libp2p (self) { return { @@ -16,6 +17,7 @@ module.exports = function libp2p (self) { const defaultBundle = (opts) => { const libp2pDefaults = { + datastore: opts.datastore, peerInfo: opts.peerInfo, peerBook: opts.peerBook, config: { @@ -43,6 +45,14 @@ module.exports = function libp2p (self) { get(opts.config, 'relay.hop.active', false)) } }, + dht: { + validators: { + ipns: ipnsUtils.validator + }, + selectors: { + ipns: ipnsUtils.selector + } + }, EXPERIMENTAL: { dht: get(opts.options, 'EXPERIMENTAL.dht', false), pubsub: get(opts.options, 'EXPERIMENTAL.pubsub', false) @@ -72,6 +82,7 @@ module.exports = function libp2p (self) { self._libp2pNode = libp2pBundle({ options: self._options, config: config, + datastore: self._repo.datastore, peerInfo: self._peerInfo, peerBook: self._peerInfoBook }) diff --git a/src/core/components/start.js b/src/core/components/start.js index 8a8fe10a85..95befc849b 100644 --- a/src/core/components/start.js +++ b/src/core/components/start.js @@ -54,14 +54,18 @@ module.exports = (self) => { ipnsStores.push(pubsubDs) } - // NOTE: IPNS routing is being replaced by the local repo datastore while the IPNS over DHT is not ready - // When DHT is added, if local option enabled, should receive offlineDatastore as well - const offlineDatastore = new OfflineDatastore(self._repo) - ipnsStores.push(offlineDatastore) + // DHT should be added as routing if we are not running with local flag + // TODO: Need to change this logic once DHT is enabled by default, for now fallback to Offline datastore + if (get(self._options, 'EXPERIMENTAL.dht', false) && !self._options.local) { + ipnsStores.push(self._libp2pNode.dht) + } else { + const offlineDatastore = new OfflineDatastore(self._repo) + ipnsStores.push(offlineDatastore) + } // Create ipns routing with a set of datastores const routing = new TieredDatastore(ipnsStores) - self._ipns = new IPNS(routing, self._repo, self._peerInfo, self._keychain, self._options) + self._ipns = new IPNS(routing, self._repo.datastore, self._peerInfo, self._keychain, self._options) self._bitswap = new Bitswap( self._libp2pNode, diff --git a/src/core/ipns/index.js b/src/core/ipns/index.js index 06b43ca330..03962ba03c 100644 --- a/src/core/ipns/index.js +++ b/src/core/ipns/index.js @@ -17,9 +17,9 @@ const path = require('./path') const defaultRecordTtl = 60 * 1000 class IPNS { - constructor (routing, repo, peerInfo, keychain, options) { - this.publisher = new IpnsPublisher(routing, repo) - this.republisher = new IpnsRepublisher(this.publisher, repo, peerInfo, keychain, options) + constructor (routing, datastore, peerInfo, keychain, options) { + this.publisher = new IpnsPublisher(routing, datastore) + this.republisher = new IpnsRepublisher(this.publisher, datastore, peerInfo, keychain, options) this.resolver = new IpnsResolver(routing) this.cache = new Receptacle({ max: 1000 }) // Create an LRU cache with max 1000 items this.routing = routing diff --git a/src/core/ipns/publisher.js b/src/core/ipns/publisher.js index 4be4fc41bb..8cc6cbb418 100644 --- a/src/core/ipns/publisher.js +++ b/src/core/ipns/publisher.js @@ -15,9 +15,9 @@ const defaultRecordTtl = 60 * 60 * 1000 // IpnsPublisher is capable of publishing and resolving names to the IPFS routing system. class IpnsPublisher { - constructor (routing, repo) { + constructor (routing, datastore) { this._routing = routing - this._repo = repo + this._datastore = datastore } // publish record with a eol @@ -56,7 +56,6 @@ class IpnsPublisher { log.error(errMsg) return callback(errcode(new Error(errMsg), 'ERR_INVALID_PEER_ID')) } - const publicKey = peerId._pubKey ipns.embedPublicKey(publicKey, record, (err, embedPublicKeyRecord) => { @@ -74,9 +73,10 @@ class IpnsPublisher { series([ (cb) => this._publishEntry(keys.routingKey, embedPublicKeyRecord || record, peerId, cb), - // Publish the public key if a public key cannot be extracted from the ID - // We will be able to deprecate this part in the future, since the public keys will be only in the peerId - (cb) => embedPublicKeyRecord ? this._publishPublicKey(keys.routingPubKey, publicKey, peerId, cb) : cb() + // Publish the public key to support old go-ipfs nodes that are looking for it in the routing + // We will be able to deprecate this part in the future, since the public keys will be only + // in IPNS record and the peerId. + (cb) => this._publishPublicKey(keys.routingPubKey, publicKey, peerId, cb) ], (err) => { if (err) { log.error(err) @@ -159,50 +159,57 @@ class IpnsPublisher { } options = options || {} - const checkRouting = !(options.checkRouting === false) - - this._repo.datastore.get(ipns.getLocalKey(peerId.id), (err, dsVal) => { - let result + const checkRouting = options.checkRouting !== false + this._datastore.get(ipns.getLocalKey(peerId.id), (err, dsVal) => { if (err) { if (err.code !== 'ERR_NOT_FOUND') { const errMsg = `unexpected error getting the ipns record ${peerId.id} from datastore` log.error(errMsg) return callback(errcode(new Error(errMsg), 'ERR_UNEXPECTED_DATASTORE_RESPONSE')) - } else { - if (!checkRouting) { - return callback(null, null) - } else { - // TODO ROUTING - get from DHT - return callback(new Error('not implemented yet')) - } } - } - if (Buffer.isBuffer(dsVal)) { - result = dsVal - } else { - const errMsg = `found ipns record that we couldn't convert to a value` + if (!checkRouting) { + return callback((errcode(err))) + } - log.error(errMsg) - return callback(errcode(new Error(errMsg), 'ERR_INVALID_IPNS_RECORD')) - } + // Try to get from routing + let keys + try { + keys = ipns.getIdKeys(peerId.toBytes()) + } catch (err) { + log.error(err) + return callback(err) + } - // unmarshal data - try { - result = ipns.unmarshal(dsVal) - } catch (err) { - const errMsg = `found ipns record that we couldn't convert to a value` + this._routing.get(keys.routingKey.toBuffer(), (err, res) => { + if (err) { + return callback(err) + } - log.error(errMsg) - return callback(null, null) + // unmarshal data + this._unmarshalData(res, callback) + }) + } else { + // unmarshal data + this._unmarshalData(dsVal, callback) } - - callback(null, result) }) } + _unmarshalData (data, callback) { + let result + try { + result = ipns.unmarshal(data) + } catch (err) { + log.error(err) + return callback(errcode(err, 'ERR_INVALID_RECORD_DATA')) + } + + callback(null, result) + } + _updateOrCreateRecord (privKey, value, validity, peerId, callback) { if (!(PeerId.isPeerId(peerId))) { const errMsg = `peerId received is not valid` @@ -212,12 +219,17 @@ class IpnsPublisher { } const getPublishedOptions = { - checkRouting: false // TODO ROUTING - change to true + checkRouting: true } this._getPublished(peerId, getPublishedOptions, (err, record) => { if (err) { - return callback(err) + if (err.code !== 'ERR_NOT_FOUND') { + const errMsg = `unexpected error when determining the last published IPNS record for ${peerId.id}` + + log.error(errMsg) + return callback(errcode(new Error(errMsg), 'ERR_DETERMINING_PUBLISHED_RECORD')) + } } // Determinate the record sequence number @@ -241,7 +253,7 @@ class IpnsPublisher { const data = ipns.marshal(entryData) // Store the new record - this._repo.datastore.put(ipns.getLocalKey(peerId.id), data, (err, res) => { + this._datastore.put(ipns.getLocalKey(peerId.id), data, (err, res) => { if (err) { const errMsg = `ipns record for ${value} could not be stored in the datastore` diff --git a/src/core/ipns/republisher.js b/src/core/ipns/republisher.js index 150cb313d7..31dab0f253 100644 --- a/src/core/ipns/republisher.js +++ b/src/core/ipns/republisher.js @@ -18,9 +18,9 @@ const defaultBroadcastInterval = 4 * hour const defaultRecordLifetime = 24 * hour class IpnsRepublisher { - constructor (publisher, repo, peerInfo, keychain, options) { + constructor (publisher, datastore, peerInfo, keychain, options) { this._publisher = publisher - this._repo = repo + this._datastore = datastore this._peerInfo = peerInfo this._keychain = keychain this._options = options @@ -160,7 +160,7 @@ class IpnsRepublisher { return callback(errcode(new Error(errMsg), 'ERR_INVALID_PEER_ID')) } - this._repo.datastore.get(ipns.getLocalKey(peerId.id), (err, dsVal) => { + this._datastore.get(ipns.getLocalKey(peerId.id), (err, dsVal) => { // error handling // no need to republish if (err && err.notFound) { diff --git a/src/core/ipns/resolver.js b/src/core/ipns/resolver.js index 8ff9c38ab3..e72aee090e 100644 --- a/src/core/ipns/resolver.js +++ b/src/core/ipns/resolver.js @@ -1,6 +1,7 @@ 'use strict' const ipns = require('ipns') +const crypto = require('libp2p-crypto') const PeerId = require('peer-id') const errcode = require('err-code') @@ -96,13 +97,9 @@ class IpnsResolver { return callback(err) } - const { routingKey } = ipns.getIdKeys(peerId.toBytes()) + const { routingKey, routingPubKey } = ipns.getIdKeys(peerId.toBytes()) - // TODO DHT - get public key from routing? - // https://github.com/ipfs/go-ipfs/blob/master/namesys/routing.go#L70 - // https://github.com/libp2p/go-libp2p-routing/blob/master/routing.go#L99 - - this._routing.get(routingKey.toBuffer(), (err, res) => { + this._routing.get(routingKey.toBuffer(), (err, record) => { if (err) { if (err.code !== 'ERR_NOT_FOUND') { const errMsg = `unexpected error getting the ipns record ${peerId.id}` @@ -116,9 +113,10 @@ class IpnsResolver { return callback(errcode(new Error(errMsg), 'ERR_NO_RECORD_FOUND')) } + // IPNS entry let ipnsEntry try { - ipnsEntry = ipns.unmarshal(res) + ipnsEntry = ipns.unmarshal(record) } catch (err) { const errMsg = `found ipns record that we couldn't convert to a value` @@ -126,19 +124,55 @@ class IpnsResolver { return callback(errcode(new Error(errMsg), 'ERR_INVALID_RECORD_RECEIVED')) } - ipns.extractPublicKey(peerId, ipnsEntry, (err, pubKey) => { + // if the record has a public key validate it + if (ipnsEntry.pubKey) { + return this._validateRecord(peerId, ipnsEntry, callback) + } + + // Otherwise, try to get the public key from routing + this._routing.get(routingKey.toBuffer(), (err, pubKey) => { if (err) { - return callback(err) - } + if (err.code !== 'ERR_NOT_FOUND') { + const errMsg = `unexpected error getting the public key for the ipns record ${peerId.id}` - // IPNS entry validation - ipns.validate(pubKey, ipnsEntry, (err) => { - if (err) { - return callback(err) + log.error(errMsg) + return callback(errcode(new Error(errMsg), 'ERR_UNEXPECTED_ERROR_GETTING_PUB_KEY')) } + const errMsg = `public key requested was not found for ${name} (${routingPubKey}) in the network` + + log.error(errMsg) + return callback(errcode(new Error(errMsg), 'ERR_NO_RECORD_FOUND')) + } + + try { + // Insert it into the peer id, in order to be validated by IPNS validator + peerId.pubKey = crypto.keys.unmarshalPublicKey(pubKey) + } catch (err) { + const errMsg = `found public key record that we couldn't convert to a value` + + log.error(errMsg) + return callback(errcode(new Error(errMsg), 'ERR_INVALID_PUB_KEY_RECEIVED')) + } + + this._validateRecord(peerId, ipnsEntry, callback) + }) + }) + } + + // validate a resolved record + _validateRecord (peerId, ipnsEntry, callback) { + ipns.extractPublicKey(peerId, ipnsEntry, (err, pubKey) => { + if (err) { + return callback(err) + } + + // IPNS entry validation + ipns.validate(pubKey, ipnsEntry, (err) => { + if (err) { + return callback(err) + } - callback(null, ipnsEntry.value.toString()) - }) + callback(null, ipnsEntry.value.toString()) }) }) } diff --git a/src/core/ipns/routing/utils.js b/src/core/ipns/routing/utils.js index 9dc8b8b992..0d960618ce 100644 --- a/src/core/ipns/routing/utils.js +++ b/src/core/ipns/routing/utils.js @@ -1,9 +1,16 @@ 'use strict' const multibase = require('multibase') +const ipns = require('ipns') -module.exports.encodeBase32 = (buf) => { - const m = multibase.encode('base32', buf).slice(1) // slice off multibase codec +module.exports = { + encodeBase32: (buf) => { + const m = multibase.encode('base32', buf).slice(1) // slice off multibase codec - return m.toString().toUpperCase() // should be uppercase for interop with go + return m.toString().toUpperCase() // should be uppercase for interop with go + }, + validator: { + func: (key, record, cb) => ipns.validator.validate(record, key, cb) + }, + selector: (k, records) => ipns.validator.select(records[0], records[1]) } diff --git a/test/cli/name.js b/test/cli/name.js index 3acfb7b089..20aaca8400 100644 --- a/test/cli/name.js +++ b/test/cli/name.js @@ -16,169 +16,282 @@ const df = DaemonFactory.create({ type: 'js' }) const checkAll = (bits) => string => bits.every(bit => string.includes(bit)) describe('name', () => { - const passPhrase = hat() - const pass = '--pass ' + passPhrase - const name = 'test-key-' + hat() + describe('working locally', () => { + const passPhrase = hat() + const pass = '--pass ' + passPhrase + const name = 'test-key-' + hat() + + let ipfs + let ipfsd + + let cidAdded + let nodeId + let keyId + + before(function (done) { + this.timeout(80 * 1000) + + df.spawn({ + exec: `./src/cli/bin.js`, + config: { + Bootstrap: [] + }, + args: ['--pass', passPhrase, '--local'], + initOptions: { bits: 512 } + }, (err, _ipfsd) => { + expect(err).to.not.exist() + + ipfsd = _ipfsd + ipfs = ipfsExec(_ipfsd.repoPath) + + ipfs(`${pass} key gen ${name} --type rsa --size 2048`) + .then((out) => { + expect(out).to.include(name) + keyId = out.split(' ')[1] + + return ipfs('id') + }) + .then((res) => { + const id = JSON.parse(res) + expect(id).to.have.property('id') + nodeId = id.id - let ipfs - let ipfsd + return ipfs('add src/init-files/init-docs/readme') + }) + .then((out) => { + cidAdded = out.split(' ')[1] + done() + }) + }) + }) - let cidAdded - let nodeId - let keyId + after(function (done) { + if (ipfsd) { + ipfsd.stop(() => done()) + } else { + done() + } + }) - before(function (done) { - this.timeout(80 * 1000) + it('should publish correctly when the file was already added', function () { + this.timeout(60 * 1000) - df.spawn({ - exec: `./src/cli/bin.js`, - config: { - Bootstrap: [] - }, - args: ['--pass', passPhrase, '--local'], - initOptions: { bits: 512 } - }, (err, _ipfsd) => { - expect(err).to.not.exist() + return ipfs(`name publish ${cidAdded}`).then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([cidAdded, nodeId])) + }) + }) - ipfsd = _ipfsd - ipfs = ipfsExec(_ipfsd.repoPath) + it('should publish and resolve an entry with the default options', function () { + this.timeout(60 * 1000) - ipfs(`${pass} key gen ${name} --type rsa --size 2048`).then((out) => { - expect(out).to.include(name) + return ipfs(`name publish ${cidAdded}`) + .then((res) => { + expect(res).to.exist() - keyId = out.split(' ')[1] + return ipfs('name resolve') + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([cidAdded])) + }) + }) - ipfs('id').then((res) => { - const id = JSON.parse(res) + it('should publish correctly when the file was not added but resolve is disabled', function () { + this.timeout(60 * 1000) - expect(id).to.have.property('id') - nodeId = id.id + const notAddedCid = 'QmPFVLPmp9zv5Z5KUqLhe2EivAGccQW2r7M7jhVJGLZoZU' - ipfs('add src/init-files/init-docs/readme').then((out) => { - cidAdded = out.split(' ')[1] - done() - }) - }) + return ipfs(`name publish ${notAddedCid} --resolve false`).then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([notAddedCid, nodeId])) }) }) - }) - after(function (done) { - if (ipfsd) { - ipfsd.stop(() => done()) - } else { - done() - } - }) + it('should not get the entry correctly if its validity time expired', function () { + this.timeout(60 * 1000) - it('should publish correctly when the file was already added', function (done) { - this.timeout(60 * 1000) + return ipfs(`name publish ${cidAdded} --lifetime 10ns`) + .then((res) => { + expect(res).to.exist() - ipfs(`name publish ${cidAdded}`).then((res) => { - expect(res).to.exist() - expect(res).to.satisfy(checkAll([cidAdded, nodeId])) + setTimeout(function () { + return ipfs('name resolve') + .then((res) => { + expect(res).to.not.exist() + }) + .catch((err) => { + expect(err).to.exist() + }) + }, 1) + }) + }) + + it('should publish correctly when a new key is used', function () { + this.timeout(60 * 1000) - done() + return ipfs(`name publish ${cidAdded} --key ${name}`).then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([cidAdded, keyId])) + }) }) - }) - it('should publish and resolve an entry with the default options', function (done) { - this.timeout(60 * 1000) + it('should return the immediate pointing record, unless using the recursive parameter', function () { + this.timeout(60 * 1000) - ipfs(`name publish ${cidAdded}`).then((res) => { - expect(res).to.exist() + return ipfs(`name publish ${cidAdded}`) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([cidAdded, nodeId])) - ipfs('name resolve').then((res) => { - expect(res).to.exist() - expect(res).to.satisfy(checkAll([cidAdded])) + return ipfs(`name publish /ipns/${nodeId} --key ${name}`) + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([nodeId, keyId])) - done() - }) + return ipfs(`name resolve ${keyId}`) + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([nodeId])) + }) }) - }) - it('should publish correctly when the file was not added but resolve is disabled', function (done) { - this.timeout(60 * 1000) + it('should go recursively until finding an ipfs hash', function () { + this.timeout(60 * 1000) - const notAddedCid = 'QmPFVLPmp9zv5Z5KUqLhe2EivAGccQW2r7M7jhVJGLZoZU' + return ipfs(`name publish ${cidAdded}`) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([cidAdded, nodeId])) - ipfs(`name publish ${notAddedCid} --resolve false`).then((res) => { - expect(res).to.exist() - expect(res).to.satisfy(checkAll([notAddedCid, nodeId])) + return ipfs(`name publish /ipns/${nodeId} --key ${name}`) + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([nodeId, keyId])) - done() + return ipfs(`name resolve ${keyId} --recursive`) + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([cidAdded])) + }) }) }) - it('should not get the entry correctly if its validity time expired', function (done) { - this.timeout(60 * 1000) + describe('using dht', () => { + const passPhrase = hat() + const pass = '--pass ' + passPhrase + const name = 'test-key-' + hat() + + let ipfs + let ipfsd + + let cidAdded + let nodeId + let keyId + + before(function (done) { + this.timeout(80 * 1000) - ipfs(`name publish ${cidAdded} --lifetime 10ns`).then((res) => { - expect(res).to.exist() + df.spawn({ + exec: `./src/cli/bin.js`, + config: { + Bootstrap: [] + }, + args: ['--pass', passPhrase, '--enable-dht-experiment'], + initOptions: { bits: 512 } + }, (err, _ipfsd) => { + expect(err).to.not.exist() - setTimeout(function () { - ipfs('name resolve') + ipfsd = _ipfsd + ipfs = ipfsExec(_ipfsd.repoPath) + + ipfs(`${pass} key gen ${name} --type rsa --size 2048`) + .then((out) => { + expect(out).to.include(name) + keyId = out.split(' ')[1] + + return ipfs('id') + }) .then((res) => { - expect(res).to.not.exist() + const id = JSON.parse(res) + expect(id).to.have.property('id') + nodeId = id.id + + return ipfs('add src/init-files/init-docs/readme') }) - .catch((err) => { - expect(err).to.exist() + .then((out) => { + cidAdded = out.split(' ')[1] done() }) - }, 1) + }) }) - }) - - it('should publish correctly when a new key is used', function (done) { - this.timeout(60 * 1000) - ipfs(`name publish ${cidAdded} --key ${name}`).then((res) => { - expect(res).to.exist() - expect(res).to.satisfy(checkAll([cidAdded, keyId])) - - done() + after(function (done) { + if (ipfsd) { + ipfsd.stop(() => done()) + } else { + done() + } }) - }) - it('should return the immediate pointing record, unless using the recursive parameter', function (done) { - this.timeout(60 * 1000) + it('should publish and resolve an entry with the default options', function () { + this.timeout(60 * 1000) - ipfs(`name publish ${cidAdded}`).then((res) => { - expect(res).to.exist() - expect(res).to.satisfy(checkAll([cidAdded, nodeId])) + return ipfs(`name publish ${cidAdded}`) + .then((res) => { + expect(res).to.exist() - ipfs(`name publish /ipns/${nodeId} --key ${name}`).then((res) => { - expect(res).to.exist() - expect(res).to.satisfy(checkAll([nodeId, keyId])) + return ipfs('name resolve') + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([cidAdded])) + }) + }) + + it('should not get the entry correctly if its validity time expired', function () { + this.timeout(60 * 1000) - ipfs(`name resolve ${keyId}`).then((res) => { + return ipfs(`name publish ${cidAdded} --lifetime 10ns`) + .then((res) => { expect(res).to.exist() - expect(res).to.satisfy(checkAll([nodeId])) - done() + setTimeout(function () { + return ipfs('name resolve') + .then((res) => { + expect(res).to.not.exist() + }) + .catch((err) => { + expect(err).to.exist() + }) + }, 1) }) - }) }) - }) - - it('should go recursively until finding an ipfs hash', function (done) { - this.timeout(60 * 1000) - ipfs(`name publish ${cidAdded}`).then((res) => { - expect(res).to.exist() - expect(res).to.satisfy(checkAll([cidAdded, nodeId])) + it('should return the immediate pointing record, unless using the recursive parameter', function () { + this.timeout(60 * 1000) - ipfs(`name publish /ipns/${nodeId} --key ${name}`).then((res) => { - expect(res).to.exist() - expect(res).to.satisfy(checkAll([nodeId, keyId])) + return ipfs(`name publish ${cidAdded}`) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([cidAdded, nodeId])) - ipfs(`name resolve ${keyId} --recursive`).then((res) => { + return ipfs(`name publish /ipns/${nodeId} --key ${name}`) + }) + .then((res) => { expect(res).to.exist() - expect(res).to.satisfy(checkAll([cidAdded])) + expect(res).to.satisfy(checkAll([nodeId, keyId])) - done() + return ipfs(`name resolve ${keyId}`) + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([nodeId])) }) - }) }) }) }) diff --git a/test/core/libp2p.spec.js b/test/core/libp2p.spec.js index 19248eb535..aacc4215a3 100644 --- a/test/core/libp2p.spec.js +++ b/test/core/libp2p.spec.js @@ -7,6 +7,7 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const MemoryStore = require('interface-datastore').MemoryDatastore const PeerInfo = require('peer-info') const PeerBook = require('peer-book') const WebSocketStar = require('libp2p-websocket-star') @@ -20,6 +21,7 @@ describe('libp2p customization', function () { // Provide some extra time for ci since we're starting libp2p nodes in each test this.timeout(15 * 1000) + let datastore let peerInfo let peerBook let mockConfig @@ -49,6 +51,7 @@ describe('libp2p customization', function () { }) } } + datastore = new MemoryStore() peerBook = new PeerBook() PeerInfo.create((err, pi) => { peerInfo = pi @@ -68,6 +71,9 @@ describe('libp2p customization', function () { describe('bundle', () => { it('should allow for using a libp2p bundle', (done) => { const ipfs = { + _repo: { + datastore + }, _peerInfo: peerInfo, _peerBook: peerBook, config: mockConfig, @@ -111,6 +117,9 @@ describe('libp2p customization', function () { describe('options', () => { it('should use options by default', (done) => { const ipfs = { + _repo: { + datastore + }, _peerInfo: peerInfo, _peerBook: peerBook, config: mockConfig @@ -150,6 +159,9 @@ describe('libp2p customization', function () { const wsstar = new WebSocketStar({ id: peerInfo.id }) const ipfs = { + _repo: { + datastore + }, _peerInfo: peerInfo, _peerBook: peerBook, config: mockConfig, diff --git a/test/core/name.js b/test/core/name.js index 08bb9b06da..2bf0119f09 100644 --- a/test/core/name.js +++ b/test/core/name.js @@ -10,6 +10,8 @@ chai.use(dirtyChai) const sinon = require('sinon') const fs = require('fs') +const parallel = require('async/parallel') +const series = require('async/series') const isNode = require('detect-node') const IPFS = require('../../src') @@ -21,6 +23,19 @@ const df = DaemonFactory.create({ type: 'proc' }) const ipfsRef = '/ipfs/QmPFVLPmp9zv5Z5KUqLhe2EivAGccQW2r7M7jhVJGLZoZU' +const publishAndResolve = (publisher, resolver, ipfsRef, publishOpts, nodeId, resolveOpts, callback) => { + series([ + (cb) => publisher.name.publish(ipfsRef, publishOpts, cb), + (cb) => resolver.name.resolve(nodeId, resolveOpts, cb) + ], (err, res) => { + expect(err).to.not.exist() + expect(res[0]).to.exist() + expect(res[1]).to.exist() + expect(res[1].path).to.equal(ipfsRef) + callback() + }) +} + describe('name', function () { if (!isNode) { return @@ -54,31 +69,16 @@ describe('name', function () { after((done) => ipfsd.stop(done)) it('should publish and then resolve correctly with the default options', function (done) { - node.name.publish(ipfsRef, { resolve: false }, (err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - - node.name.resolve(nodeId, (err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - expect(res.path).to.equal(ipfsRef) - done() - }) - }) + publishAndResolve(node, node, ipfsRef, { resolve: false }, nodeId, {}, done) }) it('should publish correctly with the lifetime option and resolve', function (done) { - node.name.publish(ipfsRef, { resolve: false, lifetime: '2h' }, (err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() + const publishOpts = { + resolve: false, + lifetime: '2h' + } - node.name.resolve(nodeId, (err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - expect(res.path).to.equal(ipfsRef) - done() - }) - }) + publishAndResolve(node, node, ipfsRef, publishOpts, nodeId, {}, done) }) it('should not get the entry correctly if its validity time expired', function (done) { @@ -101,20 +101,15 @@ describe('name', function () { node.key.gen(keyName, { type: 'rsa', size: 2048 }, function (err, key) { expect(err).to.not.exist() - - node.name.publish(ipfsRef, { resolve: false }, (err) => { + series([ + (cb) => node.name.publish(ipfsRef, { resolve: false }, cb), + (cb) => node.name.publish(`/ipns/${nodeId}`, { resolve: false, key: keyName }, cb), + (cb) => node.name.resolve(key.id, { recursive: true }, cb) + ], (err, res) => { expect(err).to.not.exist() - - node.name.publish(`/ipns/${nodeId}`, { resolve: false, key: keyName }, (err) => { - expect(err).to.not.exist() - - node.name.resolve(key.id, { recursive: true }, (err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - expect(res.path).to.equal(ipfsRef) - done() - }) - }) + expect(res[2]).to.exist() + expect(res[2].path).to.equal(ipfsRef) + done() }) }) }) @@ -125,20 +120,15 @@ describe('name', function () { node.key.gen(keyName, { type: 'rsa', size: 2048 }, function (err, key) { expect(err).to.not.exist() - - node.name.publish(ipfsRef, { resolve: false }, (err) => { + series([ + (cb) => node.name.publish(ipfsRef, { resolve: false }, cb), + (cb) => node.name.publish(`/ipns/${nodeId}`, { resolve: false, key: keyName }, cb), + (cb) => node.name.resolve(key.id, cb) + ], (err, res) => { expect(err).to.not.exist() - - node.name.publish(`/ipns/${nodeId}`, { resolve: false, key: keyName }, (err) => { - expect(err).to.not.exist() - - node.name.resolve(key.id, (err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - expect(res.path).to.equal(`/ipns/${nodeId}`) - done() - }) - }) + expect(res[2]).to.exist() + expect(res[2].path).to.equal(`/ipns/${nodeId}`) + done() }) }) }) @@ -197,6 +187,78 @@ describe('name', function () { }) }) + describe('work with dht', () => { + let nodes + let nodeA + let nodeB + let nodeC + let idA + + const createNode = (callback) => { + df.spawn({ + exec: IPFS, + args: [`--pass ${hat()}`, '--enable-dht-experiment'], + config: { Bootstrap: [] } + }, callback) + } + + before(function (done) { + this.timeout(40 * 1000) + + parallel([ + (cb) => createNode(cb), + (cb) => createNode(cb), + (cb) => createNode(cb) + ], (err, _nodes) => { + expect(err).to.not.exist() + + nodes = _nodes + nodeA = _nodes[0].api + nodeB = _nodes[1].api + nodeC = _nodes[2].api + + parallel([ + (cb) => nodeA.id(cb), + (cb) => nodeB.id(cb) + ], (err, ids) => { + expect(err).to.not.exist() + + idA = ids[0] + parallel([ + (cb) => nodeC.swarm.connect(ids[0].addresses[0], cb), // C => A + (cb) => nodeC.swarm.connect(ids[1].addresses[0], cb) // C => B + ], done) + }) + }) + }) + + after((done) => parallel(nodes.map((node) => (cb) => node.stop(cb)), done)) + + it('should publish and then resolve correctly with the default options', function (done) { + this.timeout(50 * 1000) + publishAndResolve(nodeA, nodeB, ipfsRef, { resolve: false }, idA.id, {}, done) + }) + + it('should recursively resolve to an IPFS hash', function (done) { + this.timeout(80 * 1000) + const keyName = hat() + + nodeA.key.gen(keyName, { type: 'rsa', size: 2048 }, function (err, key) { + expect(err).to.not.exist() + series([ + (cb) => nodeA.name.publish(ipfsRef, { resolve: false }, cb), + (cb) => nodeA.name.publish(`/ipns/${idA.id}`, { resolve: false, key: keyName }, cb), + (cb) => nodeB.name.resolve(key.id, { recursive: true }, cb) + ], (err, res) => { + expect(err).to.not.exist() + expect(res[2]).to.exist() + expect(res[2].path).to.equal(ipfsRef) + done() + }) + }) + }) + }) + describe('errors', function () { if (!isNode) { return @@ -246,7 +308,7 @@ describe('name', function () { it('should error to publish if _updateOrCreateRecord fails', function (done) { const stub = sinon.stub(node._ipns.publisher, '_updateOrCreateRecord').callsArgWith(4, 'error') - node.name.publish(ipfsRef, { resolve: false }, (err, res) => { + node.name.publish(ipfsRef, { resolve: false }, (err) => { expect(err).to.exist() stub.restore() @@ -264,7 +326,7 @@ describe('name', function () { it('should error to publish if receives an invalid datastore key', function (done) { const stub = sinon.stub(Key, 'isKey').returns(false) - node.name.publish(ipfsRef, { resolve: false }, (err, res) => { + node.name.publish(ipfsRef, { resolve: false }, (err) => { expect(err).to.exist() expect(err.code).to.equal('ERR_INVALID_DATASTORE_KEY') @@ -274,11 +336,11 @@ describe('name', function () { }) it('should error to publish if we receive a unexpected error getting from datastore', function (done) { - const stub = sinon.stub(node._ipns.publisher._repo.datastore, 'get').callsArgWith(1, 'error-unexpected') + const stub = sinon.stub(node._ipns.publisher._datastore, 'get').callsArgWith(1, 'error-unexpected') - node.name.publish(ipfsRef, { resolve: false }, (err, res) => { + node.name.publish(ipfsRef, { resolve: false }, (err) => { expect(err).to.exist() - expect(err.code).to.equal('ERR_UNEXPECTED_DATASTORE_RESPONSE') + expect(err.code).to.equal('ERR_DETERMINING_PUBLISHED_RECORD') stub.restore() done() @@ -286,9 +348,9 @@ describe('name', function () { }) it('should error to publish if we receive a unexpected error putting to datastore', function (done) { - const stub = sinon.stub(node._ipns.publisher._repo.datastore, 'put').callsArgWith(2, 'error-unexpected') + const stub = sinon.stub(node._ipns.publisher._datastore, 'put').callsArgWith(2, 'error-unexpected') - node.name.publish(ipfsRef, { resolve: false }, (err, res) => { + node.name.publish(ipfsRef, { resolve: false }, (err) => { expect(err).to.exist() expect(err.code).to.equal('ERR_STORING_IN_DATASTORE') @@ -320,7 +382,7 @@ describe('name', function () { expect(err).to.not.exist() expect(res).to.exist() - node.name.resolve(nodeId, { nocache: true }, (err, res) => { + node.name.resolve(nodeId, { nocache: true }, (err) => { expect(err).to.exist() expect(err.code).to.equal('ERR_UNEXPECTED_ERROR_GETTING_RECORD') stub.restore() @@ -336,7 +398,7 @@ describe('name', function () { expect(err).to.not.exist() expect(res).to.exist() - node.name.resolve(nodeId, { nocache: true }, (err, res) => { + node.name.resolve(nodeId, { nocache: true }, (err) => { expect(err).to.exist() expect(err.code).to.equal('ERR_NO_RECORD_FOUND') stub.restore() @@ -352,7 +414,7 @@ describe('name', function () { expect(err).to.not.exist() expect(res).to.exist() - node.name.resolve(nodeId, { nocache: true }, (err, res) => { + node.name.resolve(nodeId, { nocache: true }, (err) => { expect(err).to.exist() expect(err.code).to.equal('ERR_INVALID_RECORD_RECEIVED') stub.restore() diff --git a/test/fixtures/go-ipfs-repo/blocks/2F/CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data b/test/fixtures/go-ipfs-repo/blocks/2F/CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data deleted file mode 100644 index 4145619655..0000000000 --- a/test/fixtures/go-ipfs-repo/blocks/2F/CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data +++ /dev/null @@ -1,4 +0,0 @@ - -ys# js-ipfs-repo -Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript -s \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/75/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data b/test/fixtures/go-ipfs-repo/blocks/75/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data deleted file mode 100644 index c9885c45d7..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/75/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/blocks/75/CIQMUSJFXRZX7ZRBICXJQPHVD7YSPD5KS75DRO7Q55ADVNORRBXV75Y.data b/test/fixtures/go-ipfs-repo/blocks/75/CIQMUSJFXRZX7ZRBICXJQPHVD7YSPD5KS75DRO7Q55ADVNORRBXV75Y.data new file mode 100644 index 0000000000..13521eaa2a Binary files /dev/null and b/test/fixtures/go-ipfs-repo/blocks/75/CIQMUSJFXRZX7ZRBICXJQPHVD7YSPD5KS75DRO7Q55ADVNORRBXV75Y.data differ diff --git a/test/fixtures/go-ipfs-repo/blocks/AE/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data b/test/fixtures/go-ipfs-repo/blocks/AE/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data deleted file mode 100644 index 6860441aa1..0000000000 --- a/test/fixtures/go-ipfs-repo/blocks/AE/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data +++ /dev/null @@ -1,3 +0,0 @@ -/ -" gq6\u8~:6~gZ.directT2 -" 6(%݄.Ӿ5(ab recursiveT \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/AP/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data b/test/fixtures/go-ipfs-repo/blocks/AP/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data deleted file mode 100644 index 74de75af61..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/AP/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/blocks/C4/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data b/test/fixtures/go-ipfs-repo/blocks/C4/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data deleted file mode 100644 index ecce1053f6..0000000000 --- a/test/fixtures/go-ipfs-repo/blocks/C4/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data +++ /dev/null @@ -1,4 +0,0 @@ -5 -" ׾F_uؔlzS?|ڲPc@ js-ipfs-repo - - \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/CY/CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data b/test/fixtures/go-ipfs-repo/blocks/CY/CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data deleted file mode 100644 index bbe6bda78d..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/CY/CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/blocks/DU/CIQLBK52T5EHVHZY5URTG5JS3JCUJDQM2DRB5RVF33DCUUOFJNGVDUI.data b/test/fixtures/go-ipfs-repo/blocks/DU/CIQLBK52T5EHVHZY5URTG5JS3JCUJDQM2DRB5RVF33DCUUOFJNGVDUI.data deleted file mode 100644 index 82458cdf71..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/DU/CIQLBK52T5EHVHZY5URTG5JS3JCUJDQM2DRB5RVF33DCUUOFJNGVDUI.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/blocks/DX/CIQPDQJBGYDZNMOAGGYNRNMP2VDKWBWGAEDDEJDACM3SGG3VIANDDXI.data b/test/fixtures/go-ipfs-repo/blocks/DX/CIQPDQJBGYDZNMOAGGYNRNMP2VDKWBWGAEDDEJDACM3SGG3VIANDDXI.data deleted file mode 100644 index 3092e413d6..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/DX/CIQPDQJBGYDZNMOAGGYNRNMP2VDKWBWGAEDDEJDACM3SGG3VIANDDXI.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/blocks/EX/CIQKA7ZA5YM6KOJE3HVPZNQ6C4TJVSVGFTWWOTHP7GWZYGDUP5HIEXY.data b/test/fixtures/go-ipfs-repo/blocks/EX/CIQKA7ZA5YM6KOJE3HVPZNQ6C4TJVSVGFTWWOTHP7GWZYGDUP5HIEXY.data new file mode 100644 index 0000000000..5321bdc1d3 --- /dev/null +++ b/test/fixtures/go-ipfs-repo/blocks/EX/CIQKA7ZA5YM6KOJE3HVPZNQ6C4TJVSVGFTWWOTHP7GWZYGDUP5HIEXY.data @@ -0,0 +1,4 @@ +/ +" I%s!@<'8@:шo_directV2 +" eI\(&PD +  2hO.߃o recursiveV \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/FN/CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data b/test/fixtures/go-ipfs-repo/blocks/FN/CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data deleted file mode 100644 index 3da92595c2..0000000000 --- a/test/fixtures/go-ipfs-repo/blocks/FN/CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data +++ /dev/null @@ -1,24 +0,0 @@ - -The MIT License (MIT) - -Copyright (c) 2015 IPFS - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -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 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. - - \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/GQ/CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data b/test/fixtures/go-ipfs-repo/blocks/GQ/CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data deleted file mode 100644 index ee87b9db01..0000000000 --- a/test/fixtures/go-ipfs-repo/blocks/GQ/CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data +++ /dev/null @@ -1,4 +0,0 @@ -0 -" ,Qv3k>\IzxEElM/fLICENSE1 -" JZXoRX!Fwd87U;SöWw README.md{ - \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/HD/CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data b/test/fixtures/go-ipfs-repo/blocks/HD/CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data deleted file mode 100644 index 5ea0edda6f..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/HD/CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/blocks/IR/CIQERMRAAFXUAUOX3V2DCW7R77FRIVHQ3V5OIPPS3XQBX34KRPNOIRQ.data b/test/fixtures/go-ipfs-repo/blocks/IR/CIQERMRAAFXUAUOX3V2DCW7R77FRIVHQ3V5OIPPS3XQBX34KRPNOIRQ.data deleted file mode 100644 index 4a26a4ac35..0000000000 --- a/test/fixtures/go-ipfs-repo/blocks/IR/CIQERMRAAFXUAUOX3V2DCW7R77FRIVHQ3V5OIPPS3XQBX34KRPNOIRQ.data +++ /dev/null @@ -1,3 +0,0 @@ -/ -" !61صF2$`7#u@1directT2 -" Hz8#3u2ED ƥ*QKMQ recursiveT \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/5X/CIQJ23BL4UHXA2KTI6NLTXZM4PW4VEFWQBJ4ACZQAS37BLGL4HUO5XY.data b/test/fixtures/go-ipfs-repo/blocks/K5/CIQPW4MAGTUNEBGZCEFZU7XAJL2BMIHGVB5ZR2IOKOSTRMLIKPB6K5I.data similarity index 50% rename from test/fixtures/go-ipfs-repo/blocks/5X/CIQJ23BL4UHXA2KTI6NLTXZM4PW4VEFWQBJ4ACZQAS37BLGL4HUO5XY.data rename to test/fixtures/go-ipfs-repo/blocks/K5/CIQPW4MAGTUNEBGZCEFZU7XAJL2BMIHGVB5ZR2IOKOSTRMLIKPB6K5I.data index b799cf6b22..e1cd3e3e21 100644 Binary files a/test/fixtures/go-ipfs-repo/blocks/5X/CIQJ23BL4UHXA2KTI6NLTXZM4PW4VEFWQBJ4ACZQAS37BLGL4HUO5XY.data and b/test/fixtures/go-ipfs-repo/blocks/K5/CIQPW4MAGTUNEBGZCEFZU7XAJL2BMIHGVB5ZR2IOKOSTRMLIKPB6K5I.data differ diff --git a/test/fixtures/go-ipfs-repo/blocks/O6/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data b/test/fixtures/go-ipfs-repo/blocks/O6/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data deleted file mode 100644 index 7b58d6c857..0000000000 --- a/test/fixtures/go-ipfs-repo/blocks/O6/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data +++ /dev/null @@ -1,3 +0,0 @@ -/ -" @ԆDgA7directT2 -" ;APY0k}E=p  recursiveT \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/5V/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data b/test/fixtures/go-ipfs-repo/blocks/OO/CIQBT4N7PS5IZ5IG2ZOUGKFK27IE33WKGJNDW2TY3LSBNQ34R6OVOOQ.data similarity index 82% rename from test/fixtures/go-ipfs-repo/blocks/5V/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data rename to test/fixtures/go-ipfs-repo/blocks/OO/CIQBT4N7PS5IZ5IG2ZOUGKFK27IE33WKGJNDW2TY3LSBNQ34R6OVOOQ.data index 951bfe0400..770348274e 100644 --- a/test/fixtures/go-ipfs-repo/blocks/5V/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data +++ b/test/fixtures/go-ipfs-repo/blocks/OO/CIQBT4N7PS5IZ5IG2ZOUGKFK27IE33WKGJNDW2TY3LSBNQ34R6OVOOQ.data @@ -1,5 +1,5 @@ - IPFS Alpha Security Notes +  IPFS Alpha Security Notes We try hard to ensure our system is safe and robust, but all software has bugs, especially new software. This distribution is meant to be an @@ -15,9 +15,13 @@ Please note the following: user provided data. But please point any problems out to us in a github issue, or email security@ipfs.io privately. +- security@ipfs.io GPG key: + - 4B9665FB 92636D17 7C7A86D3 50AAE8A9 59B13AF3 + - https://pgp.mit.edu/pks/lookup?op=get&search=0x50AAE8A959B13AF3 + - ipfs uses encryption for all communication, but it's NOT PROVEN SECURE YET! It may be totally broken. For now, the code is included to make sure we benchmark our operations with encryption in mind. In the future, there will be an "unsafe" mode for high performance intranet apps. If this is a blocking feature for you, please contact us. - \ No newline at end of file + \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/PJ/CIQB4F7VKKQDXHMXX6WYQZTRR5QVLP7VBQYAYW2Y5BAPOOGTW5H2PJQ.data b/test/fixtures/go-ipfs-repo/blocks/PJ/CIQB4F7VKKQDXHMXX6WYQZTRR5QVLP7VBQYAYW2Y5BAPOOGTW5H2PJQ.data new file mode 100644 index 0000000000..0335563629 --- /dev/null +++ b/test/fixtures/go-ipfs-repo/blocks/PJ/CIQB4F7VKKQDXHMXX6WYQZTRR5QVLP7VBQYAYW2Y5BAPOOGTW5H2PJQ.data @@ -0,0 +1,3 @@ + + Index + \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/PU/CIQJF2E6OPOEYYEVHYML4UD5A3R4QRAVBI7NVH3PL64D3IJCWR2SPUQ.data b/test/fixtures/go-ipfs-repo/blocks/PU/CIQJF2E6OPOEYYEVHYML4UD5A3R4QRAVBI7NVH3PL64D3IJCWR2SPUQ.data new file mode 100644 index 0000000000..e6ef304bfd --- /dev/null +++ b/test/fixtures/go-ipfs-repo/blocks/PU/CIQJF2E6OPOEYYEVHYML4UD5A3R4QRAVBI7NVH3PL64D3IJCWR2SPUQ.data @@ -0,0 +1,36 @@ + +WIP + +# 0.0 - Introduction + +Welcome to IPFS! This tour will guide you through a few of the +features of this tool, and the most common commands. Then, it will +immerse you into the world of merkledags and the amazing things +you can do with them. + + +This tour has many parts, and can be taken in different sequences. +Different people learn different ways, so choose your own adventure: + + To start with the concepts, try: + - The Merkle DAG + - Data Structures on the Merkle DAG + - Representing Files with unixfs + - add, cat, ls, refs + ... + + + To start with the examples, try: + - add, cat, ls, refs + - Representing Files with unixfs + - Data Structures on the Merkle DAG + - The Merkle DAG + ... + + + To start with the network, try: + - IPFS Nodes + - Running the daemon + - The Swarm + - The Web + \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/QF/CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data b/test/fixtures/go-ipfs-repo/blocks/QF/CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data deleted file mode 100644 index a8f98693b7..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/QF/CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/blocks/QP/CIQNLGENZXNRUMUHZYGPPLZNZOMHHZVIU76LCD5GF5DWFPEGEKODQPI.data b/test/fixtures/go-ipfs-repo/blocks/QP/CIQNLGENZXNRUMUHZYGPPLZNZOMHHZVIU76LCD5GF5DWFPEGEKODQPI.data new file mode 100644 index 0000000000..6636930467 --- /dev/null +++ b/test/fixtures/go-ipfs-repo/blocks/QP/CIQNLGENZXNRUMUHZYGPPLZNZOMHHZVIU76LCD5GF5DWFPEGEKODQPI.data @@ -0,0 +1,4 @@ +2 +" sL`>P}D +>ڟo_="u' 0.0-intro + \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/S2/CIQPF3CHDB5GQ5ZBISOV2GWVMLAJPVEUMDMFKJZE7CMZESO6TYFAS2I.data b/test/fixtures/go-ipfs-repo/blocks/S2/CIQPF3CHDB5GQ5ZBISOV2GWVMLAJPVEUMDMFKJZE7CMZESO6TYFAS2I.data new file mode 100644 index 0000000000..b137a86405 --- /dev/null +++ b/test/fixtures/go-ipfs-repo/blocks/S2/CIQPF3CHDB5GQ5ZBISOV2GWVMLAJPVEUMDMFKJZE7CMZESO6TYFAS2I.data @@ -0,0 +1,3 @@ +- +" R;fqaU 0 [X@8ӷOindex + \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/S5/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data b/test/fixtures/go-ipfs-repo/blocks/S5/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data deleted file mode 100644 index 3a99c365f0..0000000000 --- a/test/fixtures/go-ipfs-repo/blocks/S5/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data +++ /dev/null @@ -1,3 +0,0 @@ -4 -" Y9_)a˹2RmŖke9 js-ipfs-repo - \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/SW/CIQHPUVCWD6JA6AFUVD6VA64TGWP67KYA3AIMBUMVWGZ5AQN2L2HSWQ.data b/test/fixtures/go-ipfs-repo/blocks/SW/CIQHPUVCWD6JA6AFUVD6VA64TGWP67KYA3AIMBUMVWGZ5AQN2L2HSWQ.data deleted file mode 100644 index 78421c81c2..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/SW/CIQHPUVCWD6JA6AFUVD6VA64TGWP67KYA3AIMBUMVWGZ5AQN2L2HSWQ.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/blocks/TW/CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data b/test/fixtures/go-ipfs-repo/blocks/TW/CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data deleted file mode 100644 index 10aa2ae4f1..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/TW/CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/blocks/UN/CIQOMBKARLB7PAITVSNH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data b/test/fixtures/go-ipfs-repo/blocks/UN/CIQOMBKARLB7PAITVSNH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data deleted file mode 100644 index b653989765..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/UN/CIQOMBKARLB7PAITVSNH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/blocks/UW/CIQDVKITASFS55MC2TXCX5XMZLMGTYVODWPEDIW7JYEG7YXBIA7IUWY.data b/test/fixtures/go-ipfs-repo/blocks/UW/CIQDVKITASFS55MC2TXCX5XMZLMGTYVODWPEDIW7JYEG7YXBIA7IUWY.data deleted file mode 100644 index ed8c782e45..0000000000 --- a/test/fixtures/go-ipfs-repo/blocks/UW/CIQDVKITASFS55MC2TXCX5XMZLMGTYVODWPEDIW7JYEG7YXBIA7IUWY.data +++ /dev/null @@ -1,3 +0,0 @@ -/ -" wҢxGܙ}X yZdirectT2 -" ˧7Fw}|ɣ*#'V>| recursiveT \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/VO/CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data b/test/fixtures/go-ipfs-repo/blocks/VO/CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data deleted file mode 100644 index 2dd80560a2..0000000000 --- a/test/fixtures/go-ipfs-repo/blocks/VO/CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data +++ /dev/null @@ -1,114 +0,0 @@ - -  # 0.1 - Quick Start - -This is a set of short examples with minimal explanation. It is meant as -a "quick start". Soon, we'll write a longer tour :-) - - -Add a file to ipfs: - - echo "hello world" >hello - ipfs add hello - - -View it: - - ipfs cat - - -Try a directory: - - mkdir foo - mkdir foo/bar - echo "baz" > foo/baz - echo "baz" > foo/bar/baz - ipfs add -r foo - - -View things: - - ipfs ls - ipfs ls /bar - ipfs cat /baz - ipfs cat /bar/baz - ipfs cat /bar - ipfs ls /baz - - -References: - - ipfs refs - ipfs refs -r - ipfs refs --help - - -Get: - - ipfs get foo2 - diff foo foo2 - - -Objects: - - ipfs object get - ipfs object get /foo2 - ipfs object --help - - -Pin + GC: - - ipfs pin -r - ipfs gc - ipfs ls - ipfs unpin -r - ipfs gc - - -Daemon: - - ipfs daemon (in another terminal) - ipfs id - - -Network: - - (must be online) - ipfs swarm peers - ipfs id - ipfs cat - - -Mount: - - (warning: fuse is finicky!) - ipfs mount - cd /ipfs/< - - -Tool: - - ipfs version - ipfs update - ipfs commands - ipfs config --help - open http://localhost:5001/webui - - -Browse: - - webui: - - http://localhost:5001/webui - - video: - - http://localhost:8080/ipfs/QmVc6zuAneKJzicnJpfrqCH9gSy6bz54JhcypfJYhGUFQu/play#/ipfs/QmTKZgRNwDNZwHtJSjCp6r5FYefzpULfy37JvMt9DwvXse - - images: - - http://localhost:8080/ipfs/QmZpc3HvfjEXvLWGQPWbHk3AjD5j8NEN4gmFN8Jmrd5g83/cs - - markdown renderer app: - - http://localhost:8080/ipfs/QmX7M9CiYXjVeFnkfVGf3y5ixTZ2ACeSGyL1vBJY1HvQPp/mdown - \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/WG/CIQN2ZNT35EZ4XBIEYMFARFMBIEICCIO6SVSAMQB7VUE6LW7QNX3WGQ.data b/test/fixtures/go-ipfs-repo/blocks/WG/CIQN2ZNT35EZ4XBIEYMFARFMBIEICCIO6SVSAMQB7VUE6LW7QNX3WGQ.data new file mode 100644 index 0000000000..afeac9fff9 Binary files /dev/null and b/test/fixtures/go-ipfs-repo/blocks/WG/CIQN2ZNT35EZ4XBIEYMFARFMBIEICCIO6SVSAMQB7VUE6LW7QNX3WGQ.data differ diff --git a/test/fixtures/go-ipfs-repo/blocks/XO/CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data b/test/fixtures/go-ipfs-repo/blocks/XO/CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data deleted file mode 100644 index d899663bf7..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/XO/CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/blocks/YD/CIQENVCICS44LLYUDQ5KVN6ALXC6QRHK2X4R6EUFRMBB5OSFO2FUYDQ.data b/test/fixtures/go-ipfs-repo/blocks/YD/CIQENVCICS44LLYUDQ5KVN6ALXC6QRHK2X4R6EUFRMBB5OSFO2FUYDQ.data deleted file mode 100644 index 2965d1c457..0000000000 --- a/test/fixtures/go-ipfs-repo/blocks/YD/CIQENVCICS44LLYUDQ5KVN6ALXC6QRHK2X4R6EUFRMBB5OSFO2FUYDQ.data +++ /dev/null @@ -1,3 +0,0 @@ - - hello world - \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/blocks/ZF/CIQLBS5HG4PRCRQ7O4EBXFD5QN6MTI5YBYMCVQJDXPKCOVR6RMLHZFQ.data b/test/fixtures/go-ipfs-repo/blocks/ZF/CIQLBS5HG4PRCRQ7O4EBXFD5QN6MTI5YBYMCVQJDXPKCOVR6RMLHZFQ.data deleted file mode 100644 index 3dcbfc8443..0000000000 Binary files a/test/fixtures/go-ipfs-repo/blocks/ZF/CIQLBS5HG4PRCRQ7O4EBXFD5QN6MTI5YBYMCVQJDXPKCOVR6RMLHZFQ.data and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/config b/test/fixtures/go-ipfs-repo/config index 162598cdfc..e42d061b2f 100644 --- a/test/fixtures/go-ipfs-repo/config +++ b/test/fixtures/go-ipfs-repo/config @@ -1,51 +1,21 @@ { - "Identity": { - "PeerID": "QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A", - "PrivKey": "CAASpgkwggSiAgEAAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAECggEAZtju/bcKvKFPz0mkHiaJcpycy9STKphorpCT83srBVQi59CdFU6Mj+aL/xt0kCPMVigJw8P3/YCEJ9J+rS8BsoWE+xWUEsJvtXoT7vzPHaAtM3ci1HZd302Mz1+GgS8Epdx+7F5p80XAFLDUnELzOzKftvWGZmWfSeDnslwVONkL/1VAzwKy7Ce6hk4SxRE7l2NE2OklSHOzCGU1f78ZzVYKSnS5Ag9YrGjOAmTOXDbKNKN/qIorAQ1bovzGoCwx3iGIatQKFOxyVCyO1PsJYT7JO+kZbhBWRRE+L7l+ppPER9bdLFxs1t5CrKc078h+wuUr05S1P1JjXk68pk3+kQKBgQDeK8AR11373Mzib6uzpjGzgNRMzdYNuExWjxyxAzz53NAR7zrPHvXvfIqjDScLJ4NcRO2TddhXAfZoOPVH5k4PJHKLBPKuXZpWlookCAyENY7+Pd55S8r+a+MusrMagYNljb5WbVTgN8cgdpim9lbbIFlpN6SZaVjLQL3J8TWH6wKBgQDSChzItkqWX11CNstJ9zJyUE20I7LrpyBJNgG1gtvz3ZMUQCn3PxxHtQzN9n1P0mSSYs+jBKPuoSyYLt1wwe10/lpgL4rkKWU3/m1Myt0tveJ9WcqHh6tzcAbb/fXpUFT/o4SWDimWkPkuCb+8j//2yiXk0a/T2f36zKMuZvujqQKBgC6B7BAQDG2H2B/ijofp12ejJU36nL98gAZyqOfpLJ+FeMz4TlBDQ+phIMhnHXA5UkdDapQ+zA3SrFk+6yGk9Vw4Hf46B+82SvOrSbmnMa+PYqKYIvUzR4gg34rL/7AhwnbEyD5hXq4dHwMNsIDq+l2elPjwm/U9V0gdAl2+r50HAoGALtsKqMvhv8HucAMBPrLikhXP/8um8mMKFMrzfqZ+otxfHzlhI0L08Bo3jQrb0Z7ByNY6M8epOmbCKADsbWcVre/AAY0ZkuSZK/CaOXNX/AhMKmKJh8qAOPRY02LIJRBCpfS4czEdnfUhYV/TYiFNnKRj57PPYZdTzUsxa/yVTmECgYBr7slQEjb5Onn5mZnGDh+72BxLNdgwBkhO0OCdpdISqk0F0Pxby22DFOKXZEpiyI9XYP1C8wPiJsShGm2yEwBPWXnrrZNWczaVuCbXHrZkWQogBDG3HGXNdU4MAWCyiYlyinIBpPpoAJZSzpGLmWbMWh28+RJS6AQX6KHrK1o2uw==" - }, - "Datastore": { - "Type": "", - "Path": "", - "StorageMax": "", - "StorageGCWatermark": 0, - "GCPeriod": "", - "Params": null, - "NoSync": false - }, "Addresses": { "Swarm": [ - "/ip4/127.0.0.1/tcp/0", - "/ip4/127.0.0.1/tcp/0/ws" + "/ip4/0.0.0.0/tcp/4002", + "/ip4/127.0.0.1/tcp/4003/ws" ], - "API": "/ip4/127.0.0.1/tcp/0", - "Gateway": "/ip4/127.0.0.1/tcp/0" - }, - "Mounts": { - "IPFS": "/ipfs", - "IPNS": "/ipns", - "FuseAllowOther": false - }, - "Version": { - "Current": "0.4.0-dev", - "Check": "error", - "CheckDate": "0001-01-01T00:00:00Z", - "CheckPeriod": "172800000000000", - "AutoUpdate": "minor" + "API": "/ip4/127.0.0.1/tcp/5002", + "Gateway": "/ip4/127.0.0.1/tcp/9090" }, "Discovery": { "MDNS": { - "Enabled": false, + "Enabled": true, "Interval": 10 }, "webRTCStar": { - "Enabled": false + "Enabled": true } }, - "Ipns": { - "RepublishPeriod": "", - "RecordLifetime": "", - "ResolveCacheSize": 128 - }, "Bootstrap": [ "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", @@ -67,43 +37,47 @@ "/dns4/node0.preload.ipfs.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic", "/dns4/node1.preload.ipfs.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6" ], - "Tour": { - "Last": "" - }, - "Gateway": { - "HTTPHeaders": null, - "RootRedirect": "", - "Writable": false - }, - "SupernodeRouting": { - "Servers": [ - "/ip4/104.236.176.52/tcp/4002/ipfs/QmXdb7tWTxdFEQEFgWBqkuYSrZd3mXrC7HxkD4krGNYx2U", - "/ip4/104.236.179.241/tcp/4002/ipfs/QmVRqViDByUxjUMoPnjurjKvZhaEMFDtK35FJXHAM4Lkj6", - "/ip4/104.236.151.122/tcp/4002/ipfs/QmSZwGx8Tn8tmcM4PtDJaMeUQNRhNFdBLVGPzRiNaRJtFH", - "/ip4/162.243.248.213/tcp/4002/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP", - "/ip4/128.199.219.111/tcp/4002/ipfs/Qmb3brdCYmKG1ycwqCbo6LUwWxTuo3FisnJV2yir7oN92R", - "/ip4/104.236.76.40/tcp/4002/ipfs/QmdRBCV8Cz2dGhoKLkD3YjPwVFECmqADQkx5ZteF2c6Fy4", - "/ip4/178.62.158.247/tcp/4002/ipfs/QmUdiMPci7YoEUBkyFZAh2pAbjqcPr7LezyiPD2artLw3v", - "/ip4/178.62.61.185/tcp/4002/ipfs/QmVw6fGNqBixZE4bewRLT2VXX7fAHUHs8JyidDiJ1P7RUN" - ] + "Identity": { + "PeerID": "QmTuh8pVDCz5kbShrK8MJsJgTycCcGwZm8hQd8SxdbYmby", + "PrivKey": "CAASpwkwggSjAgEAAoIBAQCiyLgGRpuGiorm6FzvBbrTU60e6iPMmwXL9mXyGitepQyeN7XF8e6cooFeJI/NIyvbmpa7rHCDzTWP+6ebIMOXjUjQDAgaYdHywKbAXi2cgh96yuTN+cfPJ0IVA1/4Xsn/mnaMmSNDxqnK3fExEDxZizL9iI7KQCGOHociwjNj2cqaz+4ldTQ6QBbqa8nBMbulUNtSzwihQHTHNVwhuYFGPXIIK8UhM1VR20HcCbX+TZ9RpBWLIGZgjJl2ClW7wLW1OAb55I/9CK6AmfOriVYSBxZSFi2jiPCGQmuzfiqEke6/hSZtxe8DRo8ELOQ9K2P3L27H2az2atis2FoqVY2LAgMBAAECggEBAJBg9I9kaqb/FEnPSDYb3+N1sPPdeZkM2ixYQ31i5pqQS0u9X7TMavV0UMe+J+krS8gAKbcVL8pG5T3qV3MIsVIm1rDoKvuzTTJA2uV94niRFPilIiDqbOT4De1zS9iPwhu51XHIlXWUq54qEbWRj+Vfx/8E8pjCHsDdpMAYfNoOsZClr993Hopnf+hfnCypjHpgr5JQzblbN9jmInCOS//Gjcx5IIAPSubNsRaM2sUzqCVaND2QFqQR6+efiHwO8tznLtEJtQ2eSh1LZrLNapovPpMrRyD56Wyj6YlPRd3XOBDcsxxj4WdHobQYqbRV+tI2kyIZ8RP0pOFnLBK1NqECgYEA5nwj3dkXCYBLJ3c2HcUzvQUJmsv7dTM6vsKGCbov/BLPwuKx/X5QlUO6INvHxuVk6+Fj+WTzCFu1gxU1A3bIPgxs6TvYBh4p9Om4ZoW8p7rgF6M5l+TvmlUAisA9X96wYIQnQsW0N5hncFlBveLqEGPXKydxB4y4qwjX8G2Jg3ECgYEAtM315984Rylj8Mj5SdvTUnxe3glixbGRqkj+SEs7ngW5YnKwiEcAvP1OrnczX1h6Aol2b9r89dnsdfsrnaTSEWeKlVqMUfVeixnbssIZD3ZmgzceLdT3q/uZoE89Lw7D+SxQfNG5Q7KekXjI1WQeEhAgNOVppARn/JiHUH9yKrsCgYA1Pen/Hl3e+P7jX/tlRx+bg2Vjl8k/mpTwafkSmCrrfOD3cOyS1TICOQHvAzYT8PuuLYOtoa8ueBjm7egwI6lABBjIi+VsDF2+0JqjPDOHP3jynOb5+o2KxiX4502GLufpc72qBAeMbC1A261/EsLlBFs5AcRvbQdfowxW4sbIUQKBgFRg3kclFIWZWmvPzw9aCMgxBLEInlD2qq1WvV0NxzfbIgZA0gP3Zu/MI4EmXhI8H0y5zE0tXOp7lnAFFPjQJ705niJPjLbfFQ1DtxU4oitmLTdFbM8k2aUomSyIblxcvra1qKZn1dczL+9h+BAmViZF4lHtUpzZ9ZGbuWKm56frAoGASs3C/VhZDhYuJxJWrQrw3pdXWHKosowDbitG9kmeUTOjzTb/UYDhDnWNIH5sfzOkmufEkIAPTKu9SCX4PIXIuwrbWUK6GAnJnqE8uuzGoz7wgV4ZxKiYbPsrXIn9+mFNhjyZM5PG71Vu/wWds7lduUsuWAIvlysqNX64mU3nSB4=" }, "API": { "HTTPHeaders": null }, - "Swarm": { - "AddrFilters": null - }, - "Log": { - "MaxSizeMB": 250, - "MaxBackups": 1, - "MaxAgeDays": 0 + "datastore": { + "Spec": { + "type": "mount", + "mounts": [ + { + "mountpoint": "/blocks", + "type": "measure", + "prefix": "flatfs.datastore", + "child": { + "type": "flatfs", + "path": "blocks", + "sync": true, + "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2" + } + }, + { + "mountpoint": "/", + "type": "measure", + "prefix": "leveldb.datastore", + "child": { + "type": "levelds", + "path": "datastore", + "compression": "none" + } + } + ] + } }, "Keychain": { "dek": { "keyLength": 64, "iterationCount": 10000, - "salt": "co5EbMmrhFwmhHjedZU73zhL", + "salt": "WzAwtXD84YNt474jS7PLTiPw", "hash": "sha2-512" } } -} +} \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/datastore/000002.ldb b/test/fixtures/go-ipfs-repo/datastore/000002.ldb deleted file mode 100644 index fc04d660e9..0000000000 Binary files a/test/fixtures/go-ipfs-repo/datastore/000002.ldb and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/datastore/000005.ldb b/test/fixtures/go-ipfs-repo/datastore/000005.ldb index 63d9d260b9..db91675fb1 100644 Binary files a/test/fixtures/go-ipfs-repo/datastore/000005.ldb and b/test/fixtures/go-ipfs-repo/datastore/000005.ldb differ diff --git a/test/fixtures/go-ipfs-repo/datastore/000010.ldb b/test/fixtures/go-ipfs-repo/datastore/000010.ldb deleted file mode 100644 index 92077582ca..0000000000 Binary files a/test/fixtures/go-ipfs-repo/datastore/000010.ldb and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/datastore/CURRENT b/test/fixtures/go-ipfs-repo/datastore/CURRENT index 056df57bb7..cacca7574c 100644 --- a/test/fixtures/go-ipfs-repo/datastore/CURRENT +++ b/test/fixtures/go-ipfs-repo/datastore/CURRENT @@ -1 +1 @@ -MANIFEST-000017 +MANIFEST-000004 diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG b/test/fixtures/go-ipfs-repo/datastore/LOG index f009994607..b5c1fbebe2 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG +++ b/test/fixtures/go-ipfs-repo/datastore/LOG @@ -1 +1,5 @@ -2018/02/27-08:48:29.247686 7000091b5000 Delete type=3 #15 +2018/12/04-21:06:06.695090 700009ac2000 Recovering log #3 +2018/12/04-21:06:06.696155 700009ac2000 Level-0 table #5: started +2018/12/04-21:06:06.696630 700009ac2000 Level-0 table #5: 1815 bytes OK +2018/12/04-21:06:06.708809 700009ac2000 Delete type=0 #3 +2018/12/04-21:06:06.709006 700009ac2000 Delete type=3 #2 diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG.old b/test/fixtures/go-ipfs-repo/datastore/LOG.old index 15709837f7..6b985ec2d3 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG.old +++ b/test/fixtures/go-ipfs-repo/datastore/LOG.old @@ -1 +1 @@ -2018/02/26-08:13:54.065997 70000aad6000 Delete type=3 #14 +2018/12/04-21:05:53.418981 70000ee5a000 Delete type=3 #1 diff --git a/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000004 b/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000004 new file mode 100644 index 0000000000..f0e1ba870d Binary files /dev/null and b/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000004 differ diff --git a/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000017 b/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000017 deleted file mode 100644 index fb6bc82f41..0000000000 Binary files a/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000017 and /dev/null differ diff --git a/test/fixtures/go-ipfs-repo/datastore_spec b/test/fixtures/go-ipfs-repo/datastore_spec new file mode 100644 index 0000000000..7bf9626c24 --- /dev/null +++ b/test/fixtures/go-ipfs-repo/datastore_spec @@ -0,0 +1 @@ +{"mounts":[{"mountpoint":"/blocks","path":"blocks","shardFunc":"/repo/flatfs/shard/v1/next-to-last/2","type":"flatfs"},{"mountpoint":"/","path":"datastore","type":"levelds"}],"type":"mount"} \ No newline at end of file diff --git a/test/http-api/config.js b/test/http-api/config.js index 0d14504d1a..0958b16a72 100644 --- a/test/http-api/config.js +++ b/test/http-api/config.js @@ -27,6 +27,7 @@ skipOnWindows('config endpoint', () => { let ipfs = null let ipfsd = null + before(function (done) { this.timeout(20 * 1000) diff --git a/test/http-api/id.js b/test/http-api/id.js index 95de5cf686..ea54e158ee 100644 --- a/test/http-api/id.js +++ b/test/http-api/id.js @@ -73,8 +73,8 @@ skipOnWindows('id endpoint', () => { }) const idResult = { - ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A', - PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=', + ID: 'QmTuh8pVDCz5kbShrK8MJsJgTycCcGwZm8hQd8SxdbYmby', + PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCiyLgGRpuGiorm6FzvBbrTU60e6iPMmwXL9mXyGitepQyeN7XF8e6cooFeJI/NIyvbmpa7rHCDzTWP+6ebIMOXjUjQDAgaYdHywKbAXi2cgh96yuTN+cfPJ0IVA1/4Xsn/mnaMmSNDxqnK3fExEDxZizL9iI7KQCGOHociwjNj2cqaz+4ldTQ6QBbqa8nBMbulUNtSzwihQHTHNVwhuYFGPXIIK8UhM1VR20HcCbX+TZ9RpBWLIGZgjJl2ClW7wLW1OAb55I/9CK6AmfOriVYSBxZSFi2jiPCGQmuzfiqEke6/hSZtxe8DRo8ELOQ9K2P3L27H2az2atis2FoqVY2LAgMBAAE=', Addresses: ['/ip4/0.0.0.0/tcp/0'], AgentVersion: 'js-ipfs', ProtocolVersion: '9000' diff --git a/test/http-api/inject/files.js b/test/http-api/inject/files.js index 7e65f7651f..86c7f7dbcb 100644 --- a/test/http-api/inject/files.js +++ b/test/http-api/inject/files.js @@ -62,7 +62,8 @@ module.exports = (http) => { }) }) - it('valid hash', (done) => { + it('valid hash', function (done) { + this.timeout(30 * 1000) api.inject({ method: 'GET', url: '/api/v0/cat?arg=QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o' diff --git a/test/http-api/inject/id.js b/test/http-api/inject/id.js index 35dc443e4d..51716b2594 100644 --- a/test/http-api/inject/id.js +++ b/test/http-api/inject/id.js @@ -29,8 +29,8 @@ module.exports = (http) => { } const idResult = { - ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A', - PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=', + ID: 'QmTuh8pVDCz5kbShrK8MJsJgTycCcGwZm8hQd8SxdbYmby', + PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCiyLgGRpuGiorm6FzvBbrTU60e6iPMmwXL9mXyGitepQyeN7XF8e6cooFeJI/NIyvbmpa7rHCDzTWP+6ebIMOXjUjQDAgaYdHywKbAXi2cgh96yuTN+cfPJ0IVA1/4Xsn/mnaMmSNDxqnK3fExEDxZizL9iI7KQCGOHociwjNj2cqaz+4ldTQ6QBbqa8nBMbulUNtSzwihQHTHNVwhuYFGPXIIK8UhM1VR20HcCbX+TZ9RpBWLIGZgjJl2ClW7wLW1OAb55I/9CK6AmfOriVYSBxZSFi2jiPCGQmuzfiqEke6/hSZtxe8DRo8ELOQ9K2P3L27H2az2atis2FoqVY2LAgMBAAE=', Addresses: [ '/ip4/0.0.0.0/tcp/0' ], AgentVersion: 'js-ipfs', ProtocolVersion: '9000' diff --git a/test/http-api/inject/pin.js b/test/http-api/inject/pin.js index f36821c0bc..e351e721a7 100644 --- a/test/http-api/inject/pin.js +++ b/test/http-api/inject/pin.js @@ -17,17 +17,15 @@ const expect = require('chai').expect // - c4 // - c5 // - c6 -// - root2 const pins = { - root1: 'QmVtU7ths96fMgZ8YSZAbKghyieq7AjxNdcqyVzxTt3qVe', + root1: 'QmfGBRT6BbWJd7yUc2uYdaUZJBbnEFvTqehPFoSMQ6wgdr', c1: 'QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V', c2: 'QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y', c3: 'QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7', - c4: 'QmUzLxaXnM8RYCPEqLDX5foToi5aNZHqfYr285w2BKhkft', + c4: 'QmQN88TEidd3RY2u3dpib49fERTDfKtDpvxnvczATNsfKT', c5: 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB', - c6: 'QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ', - root2: 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn' + c6: 'QmciSU8hfpAXKjvK5YLUSwApomGSWN5gFbP4EpDAEzu2Te' } module.exports = (http) => { @@ -158,9 +156,7 @@ module.exports = (http) => { url: `/api/v0/pin/ls?type=recursive` }, (res) => { expect(res.statusCode).to.equal(200) - expect(res.result.Keys['QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn']) - .to.deep.eql({ Type: 'recursive' }) - expect(res.result.Keys['QmVtU7ths96fMgZ8YSZAbKghyieq7AjxNdcqyVzxTt3qVe']) + expect(res.result.Keys['QmfGBRT6BbWJd7yUc2uYdaUZJBbnEFvTqehPFoSMQ6wgdr']) .to.deep.eql({ Type: 'recursive' }) done() })