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

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Dec 9, 2016
1 parent 59c678a commit c680339
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"hapi": "^16.0.1",
"hapi-set-header": "^1.0.2",
"idb-pull-blob-store": "^0.5.1",
"ipfs-api": "^12.0.2",
"ipfs-api": "^12.0.3",
"ipfs-bitswap": "^0.8.2",
"ipfs-block": "^0.5.1",
"ipfs-block-service": "^0.7.1",
Expand Down
39 changes: 27 additions & 12 deletions test/core/both/test-bitswap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ const isNode = require('detect-node')

const IPFS = require('../../../src/core')

function makeBlock (cb) {
return cb(null, new Block(`IPFS is awesome ${Math.random()}`))
function makeBlock (callback) {
const block = new Block(new Buffer(`IPFS is awesome ${Math.random()}`))
callback(null, block)
}

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

Expand Down Expand Up @@ -68,8 +69,7 @@ describe('bitswap', () => {
targetAddr = addr.encapsulate(multiaddr(`/ipfs/${identity.id}`)).toString()
targetAddr = targetAddr.replace('0.0.0.0', '127.0.0.1')
} else {
// Note: the browser doesn't have
// a websockets listening addr
// Note: the browser doesn't have a websockets listening addr

// TODO, what we really need is a way to dial to
// a peerId only and another to dial to peerInfo
Expand Down Expand Up @@ -129,19 +129,34 @@ describe('bitswap', () => {
remoteNode = res[1]
cb()
},
(cb) => remoteNode.block.put(block, cb),
(res, cb) => block.key('sha2-256', cb),
(key, cb) => inProcNode.block.get(key, cb),
(cb) => {
remoteNode.block.put(block, (err, _block) => {
expect(err).to.not.exist
expect(block.data).to.eql(_block.data)
cb()
})
},
(cb) => block.key('sha2-256', cb),
(key, cb) => {
console.log('----> 1')
inProcNode.swarm.peers((err, peers) => {
expect(err).to.not.exist
console.log('Got %d peers', peers.length)
})

// remoteNode.block.get(key, cb) // for testing
inProcNode.block.get(key, cb)
},
(b, cb) => {
expect(b.data).to.be.eql(block.data)
console.log('----> 2')

expect(b.data).to.eql(block.data)
cb()
}
], done)
})

it('3 peers', function (done) {
this.timeout(60 * 1000)

it('3 peers', (done) => {
let blocks
let keys
const remoteNodes = []
Expand Down

0 comments on commit c680339

Please sign in to comment.