Skip to content

Commit a8b1e07

Browse files
richardschneiderdaviddias
authored andcommitted
feat: windows interop (#154)
* test: close IPFSRepo before deleting its files * chore: run on appveyor * chore: upgrade packages * chore: debugging appveyor failure * test: more appveyor debugging * test: use os.tmpdir() not '/tmp' * test: timeout issue * test: fix error reporting * test: Math.Random => uuid Math.Random can create collisions. Using uuid should not create a collision. * test: all tests can timeout, need global timeout specified * test: bitswap-mock multi peer is just too long, skip it * fix package.json * test: [email protected] breaks us. reverting to 0.18.2 * chore: update repo version * chore: update deps * bring back the test
1 parent ab69719 commit a8b1e07

File tree

8 files changed

+49
-16
lines changed

8 files changed

+49
-16
lines changed

appveyor.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
environment:
2+
matrix:
3+
- nodejs_version: "6"
4+
- nodejs_version: "8"
5+
6+
# cache:
7+
# - node_modules
8+
9+
platform:
10+
- x64
11+
12+
install:
13+
- ps: Install-Product node $env:nodejs_version $env:platform
14+
- npm install
15+
16+
test_script:
17+
- node --version
18+
- npm --version
19+
- npm test
20+
21+
build: off
22+
23+
version: "{build}"

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
"./test/utils/create-temp-repo-nodejs.js": "./test/utils/create-temp-repo-browser.js"
99
},
1010
"scripts": {
11-
"test": "aegir test --target node --target browser",
12-
"test:browser": "aegir test --target browser",
13-
"test:node": "aegir test --target node",
11+
"test": "aegir test -t node -t browser",
12+
"test:browser": "aegir test -t browser",
13+
"test:node": "aegir test -t node",
1414
"lint": "aegir lint",
1515
"release": "aegir release",
1616
"release-minor": "aegir release --type minor",
1717
"release-major": "aegir release --type major",
1818
"bench": "node benchmarks/index",
1919
"build": "aegir build",
20-
"coverage": "aegir coverage -u",
20+
"coverage": "aegir coverage --provider codecov",
2121
"docs": "aegir docs"
2222
},
2323
"repository": {
@@ -43,7 +43,7 @@
4343
"dirty-chai": "^2.0.1",
4444
"ipfs-repo": "~0.18.3",
4545
"libp2p": "~0.13.0",
46-
"libp2p-kad-dht": "~0.5.1",
46+
"libp2p-kad-dht": "~0.6.0",
4747
"libp2p-multiplex": "~0.5.0",
4848
"libp2p-secio": "~0.8.1",
4949
"libp2p-tcp": "~0.11.1",
@@ -52,7 +52,7 @@
5252
"ncp": "^2.0.0",
5353
"peer-book": "~0.5.1",
5454
"peer-id": "~0.10.2",
55-
"peer-info": "~0.11.0",
55+
"peer-info": "~0.11.1",
5656
"rimraf": "^2.6.2",
5757
"safe-buffer": "^5.1.1"
5858
},
@@ -73,7 +73,7 @@
7373
"multicodec": "~0.2.5",
7474
"multihashing-async": "~0.4.7",
7575
"protons": "^1.0.0",
76-
"pull-defer": "^0.2.2",
76+
"pull-defer": "~0.2.2",
7777
"pull-length-prefixed": "^1.3.0",
7878
"pull-pushable": "^2.1.1",
7979
"pull-stream": "^3.6.1",

test/bitswap-mock-internals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('bitswap with mocks', () => {
110110
})
111111

112112
it('multi peer', function (done) {
113-
this.timeout(40 * 1000)
113+
this.timeout(80 * 1000)
114114
const bs = new Bitswap(mockLibp2pNode(), repo.blocks)
115115

116116
let others

test/bitswap.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ describe('bitswap without DHT', function () {
9999
})
100100
})
101101

102-
describe('bitswap with DHT', () => {
102+
describe('bitswap with DHT', function () {
103+
this.timeout(20 * 1000)
104+
103105
let nodes
104106

105107
before((done) => {

test/fixtures/repo/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5
1+
6

test/utils/create-temp-repo-nodejs.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
'use strict'
22

33
const IPFSRepo = require('ipfs-repo')
4-
const path = require('path')
4+
const pathJoin = require('path').join
5+
const os = require('os')
56
const ncp = require('ncp')
67
const rimraf = require('rimraf')
8+
const series = require('async/series')
79

8-
const baseRepo = path.join(__dirname, '../fixtures/repo')
10+
const baseRepo = pathJoin(__dirname, '../fixtures/repo')
911

1012
function createTempRepo (callback) {
1113
const date = Date.now().toString()
12-
const path = `/tmp/bitswap-tests-${date}-${Math.random()}`
14+
const path = pathJoin(os.tmpdir(), `bitswap-tests-${date}-${Math.random()}`)
1315

1416
ncp(baseRepo, path, (err) => {
1517
if (err) { return callback(err) }
1618

1719
const repo = new IPFSRepo(path)
1820

19-
repo.teardown = (callback) => rimraf(path, callback)
21+
repo.teardown = (done) => {
22+
series([
23+
(cb) => repo.close(cb),
24+
(cb) => rimraf(path, cb)
25+
], (err) => done(err))
26+
}
2027

2128
repo.open((err) => {
2229
if (err) { return callback(err) }

test/utils/make-block.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ const multihashing = require('multihashing-async')
44
const CID = require('cids')
55
const Block = require('ipfs-block')
66
const Buffer = require('safe-buffer').Buffer
7+
const uuid = require('uuid/v4')
78

89
module.exports = (callback) => {
9-
const data = Buffer.from(`hello world ${Math.random()}`)
10+
const data = Buffer.from(`hello world ${uuid()}`)
1011

1112
multihashing(data, 'sha2-256', (err, hash) => {
1213
if (err) { return callback(err) }

test/wantmanager/index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('WantManager', () => {
6767
expect(m[0]).to.be.eql(calls.connects[i])
6868
if (!m[1].equals(msgs[i])) {
6969
return done(
70-
new Error(`expected ${m[1].toString()} to equal ${msgs[1].toString()}`)
70+
new Error(`expected ${m[1].toString()} to equal ${msgs[i].toString()}`)
7171
)
7272
}
7373
})

0 commit comments

Comments
 (0)