From fcba1b58227800f0b6cb8145bf789b20568c656e Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 23 Feb 2018 14:58:37 -0600 Subject: [PATCH 1/5] feat: rework http-api tests to use ipfsd-ctl --- test/fixtures/go-ipfs-repo/blocks/_README | 8 -- test/fixtures/go-ipfs-repo/config | 112 ++++++++++-------- test/fixtures/go-ipfs-repo/datastore/CURRENT | 2 +- test/fixtures/go-ipfs-repo/datastore/LOG | 32 +---- test/fixtures/go-ipfs-repo/datastore/LOG.old | 13 +- .../go-ipfs-repo/datastore/MANIFEST-000014 | Bin 314 -> 0 bytes test/http-api/extra/block.js | 37 ++++-- test/http-api/extra/bootstrap.js | 50 +++++--- test/http-api/extra/config.js | 67 +++++++---- test/http-api/extra/dns.js | 26 ++-- test/http-api/extra/id.js | 43 +++++-- test/http-api/extra/index.js | 16 +++ test/http-api/extra/object.js | 81 +++++++------ test/http-api/extra/version.js | 26 ++-- test/http-api/index.js | 80 +------------ test/http-api/interface/block.js | 4 +- test/http-api/interface/index.js | 10 ++ test/http-api/spec/index.js | 63 ++++++++++ 18 files changed, 382 insertions(+), 288 deletions(-) delete mode 100644 test/fixtures/go-ipfs-repo/datastore/MANIFEST-000014 create mode 100644 test/http-api/extra/index.js create mode 100644 test/http-api/interface/index.js create mode 100644 test/http-api/spec/index.js diff --git a/test/fixtures/go-ipfs-repo/blocks/_README b/test/fixtures/go-ipfs-repo/blocks/_README index 23cb090956..ac3b6034c3 100644 --- a/test/fixtures/go-ipfs-repo/blocks/_README +++ b/test/fixtures/go-ipfs-repo/blocks/_README @@ -6,25 +6,17 @@ All the object files are placed in a tree of directories, based on a function of the CID. This is a form of sharding similar to the objects directory in git repositories. Previously, we used prefixes, we now use the next-to-last two charters. - func NextToLast(base32cid string) { nextToLastLen := 2 offset := len(base32cid) - nextToLastLen - 1 return str[offset : offset+nextToLastLen] } - For example, an object with a base58 CIDv1 of - zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f - has a base32 CIDv1 of - BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA - and will be placed at - SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data - with 'SC' being the last-to-next two characters and the 'B' at the beginning of the CIDv1 string is the multibase prefix that is not stored in the filename. diff --git a/test/fixtures/go-ipfs-repo/config b/test/fixtures/go-ipfs-repo/config index e5d9f80cbc..90a67b30b0 100644 --- a/test/fixtures/go-ipfs-repo/config +++ b/test/fixtures/go-ipfs-repo/config @@ -1,52 +1,52 @@ -{ - "Identity":{ - "PeerID":"QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A", - "PrivKey":"CAASpgkwggSiAgEAAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAECggEAZtju/bcKvKFPz0mkHiaJcpycy9STKphorpCT83srBVQi59CdFU6Mj+aL/xt0kCPMVigJw8P3/YCEJ9J+rS8BsoWE+xWUEsJvtXoT7vzPHaAtM3ci1HZd302Mz1+GgS8Epdx+7F5p80XAFLDUnELzOzKftvWGZmWfSeDnslwVONkL/1VAzwKy7Ce6hk4SxRE7l2NE2OklSHOzCGU1f78ZzVYKSnS5Ag9YrGjOAmTOXDbKNKN/qIorAQ1bovzGoCwx3iGIatQKFOxyVCyO1PsJYT7JO+kZbhBWRRE+L7l+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a+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 + "Datastore": { + "Type": "", + "Path": false, + "StorageMax": "", + "StorageGCWatermark": 0, + "GCPeriod": "", + "Params": null, + "NoSync": false }, - "Addresses":{ - "Swarm":[ + "Addresses": { + "Swarm": [ "/ip4/127.0.0.1/tcp/0", "/ip4/127.0.0.1/tcp/0/ws" ], - "API":"/ip4/127.0.0.1/tcp/0", - "Gateway":"/ip4/127.0.0.1/tcp/0" + "API": "/ip4/127.0.0.1/tcp/0", + "Gateway": "/ip4/127.0.0.1/tcp/0" }, - "Mounts":{ - "IPFS":"/ipfs", - "IPNS":"/ipns", - "FuseAllowOther":false + "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" + "Version": { + "Current": "0.4.0-dev", + "Check": "error", + "CheckDate": "0001-01-01T00:00:00Z", + "CheckPeriod": "172800000000000", + "AutoUpdate": "minor" }, - "Discovery":{ - "MDNS":{ - "Enabled":false, - "Interval":10 + "Discovery": { + "MDNS": { + "Enabled": false, + "Interval": 10 }, "webRTCStar": { "Enabled": false } }, - "Ipns":{ - "RepublishPeriod":"", - "RecordLifetime":"", - "ResolveCacheSize":128 + "Ipns": { + "RepublishPeriod": "", + "RecordLifetime": "", + "ResolveCacheSize": 128 }, - "Bootstrap":[ + "Bootstrap": [ "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", @@ -67,16 +67,16 @@ "/dns4/wss0.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic", "/dns4/wss1.bootstrap.libp2p.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6" ], - "Tour":{ - "Last":"" + "Tour": { + "Last": "" }, - "Gateway":{ - "HTTPHeaders":null, - "RootRedirect":"", - "Writable":false + "Gateway": { + "HTTPHeaders": null, + "RootRedirect": "", + "Writable": false }, - "SupernodeRouting":{ - "Servers":[ + "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", @@ -87,15 +87,23 @@ "/ip4/178.62.61.185/tcp/4002/ipfs/QmVw6fGNqBixZE4bewRLT2VXX7fAHUHs8JyidDiJ1P7RUN" ] }, - "API":{ - "HTTPHeaders":null + "API": { + "HTTPHeaders": null }, - "Swarm":{ - "AddrFilters":null + "Swarm": { + "AddrFilters": null }, - "Log":{ - "MaxSizeMB":250, - "MaxBackups":1, - "MaxAgeDays":0 + "Log": { + "MaxSizeMB": 250, + "MaxBackups": 1, + "MaxAgeDays": 0 + }, + "Keychain": { + "dek": { + "keyLength": 64, + "iterationCount": 10000, + "salt": "cZ3+loP2jVih3C91aaSTWvQ4", + "hash": "sha2-512" + } } -} +} \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/datastore/CURRENT b/test/fixtures/go-ipfs-repo/datastore/CURRENT index 23b73d9100..a56825eec6 100644 --- a/test/fixtures/go-ipfs-repo/datastore/CURRENT +++ b/test/fixtures/go-ipfs-repo/datastore/CURRENT @@ -1 +1 @@ -MANIFEST-000014 +MANIFEST-000033 diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG b/test/fixtures/go-ipfs-repo/datastore/LOG index 96e7909dfc..b666f90fa5 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG +++ b/test/fixtures/go-ipfs-repo/datastore/LOG @@ -1,29 +1,3 @@ -=============== Aug 25, 2016 (CEST) =============== -17:21:42.391799 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -17:21:42.393115 db@open opening -17:21:42.399749 db@janitor F·5 G·1 -17:21:42.399774 db@janitor removing manifest-4 -17:21:42.399904 db@open done T·6.754896ms -=============== Aug 25, 2016 (CEST) =============== -17:36:56.009638 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -17:36:56.009849 version@stat F·[2] S·1KiB[1KiB] Sc·[0.50] -17:36:56.009874 db@open opening -17:36:56.009943 journal@recovery F·1 -17:36:56.010918 journal@recovery recovering @8 -17:36:56.012317 memdb@flush created L0@10 N·4 S·1KiB "/ip..\xf6\xe4\xa9,d12":"/pk..TOA,v9" -17:36:56.013451 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] -17:36:56.014779 db@janitor F·5 G·0 -17:36:56.014815 db@open done T·4.928147ms -17:36:56.030081 db@close closing -17:36:56.030223 db@close done T·138.943µs -=============== Aug 25, 2016 (CEST) =============== -17:37:32.735975 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -17:37:32.736209 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] -17:37:32.736230 db@open opening -17:37:32.736304 journal@recovery F·1 -17:37:32.737385 journal@recovery recovering @11 -17:37:32.738575 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] -17:37:32.739466 db@janitor F·5 G·0 -17:37:32.739492 db@open done T·3.248709ms -17:37:51.684973 db@close closing -17:37:51.685242 db@close done T·168.908µs +2018/02/23-14:49:50.775671 70000e383000 Recovering log #32 +2018/02/23-14:49:50.778664 70000e383000 Delete type=3 #31 +2018/02/23-14:49:50.778816 70000e383000 Delete type=0 #32 diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG.old b/test/fixtures/go-ipfs-repo/datastore/LOG.old index 863b68fd57..5a37d0c410 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG.old +++ b/test/fixtures/go-ipfs-repo/datastore/LOG.old @@ -1,10 +1,3 @@ -=============== Dec 10, 2015 (PST) =============== -07:50:02.056578 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -07:50:02.057231 db@open opening -07:50:02.057312 journal@recovery F·1 -07:50:02.057514 journal@recovery recovering @3 -07:50:02.058921 mem@flush created L0@5 N·4 S·1KiB "/ip..\xf6\xe4\xa9,v5":"/pk..\xf6\xe4\xa9,v6" -07:50:02.059983 db@janitor F·4 G·0 -07:50:02.060001 db@open done T·2.755926ms -07:50:02.073183 db@close closing -07:50:02.073285 db@close done T·97.522µs +2018/02/23-14:49:40.001870 700011f92000 Recovering log #30 +2018/02/23-14:49:40.005865 700011f92000 Delete type=3 #29 +2018/02/23-14:49:40.006133 700011f92000 Delete type=0 #30 diff --git a/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000014 b/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000014 deleted file mode 100644 index bda0ce84e55dad819ef3e95a12373f69463ecfaa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 314 zcmdJcTULFAv{=p%R0p5|p&LRGe zjGPcN*cn(K5N|UhD@2zb$Y#P0Wn_a{!gQHYLO&-zIWb2+Ei)&zxF|orgpmm%D-4w= M$jmEdWQ2$T0KrCJEdT%j diff --git a/test/http-api/extra/block.js b/test/http-api/extra/block.js index d75712321d..642d626a68 100644 --- a/test/http-api/extra/block.js +++ b/test/http-api/extra/block.js @@ -8,13 +8,26 @@ chai.use(dirtyChai) const multihash = require('multihashes') const waterfall = require('async/waterfall') -const getCtl = require('./utils/get-ctl.js') -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra block', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = ipfsd.api + done() + }) }) + + after((done) => ipfsd.stop(done)) + describe('.block', () => { describe('.put', () => { it('updates value', (done) => { @@ -25,7 +38,7 @@ module.exports = (http) => { } waterfall([ - (cb) => ctl.block.put(data, cb), + (cb) => ipfs.block.put(data, cb), (block, cb) => { expect(block.cid.multihash).to.eql( multihash.fromB58String(expectedResult.key) @@ -38,14 +51,14 @@ module.exports = (http) => { describe('.get', () => { it('returns error for request with invalid argument', (done) => { - ctl.block.get('invalid', (err, result) => { + ipfs.block.get('invalid', (err, result) => { expect(err).to.exist() done() }) }) it('returns value', (done) => { - ctl.block.get('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp', (err, result) => { + ipfs.block.get('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp', (err, result) => { expect(err).to.not.exist() expect(result.data.toString()) .to.equal('hello world\n') @@ -56,21 +69,21 @@ module.exports = (http) => { describe('.stat', () => { it('returns error for request without argument', (done) => { - ctl.block.stat(null, (err, result) => { + ipfs.block.stat(null, (err, result) => { expect(err).to.exist() done() }) }) it('returns error for request with invalid argument', (done) => { - ctl.block.stat('invalid', (err, result) => { + ipfs.block.stat('invalid', (err, result) => { expect(err).to.exist() done() }) }) it('returns value', (done) => { - ctl.block.stat('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp', (err, result) => { + ipfs.block.stat('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp', (err, result) => { expect(err).to.not.exist() expect(result.key) .to.equal('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp') @@ -80,4 +93,4 @@ module.exports = (http) => { }) }) }) -} +}) diff --git a/test/http-api/extra/bootstrap.js b/test/http-api/extra/bootstrap.js index a0ab204cf4..b14075393c 100644 --- a/test/http-api/extra/bootstrap.js +++ b/test/http-api/extra/bootstrap.js @@ -1,3 +1,4 @@ +/* eslint max-nested-callbacks: ["error", 8] */ /* eslint-env mocha */ 'use strict' @@ -5,13 +6,26 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const getCtl = require('./utils/get-ctl.js') -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra bootstrap', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = ipfsd.api + done() + }) }) + + after((done) => ipfsd.stop(done)) + describe('.bootstrap', () => { const invalidArg = 'this/Is/So/Invalid/' const validIp4 = '/ip4/101.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z' @@ -21,14 +35,14 @@ module.exports = (http) => { this.timeout(40 * 1000) it('returns an error when called with an invalid arg', (done) => { - ctl.bootstrap.add(invalidArg, (err) => { + ipfs.bootstrap.add(invalidArg, (err) => { expect(err).to.be.an.instanceof(Error) done() }) }) it('returns a list of containing the bootstrap peer when called with a valid arg (ip4)', (done) => { - ctl.bootstrap.add(validIp4, (err, res) => { + ipfs.bootstrap.add(validIp4, (err, res) => { expect(err).to.not.exist() expect(res).to.be.eql({ Peers: [validIp4] }) done() @@ -36,20 +50,20 @@ module.exports = (http) => { }) it('prevents duplicate inserts of bootstrap peers', () => { - return ctl + return ipfs .bootstrap .rm(null, { all: true }) .then((res) => { expect(res.Peers.length).to.equal(0) - return ctl.bootstrap.add(validIp4) + return ipfs.bootstrap.add(validIp4) }) .then(res => { expect(res).to.be.eql({ Peers: [validIp4] }) - return ctl.bootstrap.add(validIp4) + return ipfs.bootstrap.add(validIp4) }) .then((res) => { expect(res).to.be.eql({ Peers: [validIp4] }) - return ctl.bootstrap.list() + return ipfs.bootstrap.list() }) .then((res) => { expect(res).to.exist() @@ -60,7 +74,7 @@ module.exports = (http) => { }) it('returns a list of bootstrap peers when called with the default option', (done) => { - ctl.bootstrap.add({ default: true }, (err, res) => { + ipfs.bootstrap.add({ default: true }, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -72,7 +86,7 @@ module.exports = (http) => { describe('.list', () => { it('returns a list of peers', (done) => { - ctl.bootstrap.list((err, res) => { + ipfs.bootstrap.list((err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -83,14 +97,14 @@ module.exports = (http) => { describe('.rm', () => { it('returns an error when called with an invalid arg', (done) => { - ctl.bootstrap.rm(invalidArg, (err) => { + ipfs.bootstrap.rm(invalidArg, (err) => { expect(err).to.be.an.instanceof(Error) done() }) }) it('returns empty list because no peers removed when called without an arg or options', (done) => { - ctl.bootstrap.rm(null, (err, res) => { + ipfs.bootstrap.rm(null, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -100,7 +114,7 @@ module.exports = (http) => { }) it('returns list containing the peer removed when called with a valid arg (ip4)', (done) => { - ctl.bootstrap.rm(validIp4, (err, res) => { + ipfs.bootstrap.rm(validIp4, (err, res) => { expect(err).to.not.exist() peers = res.Peers @@ -111,7 +125,7 @@ module.exports = (http) => { }) it('returns list of all peers removed when all option is passed', (done) => { - ctl.bootstrap.rm(null, { all: true }, (err, res) => { + ipfs.bootstrap.rm(null, { all: true }, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -120,4 +134,4 @@ module.exports = (http) => { }) }) }) -} +}) diff --git a/test/http-api/extra/config.js b/test/http-api/extra/config.js index 6f4dcc868f..2a5e635b63 100644 --- a/test/http-api/extra/config.js +++ b/test/http-api/extra/config.js @@ -6,33 +6,56 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const waterfall = require('async/waterfall') + const fs = require('fs') const path = require('path') -const getCtl = require('./utils/get-ctl.js') - -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) - }) - describe('.config', () => { - const configPath = path.join(__dirname, '../../repo-tests-run/config') - let updatedConfig - - before(() => { +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra config', () => { + // TODO: this didn't seem to point anywhere + const configPath = path.join(__dirname, '../../fixtures/go-ipfs-repo/config') + + let updatedConfig = null + + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + + waterfall([ + (cb) => df.spawn({ + repoPath: path.join(__dirname, '../../fixtures/go-ipfs-repo'), + initOptions: { bits: 512 }, + disposable: false, + start: true + }, cb), + (_ipfsd, cb) => { + ipfsd = _ipfsd + ipfsd.start(cb) + } + ], (err) => { + expect(err).to.not.exist() + ipfs = ipfsd.api updatedConfig = () => JSON.parse(fs.readFileSync(configPath, 'utf8')) + done() }) + }) + after((done) => ipfsd.stop(done)) + + describe('.config', () => { it('.get returns error for request with invalid argument', (done) => { - ctl.config.get('kittens', (err, res) => { + ipfs.config.get('kittens', (err, res) => { expect(err).to.exist() done() }) }) it('.get returns value for request with argument', (done) => { - ctl.config.get('API.HTTPHeaders', (err, value) => { + ipfs.config.get('API.HTTPHeaders', (err, value) => { expect(err).not.to.exist() expect(value).to.equal(null) done() @@ -40,35 +63,35 @@ module.exports = (http) => { }) it('.set updates value for request with both args', (done) => { - ctl.config.set('Datastore.Path', 'kitten', (err) => { + ipfs.config.set('Datastore.Path', 'kitten', (err) => { expect(err).not.to.exist() done() }) }) it('.set returns error for request with both args and JSON flag with invalid JSON argument', (done) => { - ctl.config.set('Datastore.Path', 'kitten', { json: true }, (err) => { + ipfs.config.set('Datastore.Path', 'kitten', { json: true }, (err) => { expect(err).to.exist() done() }) }) it('.set updates value for request with both args and bool flag and true argument', (done) => { - ctl.config.set('Datastore.Path', true, (err) => { + ipfs.config.set('Datastore.Path', true, (err) => { expect(err).not.to.exist() done() }) }) it('.set updates value for request with both args and bool flag and false argument', (done) => { - ctl.config.set('Datastore.Path', false, (err) => { + ipfs.config.set('Datastore.Path', false, (err) => { expect(err).not.to.exist() done() }) }) it('.get updatedConfig', (done) => { - ctl.config.get((err, config) => { + ipfs.config.get((err, config) => { expect(err).not.to.exist() expect(config).to.be.eql(updatedConfig()) done() @@ -81,7 +104,7 @@ module.exports = (http) => { it('returns error if the config is invalid', (done) => { const filePath = 'test/fixtures/test-data/badconfig' - ctl.config.replace(filePath, (err) => { + ipfs.config.replace(filePath, (err) => { expect(err).to.exist() done() }) @@ -91,7 +114,7 @@ module.exports = (http) => { const filePath = 'test/fixtures/test-data/otherconfig' const expectedConfig = JSON.parse(fs.readFileSync(filePath, 'utf8')) - ctl.config.replace(filePath, (err) => { + ipfs.config.replace(filePath, (err) => { expect(err).not.to.exist() expect(expectedConfig).to.deep.equal(updatedConfig()) done() @@ -99,4 +122,4 @@ module.exports = (http) => { }) }) }) -} +}) diff --git a/test/http-api/extra/dns.js b/test/http-api/extra/dns.js index f787d4cbf8..365dca73a2 100644 --- a/test/http-api/extra/dns.js +++ b/test/http-api/extra/dns.js @@ -5,20 +5,32 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const getCtl = require('./utils/get-ctl.js') -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra dns', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = ipfsd.api + done() + }) }) + + after((done) => ipfsd.stop(done)) + describe('.dns', () => { it('resolve ipfs.io dns', (done) => { - ctl.dns('ipfs.io', (err, result) => { + ipfs.dns('ipfs.io', (err, result) => { expect(err).to.not.exist() expect(result).to.exist() done() }) }) }) -} +}) diff --git a/test/http-api/extra/id.js b/test/http-api/extra/id.js index d0635da7a9..633525488f 100644 --- a/test/http-api/extra/id.js +++ b/test/http-api/extra/id.js @@ -5,16 +5,43 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const getCtl = require('./utils/get-ctl.js') -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +const waterfall = require('async/waterfall') +const path = require('path') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra id', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + this.timeout(20 * 1000) + + waterfall([ + (cb) => df.spawn({ + repoPath: path.join(__dirname, '../../fixtures/go-ipfs-repo'), + initOptions: { bits: 512 }, + disposable: false, + start: true + }, cb), + (_ipfsd, cb) => { + ipfsd = _ipfsd + ipfsd.start(cb) + } + ], (err) => { + expect(err).to.not.exist() + ipfs = ipfsd.api + done() + }) }) + + after((done) => ipfsd.stop(done)) + describe('.id', () => { it('get the identity', (done) => { - ctl.id((err, result) => { + ipfs.id((err, result) => { expect(err).to.not.exist() expect(result.id).to.equal(idResult.ID) expect(result.publicKey).to.equal(idResult.PublicKey) @@ -26,12 +53,12 @@ module.exports = (http) => { }) }) }) -} +}) const idResult = { ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A', PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=', - Addresses: [ '/ip4/0.0.0.0/tcp/0' ], + Addresses: ['/ip4/0.0.0.0/tcp/0'], AgentVersion: 'js-ipfs', ProtocolVersion: '9000' } diff --git a/test/http-api/extra/index.js b/test/http-api/extra/index.js new file mode 100644 index 0000000000..fff181e750 --- /dev/null +++ b/test/http-api/extra/index.js @@ -0,0 +1,16 @@ +/* eslint-env mocha */ +'use strict' + +const fs = require('fs') +const path = require('path') + +describe('## extra tests with ipfs-api', () => { + fs.readdirSync(path.join(__dirname)) + .forEach((file) => { + // TODO(victor) want to make all this loading of tests proper, but for now + if (file.includes('utils') || file.includes('index.js')) { + return + } + require(`./${file}`) + }) +}) diff --git a/test/http-api/extra/object.js b/test/http-api/extra/object.js index d24a836867..eced7f28f6 100644 --- a/test/http-api/extra/object.js +++ b/test/http-api/extra/object.js @@ -10,7 +10,9 @@ chai.use(dirtyChai) const fs = require('fs') const dagPB = require('ipld-dag-pb') const DAGLink = dagPB.DAGLink -const getCtl = require('./utils/get-ctl.js') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) function asJson (cb) { return (err, result) => { @@ -20,14 +22,25 @@ function asJson (cb) { } } -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +describe('extra object', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = ipfsd.api + done() + }) }) + + after((done) => ipfsd.stop(done)) + describe('.object', () => { it('.new', (done) => { - ctl.object.new(asJson((err, res) => { + ipfs.object.new(asJson((err, res) => { expect(err).to.not.exist() expect(res.multihash) .to.equal('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n') @@ -38,21 +51,21 @@ module.exports = (http) => { describe('.get', () => { it('returns error for request without argument', (done) => { - ctl.object.get(null, (err, result) => { + ipfs.object.get(null, (err, result) => { expect(err).to.exist() done() }) }) it('returns error for request with invalid argument', (done) => { - ctl.object.get('invalid', {enc: 'base58'}, (err, result) => { + ipfs.object.get('invalid', { enc: 'base58' }, (err, result) => { expect(err).to.exist() done() }) }) it('returns value', (done) => { - ctl.object.get('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n', {enc: 'base58'}, asJson((err, res) => { + ipfs.object.get('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n', { enc: 'base58' }, asJson((err, res) => { expect(err).to.not.exist() expect(res.links).to.be.eql([]) expect(res.data).to.eql(Buffer.from('')) @@ -65,7 +78,7 @@ module.exports = (http) => { it('returns error if the node is invalid', (done) => { const filePath = 'test/fixtures/test-data/badnode.json' - ctl.object.put(filePath, {enc: 'json'}, (err) => { + ipfs.object.put(filePath, { enc: 'json' }, (err) => { expect(err).to.exist() done() }) @@ -84,7 +97,7 @@ module.exports = (http) => { size: 68 } - ctl.object.put(filePath, {enc: 'json'}, asJson((err, res) => { + ipfs.object.put(filePath, { enc: 'json' }, asJson((err, res) => { expect(err).to.not.exist() expect(res).to.eql(expectedResult) done() @@ -94,21 +107,21 @@ module.exports = (http) => { describe('.stat', () => { it('returns error for request without argument', (done) => { - ctl.object.stat(null, (err, result) => { + ipfs.object.stat(null, (err, result) => { expect(err).to.exist() done() }) }) it('returns error for request with invalid argument', (done) => { - ctl.object.stat('invalid', {enc: 'base58'}, (err, result) => { + ipfs.object.stat('invalid', { enc: 'base58' }, (err, result) => { expect(err).to.exist() done() }) }) it('returns value', (done) => { - ctl.object.stat('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', {enc: 'base58'}, (err, result) => { + ipfs.object.stat('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', { enc: 'base58' }, (err, result) => { expect(err).to.not.exist() expect(result.Hash).to.equal('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm') expect(result.NumLinks).to.equal(1) @@ -123,21 +136,21 @@ module.exports = (http) => { describe('.data', () => { it('returns error for request without argument', (done) => { - ctl.object.data(null, (err, result) => { + ipfs.object.data(null, (err, result) => { expect(err).to.exist() done() }) }) it('returns error for request with invalid argument', (done) => { - ctl.object.data('invalid', {enc: 'base58'}, (err, result) => { + ipfs.object.data('invalid', { enc: 'base58' }, (err, result) => { expect(err).to.exist() done() }) }) it('returns value', (done) => { - ctl.object.data('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', {enc: 'base58'}, (err, result) => { + ipfs.object.data('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', { enc: 'base58' }, (err, result) => { expect(err).to.not.exist() expect(result.toString()).to.equal('another') done() @@ -147,14 +160,14 @@ module.exports = (http) => { describe('.links', () => { it('returns error for request without argument', (done) => { - ctl.object.links(null, (err, result) => { + ipfs.object.links(null, (err, result) => { expect(err).to.exist() done() }) }) it('returns error for request with invalid argument', (done) => { - ctl.object.links('invalid', {enc: 'base58'}, (err, result) => { + ipfs.object.links('invalid', { enc: 'base58' }, (err, result) => { expect(err).to.exist() done() }) @@ -167,7 +180,7 @@ module.exports = (http) => { size: 8 } - ctl.object.links('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', {enc: 'base58'}, (err, result) => { + ipfs.object.links('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', { enc: 'base58' }, (err, result) => { expect(err).to.not.exist() expect(result[0].toJSON()).to.deep.equal(expectedResult) done() @@ -177,7 +190,7 @@ module.exports = (http) => { describe('.patch.appendData', () => { it('returns error for request without key & data', (done) => { - ctl.object.patch.appendData(null, null, (err) => { + ipfs.object.patch.appendData(null, null, (err) => { expect(err).to.exist() done() }) @@ -186,7 +199,7 @@ module.exports = (http) => { it('returns error for request without data', (done) => { const filePath = 'test/fixtures/test-data/badnode.json' - ctl.object.patch.appendData(null, filePath, (err) => { + ipfs.object.patch.appendData(null, filePath, (err) => { expect(err).to.exist() done() }) @@ -202,7 +215,7 @@ module.exports = (http) => { size: 19 } - ctl.object.patch.appendData(key, filePath, {enc: 'base58'}, asJson((err, res) => { + ipfs.object.patch.appendData(key, filePath, { enc: 'base58' }, asJson((err, res) => { expect(err).to.not.exist() expect(res).to.eql(expectedResult) done() @@ -212,7 +225,7 @@ module.exports = (http) => { describe('.patch.setData', () => { it('returns error for request without key & data', (done) => { - ctl.object.patch.setData(null, null, (err) => { + ipfs.object.patch.setData(null, null, (err) => { expect(err).to.exist() done() }) @@ -221,7 +234,7 @@ module.exports = (http) => { it('returns error for request without data', (done) => { const filePath = 'test/fixtures/test-data/badnode.json' - ctl.object.patch.setData(null, filePath, (err) => { + ipfs.object.patch.setData(null, filePath, (err) => { expect(err).to.exist() done() }) @@ -237,7 +250,7 @@ module.exports = (http) => { size: 19 } - ctl.object.patch.setData(key, filePath, {enc: 'base58'}, asJson((err, res) => { + ipfs.object.patch.setData(key, filePath, { enc: 'base58' }, asJson((err, res) => { expect(err).to.not.exist() expect(res).to.eql(expectedResult) done() @@ -247,14 +260,14 @@ module.exports = (http) => { describe('.patch.addLink', () => { it('returns error for request without arguments', (done) => { - ctl.object.patch.addLink(null, null, null, (err) => { + ipfs.object.patch.addLink(null, null, null, (err) => { expect(err).to.exist() done() }) }) it('returns error for request only one invalid argument', (done) => { - ctl.object.patch.addLink('invalid', null, null, (err) => { + ipfs.object.patch.addLink('invalid', null, null, (err) => { expect(err).to.exist() done() }) @@ -265,7 +278,7 @@ module.exports = (http) => { const name = '' const ref = 'QmTz3oc4gdpRMKP2sdGUPZTAGRngqjsi99BPoztyP53JMM' const link = new DAGLink(name, 2, ref) - ctl.object.patch.addLink(root, link, {enc: 'base58'}, (err) => { + ipfs.object.patch.addLink(root, link, { enc: 'base58' }, (err) => { expect(err).to.exist() done() }) @@ -276,7 +289,7 @@ module.exports = (http) => { const name = 'foo' const ref = 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn' const link = new DAGLink(name, 10, ref) - ctl.object.patch.addLink(root, link, {enc: 'base58'}, asJson((err, res) => { + ipfs.object.patch.addLink(root, link, { enc: 'base58' }, asJson((err, res) => { expect(err).not.to.exist() expect(res.multihash).to.equal('QmdVHE8fUD6FLNLugtNxqDFyhaCgdob372hs6BYEe75VAK') expect(res.links[0]).to.eql({ @@ -291,14 +304,14 @@ module.exports = (http) => { describe('.patch.rmLink', () => { it('returns error for request without arguments', (done) => { - ctl.object.patch.rmLink(null, null, (err) => { + ipfs.object.patch.rmLink(null, null, (err) => { expect(err).to.exist() done() }) }) it('returns error for request only one invalid argument', (done) => { - ctl.object.patch.rmLink('invalid', null, (err) => { + ipfs.object.patch.rmLink('invalid', null, (err) => { expect(err).to.exist() done() }) @@ -308,11 +321,11 @@ module.exports = (http) => { const root = '' const link = 'foo' - ctl.object.patch.rmLink(root, link, (err) => { + ipfs.object.patch.rmLink(root, link, (err) => { expect(err).to.exist() done() }) }) }) }) -} +}) diff --git a/test/http-api/extra/version.js b/test/http-api/extra/version.js index 2adb18ecd9..8a22deff0d 100644 --- a/test/http-api/extra/version.js +++ b/test/http-api/extra/version.js @@ -5,16 +5,28 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const getCtl = require('./utils/get-ctl.js') -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra version', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = ipfsd.api + done() + }) }) + + after((done) => ipfsd.stop(done)) + describe('.version', () => { it('get the version', (done) => { - ctl.version((err, result) => { + ipfs.version((err, result) => { expect(err).to.not.exist() expect(result).to.have.a.property('version') expect(result).to.have.a.property('commit') @@ -23,4 +35,4 @@ module.exports = (http) => { }) }) }) -} +}) diff --git a/test/http-api/index.js b/test/http-api/index.js index 99c5a86adc..0d6941e9dd 100644 --- a/test/http-api/index.js +++ b/test/http-api/index.js @@ -1,79 +1,5 @@ -/* eslint-env mocha */ 'use strict' -const fs = require('fs') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) -const hat = require('hat') -const API = require('../../src/http') -const ncp = require('ncp').ncp -const path = require('path') -const clean = require('../utils/clean') - -describe('HTTP API', () => { - const repoExample = path.join(__dirname, '../fixtures/go-ipfs-repo') - const repoTests = path.join(__dirname, '../repo-tests-run') - - let http = {} - - const startHttpAPI = (cb) => { - const options = { - pass: hat(), - enablePubsubExperiment: true - } - http.api = new API(repoTests, null, options) - - ncp(repoExample, repoTests, (err) => { - if (err) { - return cb(err) - } - - http.api.start(false, (err) => { - if (err) { - return cb(err) - } - cb(null, http) - }) - }) - } - - before(function (done) { - this.timeout(60 * 1000) - startHttpAPI((err, _http) => { - if (err) { - throw err - } - http = _http - done() - }) - }) - - after((done) => http.api.stop((err) => { - expect(err).to.not.exist() - clean(repoTests) - done() - })) - - describe('## http-api spec tests', () => { - fs.readdirSync(path.join(__dirname, '/spec')) - .forEach((file) => require('./spec/' + file)(http)) - }) - - describe('## interface-ipfs-core over ipfs-api', () => { - fs.readdirSync(path.join(__dirname, '/interface')) - .forEach((file) => require('./interface/' + file)) - }) - - describe('## extra tests with ipfs-api', () => { - fs.readdirSync(path.join(__dirname, '/extra')) - .forEach((file) => { - // TODO(victor) want to make all this loading of tests proper, but for now - if (file.includes('utils')) { - return - } - require('./extra/' + file)(http) - }) - }) -}) +require('./spec') +require('./interface') +require('./extra') diff --git a/test/http-api/interface/block.js b/test/http-api/interface/block.js index a3a7717f03..ef9e63f370 100644 --- a/test/http-api/interface/block.js +++ b/test/http-api/interface/block.js @@ -12,9 +12,7 @@ const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn({ - initOptions: { bits: 512 } - }, (err, _ipfsd) => { + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/http-api/interface/index.js b/test/http-api/interface/index.js new file mode 100644 index 0000000000..7239f09e3a --- /dev/null +++ b/test/http-api/interface/index.js @@ -0,0 +1,10 @@ +/* eslint-env mocha */ +'use strict' + +const fs = require('fs') +const path = require('path') + +describe('## interface-ipfs-core over ipfs-api', () => { + fs.readdirSync(path.join(__dirname)) + .forEach((file) => file !== 'index.js' && require(`./${file}`)) +}) diff --git a/test/http-api/spec/index.js b/test/http-api/spec/index.js new file mode 100644 index 0000000000..24d94ebc4e --- /dev/null +++ b/test/http-api/spec/index.js @@ -0,0 +1,63 @@ +/* eslint-env mocha */ +'use strict' + +const fs = require('fs') +const chai = require('chai') +const dirtyChai = require('dirty-chai') +const expect = chai.expect +chai.use(dirtyChai) +const hat = require('hat') +const API = require('../../../src/http/index') +const ncp = require('ncp').ncp +const path = require('path') +const clean = require('../../utils/clean') + +describe('HTTP API', () => { + const repoExample = path.join(__dirname, '../../fixtures/go-ipfs-repo') + const repoTests = path.join(__dirname, '../../repo-tests-run') + + let http = {} + + const startHttpAPI = (cb) => { + const options = { + pass: hat(), + enablePubsubExperiment: true + } + http.api = new API(repoTests, null, options) + + ncp(repoExample, repoTests, (err) => { + if (err) { + return cb(err) + } + + http.api.start(false, (err) => { + if (err) { + return cb(err) + } + cb(null, http) + }) + }) + } + + before(function (done) { + this.timeout(60 * 1000) + startHttpAPI((err, _http) => { + if (err) { + throw err + } + http = _http + done() + }) + }) + + after((done) => http.api.stop((err) => { + expect(err).to.not.exist() + clean(repoTests) + done() + })) + + describe('## http-api spec tests', () => { + fs.readdirSync(path.join(__dirname)) + .forEach((file) => file !== 'index.js' && require(`./${file}`)(http)) + }) +}) From 6c6df7cfe686f3a25bd029c13e9b9574b935d3df Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 23 Feb 2018 15:11:14 -0600 Subject: [PATCH 2/5] fix: copy repo --- test/fixtures/go-ipfs-repo/datastore/CURRENT | 2 +- test/fixtures/go-ipfs-repo/datastore/LOG | 6 +-- test/fixtures/go-ipfs-repo/datastore/LOG.old | 6 +-- test/http-api/extra/config.js | 51 +++++++++++++------- test/http-api/extra/id.js | 45 +++++++++++------ 5 files changed, 70 insertions(+), 40 deletions(-) diff --git a/test/fixtures/go-ipfs-repo/datastore/CURRENT b/test/fixtures/go-ipfs-repo/datastore/CURRENT index a56825eec6..29a53d866a 100644 --- a/test/fixtures/go-ipfs-repo/datastore/CURRENT +++ b/test/fixtures/go-ipfs-repo/datastore/CURRENT @@ -1 +1 @@ -MANIFEST-000033 +MANIFEST-000035 diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG b/test/fixtures/go-ipfs-repo/datastore/LOG index b666f90fa5..1b19c3538d 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG +++ b/test/fixtures/go-ipfs-repo/datastore/LOG @@ -1,3 +1,3 @@ -2018/02/23-14:49:50.775671 70000e383000 Recovering log #32 -2018/02/23-14:49:50.778664 70000e383000 Delete type=3 #31 -2018/02/23-14:49:50.778816 70000e383000 Delete type=0 #32 +2018/02/23-15:10:20.675770 700007cb4000 Recovering log #34 +2018/02/23-15:10:20.677371 700007cb4000 Delete type=3 #33 +2018/02/23-15:10:20.677545 700007cb4000 Delete type=0 #34 diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG.old b/test/fixtures/go-ipfs-repo/datastore/LOG.old index 5a37d0c410..b666f90fa5 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG.old +++ b/test/fixtures/go-ipfs-repo/datastore/LOG.old @@ -1,3 +1,3 @@ -2018/02/23-14:49:40.001870 700011f92000 Recovering log #30 -2018/02/23-14:49:40.005865 700011f92000 Delete type=3 #29 -2018/02/23-14:49:40.006133 700011f92000 Delete type=0 #30 +2018/02/23-14:49:50.775671 70000e383000 Recovering log #32 +2018/02/23-14:49:50.778664 70000e383000 Delete type=3 #31 +2018/02/23-14:49:50.778816 70000e383000 Delete type=0 #32 diff --git a/test/http-api/extra/config.js b/test/http-api/extra/config.js index 2a5e635b63..1edbff4a11 100644 --- a/test/http-api/extra/config.js +++ b/test/http-api/extra/config.js @@ -6,6 +6,8 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const ncp = require('ncp').ncp +const rimraf = require('rimraf') const waterfall = require('async/waterfall') const fs = require('fs') @@ -16,7 +18,8 @@ const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) describe('extra config', () => { // TODO: this didn't seem to point anywhere - const configPath = path.join(__dirname, '../../fixtures/go-ipfs-repo/config') + const repoExample = path.join(__dirname, '../../fixtures/go-ipfs-repo') + const repoTests = path.join(__dirname, '../../repo-tests-run') let updatedConfig = null @@ -25,26 +28,40 @@ describe('extra config', () => { before(function (done) { this.timeout(20 * 1000) - waterfall([ - (cb) => df.spawn({ - repoPath: path.join(__dirname, '../../fixtures/go-ipfs-repo'), - initOptions: { bits: 512 }, - disposable: false, - start: true - }, cb), - (_ipfsd, cb) => { - ipfsd = _ipfsd - ipfsd.start(cb) - } - ], (err) => { + ncp(repoExample, repoTests, (err) => { expect(err).to.not.exist() - ipfs = ipfsd.api - updatedConfig = () => JSON.parse(fs.readFileSync(configPath, 'utf8')) - done() + + waterfall([ + (cb) => df.spawn({ + repoPath: repoTests, + initOptions: { bits: 512 }, + disposable: false, + start: true + }, cb), + (_ipfsd, cb) => { + ipfsd = _ipfsd + ipfsd.start(cb) + } + ], (err) => { + expect(err).to.not.exist() + ipfs = ipfsd.api + + updatedConfig = () => { + const file = fs.readFileSync(path.join(__dirname, '../../repo-tests-run/config')) + return JSON.parse(file, 'utf8') + } + + done() + }) }) }) - after((done) => ipfsd.stop(done)) + after((done) => { + rimraf(repoTests, (err) => { + expect(err).to.not.exist() + ipfsd.stop(done) + }) + }) describe('.config', () => { it('.get returns error for request with invalid argument', (done) => { diff --git a/test/http-api/extra/id.js b/test/http-api/extra/id.js index 633525488f..3ee69bc4a1 100644 --- a/test/http-api/extra/id.js +++ b/test/http-api/extra/id.js @@ -6,6 +6,8 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const ncp = require('ncp').ncp +const rimraf = require('rimraf') const waterfall = require('async/waterfall') const path = require('path') @@ -13,31 +15,42 @@ const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) describe('extra id', () => { + const repoExample = path.join(__dirname, '../../fixtures/go-ipfs-repo') + const repoTests = path.join(__dirname, '../../repo-tests-run') + let ipfs = null let ipfsd = null before(function (done) { this.timeout(20 * 1000) - this.timeout(20 * 1000) - waterfall([ - (cb) => df.spawn({ - repoPath: path.join(__dirname, '../../fixtures/go-ipfs-repo'), - initOptions: { bits: 512 }, - disposable: false, - start: true - }, cb), - (_ipfsd, cb) => { - ipfsd = _ipfsd - ipfsd.start(cb) - } - ], (err) => { + ncp(repoExample, repoTests, (err) => { expect(err).to.not.exist() - ipfs = ipfsd.api - done() + + waterfall([ + (cb) => df.spawn({ + repoPath: path.join(__dirname, '../../fixtures/go-ipfs-repo'), + initOptions: { bits: 512 }, + disposable: false, + start: true + }, cb), + (_ipfsd, cb) => { + ipfsd = _ipfsd + ipfsd.start(cb) + } + ], (err) => { + expect(err).to.not.exist() + ipfs = ipfsd.api + done() + }) }) }) - after((done) => ipfsd.stop(done)) + after((done) => { + rimraf(repoTests, (err) => { + expect(err).to.not.exist() + ipfsd.stop(done) + }) + }) describe('.id', () => { it('get the identity', (done) => { From ab69cf3f8008efbd1e34b609d21384fbd75b9a44 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 23 Feb 2018 15:13:10 -0600 Subject: [PATCH 3/5] fix: revert fixture changes --- test/fixtures/go-ipfs-repo/blocks/_README | 8 ++ test/fixtures/go-ipfs-repo/config | 116 ++++++++---------- test/fixtures/go-ipfs-repo/datastore/CURRENT | 2 +- test/fixtures/go-ipfs-repo/datastore/LOG | 32 ++++- test/fixtures/go-ipfs-repo/datastore/LOG.old | 13 +- .../go-ipfs-repo/datastore/MANIFEST-000014 | Bin 0 -> 314 bytes 6 files changed, 102 insertions(+), 69 deletions(-) create mode 100644 test/fixtures/go-ipfs-repo/datastore/MANIFEST-000014 diff --git a/test/fixtures/go-ipfs-repo/blocks/_README b/test/fixtures/go-ipfs-repo/blocks/_README index ac3b6034c3..23cb090956 100644 --- a/test/fixtures/go-ipfs-repo/blocks/_README +++ b/test/fixtures/go-ipfs-repo/blocks/_README @@ -6,17 +6,25 @@ All the object files are placed in a tree of directories, based on a function of the CID. This is a form of sharding similar to the objects directory in git repositories. Previously, we used prefixes, we now use the next-to-last two charters. + func NextToLast(base32cid string) { nextToLastLen := 2 offset := len(base32cid) - nextToLastLen - 1 return str[offset : offset+nextToLastLen] } + For example, an object with a base58 CIDv1 of + zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f + has a base32 CIDv1 of + BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA + and will be placed at + SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data + with 'SC' being the last-to-next two characters and the 'B' at the beginning of the CIDv1 string is the multibase prefix that is not stored in the filename. diff --git a/test/fixtures/go-ipfs-repo/config b/test/fixtures/go-ipfs-repo/config index 90a67b30b0..7498da51bf 100644 --- a/test/fixtures/go-ipfs-repo/config +++ b/test/fixtures/go-ipfs-repo/config @@ -1,52 +1,52 @@ -{ - "Identity": { - "PeerID": "QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A", - "PrivKey": "CAASpgkwggSiAgEAAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XY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WbVTgN8cgdpim9lbbIFlpN6SZaVjLQL3J8TWH6wKBgQDSChzItkqWX11CNstJ9zJyUE20I7LrpyBJNgG1gtvz3ZMUQCn3PxxHtQzN9n1P0mSSYs+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": false, - "StorageMax": "", - "StorageGCWatermark": 0, - "GCPeriod": "", - "Params": null, - "NoSync": false + "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" + "Addresses":{ + "Swarm":[ + "/ip4/127.0.0.1/tcp/9999", + "/ip4/127.0.0.1/tcp/9990/ws" ], - "API": "/ip4/127.0.0.1/tcp/0", - "Gateway": "/ip4/127.0.0.1/tcp/0" + "API":"/ip4/127.0.0.1/tcp/6001", + "Gateway":"/ip4/127.0.0.1/tcp/0" }, - "Mounts": { - "IPFS": "/ipfs", - "IPNS": "/ipns", - "FuseAllowOther": false + "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" + "Version":{ + "Current":"0.4.0-dev", + "Check":"error", + "CheckDate":"0001-01-01T00:00:00Z", + "CheckPeriod":"172800000000000", + "AutoUpdate":"minor" }, - "Discovery": { - "MDNS": { - "Enabled": false, - "Interval": 10 + "Discovery":{ + "MDNS":{ + "Enabled":false, + "Interval":10 }, "webRTCStar": { "Enabled": false } }, - "Ipns": { - "RepublishPeriod": "", - "RecordLifetime": "", - "ResolveCacheSize": 128 + "Ipns":{ + "RepublishPeriod":"", + "RecordLifetime":"", + "ResolveCacheSize":128 }, - "Bootstrap": [ + "Bootstrap":[ "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", @@ -67,16 +67,16 @@ "/dns4/wss0.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic", "/dns4/wss1.bootstrap.libp2p.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6" ], - "Tour": { - "Last": "" + "Tour":{ + "Last":"" }, - "Gateway": { - "HTTPHeaders": null, - "RootRedirect": "", - "Writable": false + "Gateway":{ + "HTTPHeaders":null, + "RootRedirect":"", + "Writable":false }, - "SupernodeRouting": { - "Servers": [ + "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", @@ -87,23 +87,15 @@ "/ip4/178.62.61.185/tcp/4002/ipfs/QmVw6fGNqBixZE4bewRLT2VXX7fAHUHs8JyidDiJ1P7RUN" ] }, - "API": { - "HTTPHeaders": null + "API":{ + "HTTPHeaders":null }, - "Swarm": { - "AddrFilters": null + "Swarm":{ + "AddrFilters":null }, - "Log": { - "MaxSizeMB": 250, - "MaxBackups": 1, - "MaxAgeDays": 0 - }, - "Keychain": { - "dek": { - "keyLength": 64, - "iterationCount": 10000, - "salt": "cZ3+loP2jVih3C91aaSTWvQ4", - "hash": "sha2-512" - } + "Log":{ + "MaxSizeMB":250, + "MaxBackups":1, + "MaxAgeDays":0 } -} \ No newline at end of file +} diff --git a/test/fixtures/go-ipfs-repo/datastore/CURRENT b/test/fixtures/go-ipfs-repo/datastore/CURRENT index 29a53d866a..23b73d9100 100644 --- a/test/fixtures/go-ipfs-repo/datastore/CURRENT +++ b/test/fixtures/go-ipfs-repo/datastore/CURRENT @@ -1 +1 @@ -MANIFEST-000035 +MANIFEST-000014 diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG b/test/fixtures/go-ipfs-repo/datastore/LOG index 1b19c3538d..96e7909dfc 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG +++ b/test/fixtures/go-ipfs-repo/datastore/LOG @@ -1,3 +1,29 @@ -2018/02/23-15:10:20.675770 700007cb4000 Recovering log #34 -2018/02/23-15:10:20.677371 700007cb4000 Delete type=3 #33 -2018/02/23-15:10:20.677545 700007cb4000 Delete type=0 #34 +=============== Aug 25, 2016 (CEST) =============== +17:21:42.391799 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +17:21:42.393115 db@open opening +17:21:42.399749 db@janitor F·5 G·1 +17:21:42.399774 db@janitor removing manifest-4 +17:21:42.399904 db@open done T·6.754896ms +=============== Aug 25, 2016 (CEST) =============== +17:36:56.009638 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +17:36:56.009849 version@stat F·[2] S·1KiB[1KiB] Sc·[0.50] +17:36:56.009874 db@open opening +17:36:56.009943 journal@recovery F·1 +17:36:56.010918 journal@recovery recovering @8 +17:36:56.012317 memdb@flush created L0@10 N·4 S·1KiB "/ip..\xf6\xe4\xa9,d12":"/pk..TOA,v9" +17:36:56.013451 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] +17:36:56.014779 db@janitor F·5 G·0 +17:36:56.014815 db@open done T·4.928147ms +17:36:56.030081 db@close closing +17:36:56.030223 db@close done T·138.943µs +=============== Aug 25, 2016 (CEST) =============== +17:37:32.735975 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +17:37:32.736209 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] +17:37:32.736230 db@open opening +17:37:32.736304 journal@recovery F·1 +17:37:32.737385 journal@recovery recovering @11 +17:37:32.738575 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] +17:37:32.739466 db@janitor F·5 G·0 +17:37:32.739492 db@open done T·3.248709ms +17:37:51.684973 db@close closing +17:37:51.685242 db@close done T·168.908µs diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG.old b/test/fixtures/go-ipfs-repo/datastore/LOG.old index b666f90fa5..863b68fd57 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG.old +++ b/test/fixtures/go-ipfs-repo/datastore/LOG.old @@ -1,3 +1,10 @@ -2018/02/23-14:49:50.775671 70000e383000 Recovering log #32 -2018/02/23-14:49:50.778664 70000e383000 Delete type=3 #31 -2018/02/23-14:49:50.778816 70000e383000 Delete type=0 #32 +=============== Dec 10, 2015 (PST) =============== +07:50:02.056578 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +07:50:02.057231 db@open opening +07:50:02.057312 journal@recovery F·1 +07:50:02.057514 journal@recovery recovering @3 +07:50:02.058921 mem@flush created L0@5 N·4 S·1KiB "/ip..\xf6\xe4\xa9,v5":"/pk..\xf6\xe4\xa9,v6" +07:50:02.059983 db@janitor F·4 G·0 +07:50:02.060001 db@open done T·2.755926ms +07:50:02.073183 db@close closing +07:50:02.073285 db@close done T·97.522µs diff --git a/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000014 b/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000014 new file mode 100644 index 0000000000000000000000000000000000000000..bda0ce84e55dad819ef3e95a12373f69463ecfaa GIT binary patch literal 314 zcmdJcTULFAv{=p%R0p5|p&LRGe zjGPcN*cn(K5N|UhD@2zb$Y#P0Wn_a{!gQHYLO&-zIWb2+Ei)&zxF|orgpmm%D-4w= M$jmEdWQ2$T0KrCJEdT%j literal 0 HcmV?d00001 From 3df0bbae24d870be8f5a460c96582aeabed917b8 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 23 Feb 2018 15:14:25 -0600 Subject: [PATCH 4/5] fix: revert fixture changes --- test/fixtures/go-ipfs-repo/config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/fixtures/go-ipfs-repo/config b/test/fixtures/go-ipfs-repo/config index 7498da51bf..e5d9f80cbc 100644 --- a/test/fixtures/go-ipfs-repo/config +++ b/test/fixtures/go-ipfs-repo/config @@ -14,10 +14,10 @@ }, "Addresses":{ "Swarm":[ - "/ip4/127.0.0.1/tcp/9999", - "/ip4/127.0.0.1/tcp/9990/ws" + "/ip4/127.0.0.1/tcp/0", + "/ip4/127.0.0.1/tcp/0/ws" ], - "API":"/ip4/127.0.0.1/tcp/6001", + "API":"/ip4/127.0.0.1/tcp/0", "Gateway":"/ip4/127.0.0.1/tcp/0" }, "Mounts":{ From 803a496a72f45343b2e3a6947c5f9e7508d2c36b Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 23 Feb 2018 15:15:58 -0600 Subject: [PATCH 5/5] fix: remove unused todo --- test/http-api/extra/config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/http-api/extra/config.js b/test/http-api/extra/config.js index 1edbff4a11..0d9ae6e907 100644 --- a/test/http-api/extra/config.js +++ b/test/http-api/extra/config.js @@ -17,7 +17,6 @@ const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) describe('extra config', () => { - // TODO: this didn't seem to point anywhere const repoExample = path.join(__dirname, '../../fixtures/go-ipfs-repo') const repoTests = path.join(__dirname, '../../repo-tests-run')