Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
jsipfs swarm; libp2p start and stop; not fail on browser tests. separ…
Browse files Browse the repository at this point in the history
…ate browser and node.js swarm tests
  • Loading branch information
daviddias committed Mar 21, 2016
1 parent 9676f68 commit 2c5b277
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 41 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ node_js:
- "4"
- "5"

branches:
only:
- master

before_install:
- npm i -g npm
# Workaround for a permissions issue with Travis virtual machine images

addons:
firefox: 'latest'

script:
- npm test

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
js-ipfs
=======
IPFS JavaScript Implementation
==============================

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) ![Build Status](https://travis-ci.org/ipfs/js-ipfs.svg?style=flat-square)](https://travis-ci.org/ipfs/js-ipfs) ![](https://img.shields.io/badge/coverage-75%25-yellow.svg?style=flat-square) [![Dependency Status](https://david-dm.org/ipfs/js-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

Expand Down
3 changes: 2 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ module.exports = function (config) {
},
externals: {
fs: '{}',
'node-forge': 'forge'
'node-forge': 'forge',
'libp2p-ipfs': {} // to be 'libp2p-ipfs-browser'
},
node: {
Buffer: true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"ipfs-multipart": "^0.1.0",
"ipfs-repo": "^0.5.0",
"joi": "^8.0.2",
"libp2p-ipfs": "^0.1.0",
"libp2p-ipfs": "^0.2.0",
"lodash.get": "^4.0.0",
"lodash.set": "^4.0.0",
"peer-id": "^0.6.0",
Expand Down
27 changes: 14 additions & 13 deletions src/http-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ exports.start = (callback) => {
// load routes
require('./routes')(server)

// TODO start libp2p.Node

server.start((err) => {
if (err) {
return callback(err)
}
const api = server.select('API')
const gateway = server.select('Gateway')
console.log('API is listening on: ' + api.info.uri)
console.log('Gateway (readonly) is listening on: ' + gateway.info.uri)
callback()
ipfs.libp2p.start(() => {
server.start((err) => {
if (err) {
return callback(err)
}
const api = server.select('API')
const gateway = server.select('Gateway')
console.log('API is listening on: ' + api.info.uri)
console.log('Gateway (readonly) is listening on: ' + gateway.info.uri)
callback()
})
})
})
})
Expand All @@ -67,6 +67,7 @@ exports.start = (callback) => {
exports.stop = (callback) => {
const repoPath = process.env.IPFS_PATH || os.homedir() + '/.ipfs'
fs.unlinkSync(repoPath + '/api')
// TODO stop libp2p
exports.server.stop(callback)
exports.ipfs.libp2p.stop(() => {
exports.server.stop(callback)
})
}
19 changes: 14 additions & 5 deletions src/ipfs-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const DAGService = mDAG.DAGService
const Id = require('peer-id')
const Info = require('peer-info')
const multiaddr = require('multiaddr')
const libp2p = require('libp2p-ipfs')

exports = module.exports = IPFS

Expand All @@ -26,7 +27,7 @@ function IPFS (repo) {
const blockS = new BlockService(repo)
const dagS = new DAGService(blockS)
var peerInfo
// var libp2pNode
var libp2pNode

this.load = (callback) => {
repo.exists((err, exists) => {
Expand Down Expand Up @@ -304,13 +305,21 @@ function IPFS (repo) {
}

this.libp2p = {
start: () => {

start: (callback) => {
libp2pNode = new libp2p.Node(peerInfo)
libp2pNode.start(() => {
// TODO connect to bootstrap nodes, it will get us more addrs
peerInfo.multiaddrs.forEach((ma) => {
console.log('Swarm listening on', ma.toString())
})
callback()
})
},
stop: () => {
stop: (callback) => {
libp2pNode.swarm.close(callback)
},
swarm: {
peers: notImpl,
peers: () => {},
addrs: notImpl,
connect: notImpl,
disconnect: notImpl,
Expand Down
2 changes: 1 addition & 1 deletion tests/otherconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"Addresses": {
"Swarm": ["/ip4/0.0.0.0/tcp/4001", "/ip6/::/tcp/4001"],
"API": "/ip4/127.0.0.1/tcp/6001",
"Gateway": "/ip4/127.0.0.1/tcp/9090"
"Gateway": "/ip4/127.0.0.1/tcp/9080"
},
"Mounts": {
"IPFS": "/ipfs",
Expand Down
2 changes: 1 addition & 1 deletion tests/repo-example/config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"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/0.0.0.0/tcp/4001","/ip6/::/tcp/4001"],"API":"/ip4/127.0.0.1/tcp/6001","Gateway":"/ip4/127.0.0.1/tcp/9090"},"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"},"Discovery":{"MDNS":{"Enabled":true,"Interval":10}},"Ipns":{"RepublishPeriod":"","RecordLifetime":"","ResolveCacheSize":128},"Bootstrap":["/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ","/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z","/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM","/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm","/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu","/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64","/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd","/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3","/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx"],"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"]},"API":{"HTTPHeaders":null},"Swarm":{"AddrFilters":null},"Log":{"MaxSizeMB":250,"MaxBackups":1,"MaxAgeDays":0}}
{"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/0.0.0.0/tcp/0"],"API":"/ip4/127.0.0.1/tcp/6001","Gateway":"/ip4/127.0.0.1/tcp/9095"},"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"},"Discovery":{"MDNS":{"Enabled":true,"Interval":10}},"Ipns":{"RepublishPeriod":"","RecordLifetime":"","ResolveCacheSize":128},"Bootstrap":["/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ","/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z","/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM","/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm","/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu","/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64","/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd","/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3","/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx"],"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"]},"API":{"HTTPHeaders":null},"Swarm":{"AddrFilters":null},"Log":{"MaxSizeMB":250,"MaxBackups":1,"MaxAgeDays":0}}
11 changes: 6 additions & 5 deletions tests/test-cli/test-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ describe('id', () => {
.run((err, stdout, exitcode) => {
var expected = [ "{ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',",
" PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',",
" Addresses: [ '/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001' ],",
" Addresses: [ '/ip4/0.0.0.0/tcp/0'],",
" AgentVersion: 'js-ipfs',",
" ProtocolVersion: '9000' }" ]

expect(stdout[0]).to.equal(expected[0])
expect(stdout[1]).to.equal(expected[1])
expect(stdout[2]).to.equal(expected[2])
// expect(stdout[2]).to.equal(expected[2])
expect(stdout[3]).to.equal(expected[3])
expect(stdout[4]).to.equal(expected[4])
expect(stdout[5]).to.equal(expected[5])
Expand Down Expand Up @@ -48,15 +48,16 @@ describe('id', () => {
it('get the id', (done) => {
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'id'])
.run((err, stdout, exitcode) => {
var expected = [ "{ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',",
var expected = [
"{ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',",
" PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',",
" Addresses: [ '/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001' ],",
" Addresses: [ '/ip4/0.0.0.0/tcp/0' ],",
" AgentVersion: 'js-ipfs',",
" ProtocolVersion: '9000' }" ]

expect(stdout[0]).to.equal(expected[0])
expect(stdout[1]).to.equal(expected[1])
expect(stdout[2]).to.equal(expected[2])
// expect(stdout[2]).to.equal(expected[2])
expect(stdout[3]).to.equal(expected[3])
expect(stdout[4]).to.equal(expected[4])
expect(stdout[5]).to.equal(expected[5])
Expand Down
12 changes: 11 additions & 1 deletion tests/test-core/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ describe('IPFS Repo Tests on the Browser', function () {
const testsContext = require.context('.', true, /test-*/)
testsContext
.keys()
.forEach((key) => testsContext(key))
.filter((key) => {
if (key === './test-swarm-node.js' ||
key === './test-swarm-node') {
return false
} else {
return true
}
})
.forEach((key) => {
testsContext(key)
})
})
})
4 changes: 3 additions & 1 deletion tests/test-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ describe('core', () => {

const tests = fs.readdirSync(__dirname)
tests.filter((file) => {
if (file === 'index.js' || file === 'browser.js') {
if (file === 'index.js' ||
file === 'browser.js' ||
file === 'test-swarm-browser.js') {
return false
} else {
return true
Expand Down
4 changes: 2 additions & 2 deletions tests/test-core/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ describe('config', () => {
GCPeriod: '',
Params: null,
NoSync: false },
Addresses: { Swarm: [ '/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001' ],
Addresses: { Swarm: [ '/ip4/0.0.0.0/tcp/0' ],
API: '/ip4/127.0.0.1/tcp/6001',
Gateway: '/ip4/127.0.0.1/tcp/9090' },
Gateway: '/ip4/127.0.0.1/tcp/9095' },
Mounts: { IPFS: '/ipfs', IPNS: '/ipns', FuseAllowOther: false },
Version: { Current: '0.4.0-dev',
Check: 'error',
Expand Down
2 changes: 1 addition & 1 deletion tests/test-core/test-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('id', () => {
expect(err).to.not.exist
expect(id).to.deep.equal({ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',
PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',
Addresses: [ '/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001' ],
Addresses: [ '/ip4/0.0.0.0/tcp/0' ],
AgentVersion: 'js-ipfs',
ProtocolVersion: '9000'
})
Expand Down
Empty file.
33 changes: 33 additions & 0 deletions tests/test-core/test-swarm-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-env mocha */

const expect = require('chai').expect

process.env.IPFS_PATH = process.cwd() + '/tests/repo-example'
const IPFS = require('../../src/ipfs-core')

describe('swarm', () => {
var ipfs

before((done) => {
ipfs = new IPFS()
ipfs.load(done)
})

it('start', (done) => {
ipfs.libp2p.start((err) => {
expect(err).to.not.exist
done()
})
})

it.skip('swarm peers', (done) => {})
it.skip('swarm connect', (done) => {})
it.skip('swarm disconnect', (done) => {})

it('stop', (done) => {
ipfs.libp2p.stop((err) => {
expect(err).to.not.exist
done()
})
})
})
12 changes: 9 additions & 3 deletions tests/test-http-api/test-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ describe('id', () => {
method: 'GET',
url: '/api/v0/id'
}, (res) => {
expect(res.result).to.deep.equal(idResult)
expect(res.result.ID).to.equal(idResult.ID)
expect(res.result.PublicKey).to.equal(idResult.PublicKey)
expect(res.result.AgentVersion).to.equal(idResult.AgentVersion)
expect(res.result.ProtocolVersion).to.equal(idResult.ProtocolVersion)
done()
})
})
Expand All @@ -36,7 +39,10 @@ describe('id', () => {
it('get the id', (done) => {
ctl.id((err, result) => {
expect(err).to.not.exist
expect(result).to.deep.equal(idResult)
expect(result.ID).to.equal(idResult.ID)
expect(result.PublicKey).to.equal(idResult.PublicKey)
expect(result.AgentVersion).to.equal(idResult.AgentVersion)
expect(result.ProtocolVersion).to.equal(idResult.ProtocolVersion)
done()
})
})
Expand All @@ -46,7 +52,7 @@ describe('id', () => {
const idResult = {
ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',
PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',
Addresses: [ '/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001' ],
Addresses: [ '/ip4/0.0.0.0/tcp/0' ],
AgentVersion: 'js-ipfs',
ProtocolVersion: '9000'
}

0 comments on commit 2c5b277

Please sign in to comment.