Skip to content

Commit

Permalink
feat: stardust4ipfs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Oct 31, 2019
1 parent 25e8c64 commit b4d11e8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"qs": "^6.5.2",
"rimraf": "^3.0.0",
"sinon": "^7.4.2",
"stardust4ipfs": "^0.1.2",
"stream-to-promise": "^2.2.0",
"temp-write": "^4.0.0"
},
Expand Down
4 changes: 1 addition & 3 deletions src/core/runtime/libp2p-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const KadDHT = require('libp2p-kad-dht')
const GossipSub = require('libp2p-gossipsub')
const libp2p = require('libp2p')
const mergeOptions = require('merge-options')
const multiaddr = require('multiaddr')

class Node extends libp2p {
constructor (_options) {
Expand All @@ -26,8 +25,7 @@ class Node extends libp2p {
modules: {
transport: [
WS,
wrtcstar,
wsstar
wrtcstar
],
streamMuxer: [
Multiplex
Expand Down
29 changes: 27 additions & 2 deletions test/core/libp2p.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,31 @@ describe('libp2p customization', function () {
done()
})
})

it('should allow for custom overrideFunction', (done) => {
const ipfs = {
_repo: {
datastore
},
_peerInfo: peerInfo,
_peerBook: peerBook,
// eslint-disable-next-line no-console
_print: console.log,
_options: {
libp2p: {
overrideFunction: require('stardust4ipfs')
}
}
}

_libp2p = libp2pComponent(ipfs, testConfig)

_libp2p.start((err) => {
expect(err).to.not.exist()
expect(_libp2p._transport).to.have.length(3)
done()
})
})
})

describe('options', () => {
Expand Down Expand Up @@ -149,13 +174,13 @@ describe('libp2p customization', function () {
strictSigning: true
}
})
expect(_libp2p._transport).to.have.length(3)
expect(_libp2p._transport).to.have.length(2)
done()
})
})

it('should allow for overriding via options', (done) => {
const wsstar = new WebSocketStar({ id: peerInfo.id })
const wsstar = new Stardust({ id: peerInfo.id })

const ipfs = {
_repo: {
Expand Down

0 comments on commit b4d11e8

Please sign in to comment.