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

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Sep 1, 2016
1 parent 2838537 commit 66da310
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/core/ipfs/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function block (self) {
return {
get: (hash, callback) => {
hash = cleanHash(hash)

console.log('block.get', hash)
self._blockS.get(hash, callback)
},
put: (block, callback) => {
Expand Down
15 changes: 12 additions & 3 deletions src/core/ipfs/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ module.exports = function init (self) {
opts.emptyRepo = opts.emptyRepo || false
opts.bits = opts.bits || 2048

let config
// Pre-set config values.
const config = JSON.parse(fs.readFileSync(path.join(__dirname, '../../init-files/default-config.json')).toString())
try {
config = JSON.parse(
fs.readFileSync(
path.join(__dirname, '../../init-files/default-config.json')
).toString()
)
} catch (err) {
return callback(err)
}

// Verify repo does not yet exist.
self._repo.exists((err, exists) => {
Expand Down Expand Up @@ -53,7 +62,7 @@ module.exports = function init (self) {
const version = '3'

self._repo.version.set(version, (err) => {
if (err) { return callback(err) }
if (err) return callback(err)

writeConfig()
})
Expand All @@ -62,7 +71,7 @@ module.exports = function init (self) {
// Write the config to the repo.
function writeConfig () {
self._repo.config.set(config, (err) => {
if (err) { return callback(err) }
if (err) return callback(err)

addDefaultAssets()
})
Expand Down
1 change: 0 additions & 1 deletion test/cli/test-bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const expect = require('chai').expect
Expand Down
1 change: 0 additions & 1 deletion test/cli/test-object.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const expect = require('chai').expect
Expand Down
3 changes: 1 addition & 2 deletions test/core/both/test-bitswap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const expect = require('chai').expect
Expand All @@ -21,7 +20,7 @@ function makeBlock () {
return new Block(`IPFS is awesome ${Math.random()}`)
}

describe.skip('bitswap', () => {
describe('bitswap', () => {
let inProcNode // Node spawned inside this process
let swarmAddrsBak

Expand Down
1 change: 0 additions & 1 deletion test/core/both/test-init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const expect = require('chai').expect
Expand Down
1 change: 0 additions & 1 deletion test/core/node-only/test-init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const expect = require('chai').expect
Expand Down
1 change: 0 additions & 1 deletion test/http-api/inject/test-block.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const expect = require('chai').expect
Expand Down
1 change: 0 additions & 1 deletion test/http-api/inject/test-object.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const expect = require('chai').expect
Expand Down
1 change: 0 additions & 1 deletion test/http-api/inject/test-swarm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const expect = require('chai').expect
Expand Down
2 changes: 0 additions & 2 deletions test/http-api/ipfs-api/test-repo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */

'use strict'

// const expect = require('chai').expect
Expand Down
1 change: 0 additions & 1 deletion test/http-api/ipfs-api/test-swarm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'

const expect = require('chai').expect
Expand Down
19 changes: 9 additions & 10 deletions test/utils/temp-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

const expect = require('chai').expect
const leftPad = require('left-pad')
const series = require('run-series')

const IPFS = require('../../src/core')
const createTempRepo = require('./temp-repo')
Expand All @@ -29,16 +30,14 @@ function createTempNode (num, callback) {

num = leftPad(num, 3, 0)

ipfs.init({ emptyRepo: true }, (err) => {
expect(err).to.not.exist
setAddresses(repo, num, (err) => {
expect(err).to.not.exist

ipfs.load((err) => {
expect(err).to.not.exist
callback(null, ipfs)
})
})
series([
(cb) => ipfs.init({ emptyRepo: true }, cb),
(cb) => setAddresses(repo, num, cb),
(cb) => ipfs.load(cb)
], (err) => {
if (err) return callback(err)
callback(null, ipfs)
})
}

module.exports = createTempNode

0 comments on commit 66da310

Please sign in to comment.