From f91f2b6506b6d1a1630a4e3286a42f48959312f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=A0=C9=AA=E1=B4=84=E1=B4=9B=E1=B4=8F=CA=80=20=CA=99?= =?UTF-8?q?=E1=B4=8A=E1=B4=87=CA=9F=E1=B4=8B=CA=9C=E1=B4=8F=CA=9F=E1=B4=8D?= Date: Fri, 24 Nov 2017 18:46:24 +0100 Subject: [PATCH] chore: Updating CI files (#70) * Updating CI files This commit updates all CI scripts to the latest version * Faster tests --- .travis.yml | 3 ++- appveyor.yml | 29 ++++++++++++++++++++++ ci/Jenkinsfile | 2 ++ circle.yml | 1 + test/peer-id.spec.js | 57 ++++++++++++++++++++++++++++---------------- 5 files changed, 70 insertions(+), 22 deletions(-) create mode 100644 appveyor.yml create mode 100644 ci/Jenkinsfile diff --git a/.travis.yml b/.travis.yml index 371bf0c..5102ee5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories. sudo: false language: node_js @@ -13,7 +14,7 @@ matrix: script: - npm run lint - npm run test - - npm run coverage -- --upload + - npm run coverage before_script: - export DISPLAY=:99.0 diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..046bf91 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,29 @@ +# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories. +version: "{build}" + +environment: + matrix: + - nodejs_version: "6" + - nodejs_version: "8" + +matrix: + fast_finish: true + +install: + # Install Node.js + - ps: Install-Product node $env:nodejs_version + + # Upgrade npm + - npm install -g npm + + # Output our current versions for debugging + - node --version + - npm --version + + # Install our package dependencies + - npm install + +test_script: + - npm run test:node + +build: off diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile new file mode 100644 index 0000000..a7da2e5 --- /dev/null +++ b/ci/Jenkinsfile @@ -0,0 +1,2 @@ +// Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories. +javascript() diff --git a/circle.yml b/circle.yml index 56f7efb..0009693 100644 --- a/circle.yml +++ b/circle.yml @@ -1,3 +1,4 @@ +# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories. machine: node: version: stable diff --git a/test/peer-id.spec.js b/test/peer-id.spec.js index 4fbff6f..2695945 100644 --- a/test/peer-id.spec.js +++ b/test/peer-id.spec.js @@ -19,13 +19,19 @@ const testIdB58String = mh.toB58String(testIdBytes) const goId = require('./fixtures/go-private-key') +// Test options for making PeerId.create faster +// INSECURE, only use when testing +const testOpts = { + bits: 512 +} + describe('PeerId', () => { it('create an id without \'new\'', () => { expect(PeerId).to.throw(Error) }) it('create a new id', (done) => { - PeerId.create((err, id) => { + PeerId.create(testOpts, (err, id) => { expect(err).to.not.exist() expect(id.toB58String().length).to.equal(46) done() @@ -33,7 +39,7 @@ describe('PeerId', () => { }) it('isPeerId', (done) => { - PeerId.create((err, id) => { + PeerId.create(testOpts, (err, id) => { expect(err).to.not.exist() expect(PeerId.isPeerId(id)).to.equal(true) expect(PeerId.isPeerId('aaa')).to.equal(false) @@ -42,8 +48,9 @@ describe('PeerId', () => { }) }) - it('throws on changing the id', (done) => { - PeerId.create((err, id) => { + it('throws on changing the id', function (done) { + this.timeout(10000) + PeerId.create(testOpts, (err, id) => { expect(err).to.not.exist() expect(id.toB58String().length).to.equal(46) expect(() => { @@ -92,7 +99,7 @@ describe('PeerId', () => { }) it('Compare generated ID with one created from PubKey', (done) => { - PeerId.create((err, id1) => { + PeerId.create(testOpts, (err, id1) => { expect(err).to.not.exist() PeerId.createFromPubKey(id1.marshalPubKey(), (err, id2) => { @@ -103,12 +110,20 @@ describe('PeerId', () => { }) }) - it('Non-default # of bits', function (done) { - // rsa is slow atm - this.timeout(100000) - PeerId.create({ bits: 1024 }, (err, shortId) => { + it('Works with default options', function (done) { + this.timeout(10000) + PeerId.create((err, id) => { expect(err).to.not.exist() - PeerId.create({ bits: 4096 }, (err, longId) => { + expect(id.toB58String().length).to.equal(46) + done() + }) + }) + + it('Non-default # of bits', function (done) { + this.timeout(1000 * 60) + PeerId.create(testOpts, (err, shortId) => { + expect(err).to.not.exist() + PeerId.create({ bits: 1024 }, (err, longId) => { expect(err).to.not.exist() expect(shortId.privKey.bytes.length).is.below(longId.privKey.bytes.length) done() @@ -117,7 +132,7 @@ describe('PeerId', () => { }) it('Pretty printing', (done) => { - PeerId.create((err, id1) => { + PeerId.create(testOpts, (err, id1) => { expect(err).to.not.exist() PeerId.createFromPrivKey(id1.toPrint().privKey, (err, id2) => { expect(err).to.not.exist() @@ -134,8 +149,8 @@ describe('PeerId', () => { it('isEqual', (done) => { parallel([ - (cb) => PeerId.create(cb), - (cb) => PeerId.create(cb) + (cb) => PeerId.create(testOpts, cb), + (cb) => PeerId.create(testOpts, cb) ], (err, ids) => { expect(err).to.not.exist() expect(ids[0].isEqual(ids[0])).to.equal(true) @@ -148,7 +163,7 @@ describe('PeerId', () => { describe('fromJSON', () => { it('full node', (done) => { - PeerId.create({ bits: 1024 }, (err, id) => { + PeerId.create(testOpts, (err, id) => { expect(err).to.not.exist() PeerId.createFromJSON(id.toJSON(), (err, other) => { @@ -193,7 +208,7 @@ describe('PeerId', () => { }) it('set privKey (valid)', (done) => { - PeerId.create((err, peerId) => { + PeerId.create(testOpts, (err, peerId) => { expect(err).to.not.exist() peerId.privKey = peerId._privKey peerId.isValid(done) @@ -201,7 +216,7 @@ describe('PeerId', () => { }) it('set pubKey (valid)', (done) => { - PeerId.create((err, peerId) => { + PeerId.create(testOpts, (err, peerId) => { expect(err).to.not.exist() peerId.pubKey = peerId._pubKey peerId.isValid(done) @@ -209,7 +224,7 @@ describe('PeerId', () => { }) it('set privKey (invalid)', (done) => { - PeerId.create((err, peerId) => { + PeerId.create(testOpts, (err, peerId) => { expect(err).to.not.exist() peerId.privKey = Buffer.from('bufff') peerId.isValid((err) => { @@ -220,7 +235,7 @@ describe('PeerId', () => { }) it('set pubKey (invalid)', (done) => { - PeerId.create((err, peerId) => { + PeerId.create(testOpts, (err, peerId) => { expect(err).to.not.exist() peerId.pubKey = Buffer.from('buffff') peerId.isValid((err) => { @@ -237,9 +252,9 @@ describe('PeerId', () => { before((done) => { parallel([ - (cb) => crypto.keys.generateKeyPair('RSA', 1024, cb), - (cb) => crypto.keys.generateKeyPair('RSA', 1024, cb), - (cb) => crypto.keys.generateKeyPair('RSA', 1024, cb) + (cb) => crypto.keys.generateKeyPair('RSA', 512, cb), + (cb) => crypto.keys.generateKeyPair('RSA', 512, cb), + (cb) => crypto.keys.generateKeyPair('RSA', 512, cb) ], (err, keys) => { expect(err).to.not.exist()