Skip to content

Commit

Permalink
chore: Updating CI files (#70)
Browse files Browse the repository at this point in the history
* Updating CI files

This commit updates all CI scripts to the latest version

* Faster tests
  • Loading branch information
victorb authored and daviddias committed Nov 24, 2017
1 parent 8f69354 commit f91f2b6
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
29 changes: 29 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
55 changes: 35 additions & 20 deletions test/peer-id.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@ 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()
})
})

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)
Expand All @@ -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(() => {
Expand Down Expand Up @@ -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) => {
Expand All @@ -103,12 +110,20 @@ describe('PeerId', () => {
})
})

it('Works with default options', function (done) {
this.timeout(10000)
PeerId.create((err, id) => {
expect(err).to.not.exist()
expect(id.toB58String().length).to.equal(46)
done()
})
})

it('Non-default # of bits', function (done) {
// rsa is slow atm
this.timeout(100000)
PeerId.create({ bits: 1024 }, (err, shortId) => {
this.timeout(1000 * 60)
PeerId.create(testOpts, (err, shortId) => {
expect(err).to.not.exist()
PeerId.create({ bits: 4096 }, (err, longId) => {
PeerId.create({ bits: 1024 }, (err, longId) => {
expect(err).to.not.exist()
expect(shortId.privKey.bytes.length).is.below(longId.privKey.bytes.length)
done()
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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) => {
Expand Down Expand Up @@ -193,23 +208,23 @@ 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)
})
})

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)
})
})

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) => {
Expand All @@ -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) => {
Expand All @@ -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()

Expand Down

0 comments on commit f91f2b6

Please sign in to comment.