diff --git a/.aegir.js b/.aegir.js index 5abba1b..a754e57 100644 --- a/.aegir.js +++ b/.aegir.js @@ -1,16 +1,8 @@ 'use strict' +/** @type {import('aegir').PartialOptions} */ module.exports = { - webpack: { - node: { - // needed by random-bytes - crypto: true, - - // needed by cipher-base - stream: true, - - // needed by core-util-is - Buffer: true - } + build: { + bundlesizeMax: '17KB' } } diff --git a/.travis.yml b/.travis.yml index c62306b..c601f7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,28 +1,31 @@ language: node_js -cache: npm -stages: - - check - - test - - cov +cache: false +dist: bionic + +branches: + only: + - master + - /^release\/.*$/ node_js: - - '10' + - 'lts/*' + - 'node' + +stages: + - check os: - linux - osx + - windows script: npx nyc -s npm run test:node -- --bail after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov jobs: include: - - os: windows - cache: false - - stage: check script: - - npx aegir commitlint --travis - npx aegir dep-check - npm run lint @@ -36,7 +39,7 @@ jobs: name: firefox addons: firefox: latest - script: npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless + script: npx aegir test -t browser -t webworker -- --browser firefox notifications: email: false diff --git a/package.json b/package.json index 404f8d3..ded7197 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "src" ], "browser": { - "./src/coder/encode.js": "./src/coder/encode.browser.js" + "./src/coder/encode.js": "./src/coder/encode.browser.js", + "libp2p-tcp": false }, "scripts": { "lint": "aegir lint", @@ -42,10 +43,11 @@ }, "homepage": "https://github.com/libp2p/js-libp2p-mplex#readme", "devDependencies": { - "aegir": "^30.3.0", - "libp2p-interfaces": "^0.8.3", + "aegir": "^33.1.0", + "cborg": "^1.2.1", + "iso-random-stream": "^2.0.0", + "libp2p-interfaces": "^0.10.0", "p-defer": "^3.0.0", - "random-bytes": "^1.0.0", "random-int": "^2.0.0", "streaming-iterables": "^5.0.4", "uint8arrays": "^2.0.5" @@ -53,9 +55,9 @@ "dependencies": { "abort-controller": "^3.0.0", "abortable-iterator": "^3.0.0", - "bl": "^4.0.0", + "bl": "^5.0.0", "debug": "^4.3.1", - "err-code": "^2.0.3", + "err-code": "^3.0.1", "it-pipe": "^1.1.0", "it-pushable": "^1.4.1", "varint": "^6.0.0" diff --git a/test/restrict-size.spec.js b/test/restrict-size.spec.js index df8b01d..0b13ffc 100644 --- a/test/restrict-size.spec.js +++ b/test/restrict-size.spec.js @@ -3,7 +3,7 @@ const { expect } = require('aegir/utils/chai') const pipe = require('it-pipe') -const randomBytes = require('random-bytes') +const { randomBytes } = require('iso-random-stream') const { tap, consume, collect } = require('streaming-iterables') const restrictSize = require('../src/restrict-size') diff --git a/test/stream.spec.js b/test/stream.spec.js index 00f989c..7abb801 100644 --- a/test/stream.spec.js +++ b/test/stream.spec.js @@ -3,13 +3,12 @@ const { expect } = require('aegir/utils/chai') const pipe = require('it-pipe') -const randomBytes = require('random-bytes') +const { randomBytes } = require('iso-random-stream') const randomInt = require('random-int') const { tap, take, collect, consume, map } = require('streaming-iterables') const defer = require('p-defer') -const uint8ArrayFromString = require('uint8arrays/from-string') -const uint8ArrayToString = require('uint8arrays/to-string') const uint8ArrayConcat = require('uint8arrays/concat') +const cborg = require('cborg') const createStream = require('../src/stream') const { MessageTypes, MessageTypeNames } = require('../src/message-types') @@ -30,16 +29,8 @@ const infiniteRandom = { } } -const msgToBuffer = msg => uint8ArrayFromString(JSON.stringify(msg)) - -const bufferToMessage = buf => { - const msg = JSON.parse(uint8ArrayToString(buf)) - // JSON.stringify(Buffer) encodes as {"type":"Buffer","data":[1,2,3]} - if (msg.data && msg.data.type === 'Buffer') { - msg.data = new Uint8Array(msg.data.data) - } - return msg -} +const msgToBuffer = msg => cborg.encode(msg) +const bufferToMessage = buf => cborg.decode(buf) describe('stream', () => { it('should initiate stream with NEW_STREAM message', async () => { @@ -320,13 +311,17 @@ describe('stream', () => { await pipe( input, tap(msg => generatedMsgs.push(msg)), - tap(() => { if (i++ >= maxMsgs) initiator.abort(error) }), initiator, tap(msg => { if (msg.data) { msg.data = bufferToMessage(msg.data) } + msgs.push(msg) + + if (i++ >= maxMsgs) { + initiator.abort(error) + } }), consume )