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 8, 2016
1 parent c91abc4 commit ec70bef
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions test/core/both/test-bitswap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const isNode = require('detect-node')
const IPFS = require('../../../src/core')

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

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

Expand Down Expand Up @@ -68,16 +68,23 @@ 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
return done()
// targetAddr = multiaddr(`/ip4/127.0.0.1/tcp/0/ws/ipfs/${identity.id}`).toString()
}

dialerNode.swarm.connect(targetAddr, done)
dialerNode.swarm.connect(targetAddr, (err) => {
expect(err).to.not.exist
console.log('swarm.connect finished')
dialerNode.swarm.peers((err, peers) => {
expect(err).to.not.exist
console.log(peers.map((peer) => peer.addr))
done()
})
})
})
}

Expand Down Expand Up @@ -125,15 +132,21 @@ describe('bitswap', () => {
(cb) => addNode(13, cb)
], cb),
(res, cb) => {
console.log('going to block/put')
block = res[0]
remoteNode = res[1]
cb()
},
(cb) => remoteNode.block.put(block, cb),
(res, cb) => block.key('sha2-256', cb),
(key, cb) => inProcNode.block.get(key, cb),
(key, cb) => {
console.log('-> 1')
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)
Expand Down

0 comments on commit ec70bef

Please sign in to comment.