Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

fix: fix electron renderer tests and a couple more bugs #1105

Merged
merged 49 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2278822
fix: enable a bunch of tests in the browser
hugomrdias Sep 13, 2019
87d444e
fix: Blob can accept Buffer directly
hugomrdias Sep 13, 2019
080b4b9
fix: temp fix for electron renderer until ky-universal is fixed
hugomrdias Sep 13, 2019
000e00c
chore: use interface-core branch with fixes
hugomrdias Sep 13, 2019
d518683
chore: update interface-core
hugomrdias Sep 13, 2019
ee5fd82
chore: fix typo
hugomrdias Sep 13, 2019
05e4bba
fix: try to fix ci
hugomrdias Sep 13, 2019
d0b77c3
chore: testing timing for wantlist tests
hugomrdias Sep 13, 2019
9966025
chore: run everything in ci
hugomrdias Sep 13, 2019
61c5917
chore: test travis
hugomrdias Sep 13, 2019
02c4450
chore: remove travis cache
hugomrdias Sep 13, 2019
a8d820e
chore: disable more stuff
hugomrdias Sep 13, 2019
4106720
chore: disable more stuff 2
hugomrdias Sep 13, 2019
a289ab4
chore: test travis 2
hugomrdias Sep 13, 2019
dd977ad
chore: test travis 3
hugomrdias Sep 13, 2019
2b707bf
chore: test travis 4
hugomrdias Sep 13, 2019
4f571f6
chore: test travis 5
hugomrdias Sep 13, 2019
9b8e60f
fix: update deps
hugomrdias Sep 13, 2019
c97508c
fix: revert
hugomrdias Sep 13, 2019
276092b
fix: travis again
hugomrdias Sep 13, 2019
2e6555c
fix: travis again 2
hugomrdias Sep 13, 2019
792800b
fix: enable more test
hugomrdias Sep 15, 2019
ece1171
fix: debug
hugomrdias Sep 15, 2019
0e7140d
fix: enable more tests
hugomrdias Sep 15, 2019
4e6440b
fix: dup
hugomrdias Sep 15, 2019
dd9c57a
fix: just 3
hugomrdias Sep 15, 2019
878ff3e
fix: just 3
hugomrdias Sep 15, 2019
2c8c0ca
chore: debug stop
hugomrdias Sep 15, 2019
3b9bf02
chore: enable more
hugomrdias Sep 15, 2019
f5a9bb6
chore: remove clg
hugomrdias Sep 15, 2019
858453b
chore: dag
hugomrdias Sep 15, 2019
4074307
chore: add more
hugomrdias Sep 15, 2019
948b8f8
chore: only swarm
hugomrdias Sep 15, 2019
72907ac
chore: new setup
hugomrdias Sep 15, 2019
795eabf
chore: fix dep
hugomrdias Sep 15, 2019
8628516
chore: debug
hugomrdias Sep 15, 2019
ae5150a
fix: support create options
hugomrdias Sep 15, 2019
07e0269
chore: increade timeout
hugomrdias Sep 15, 2019
0b4f917
chore: increade timeout 2
hugomrdias Sep 15, 2019
f1a719d
chore: change aegir
hugomrdias Sep 15, 2019
73389c0
chore: change os
hugomrdias Sep 15, 2019
92d74ed
chore: test all
hugomrdias Sep 15, 2019
0ab555d
chore: change os for main
hugomrdias Sep 15, 2019
0504d11
chore: remove xvfb
hugomrdias Sep 15, 2019
8362a60
chore: fix fn name
hugomrdias Sep 15, 2019
966e142
chore: delete comments
hugomrdias Sep 15, 2019
30bbaa4
chore: upgrade aegir
hugomrdias Sep 16, 2019
8819e6c
chore: update interface-core
hugomrdias Sep 16, 2019
651d0d9
chore: add link to upstream ky fix
hugomrdias Sep 16, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
'use strict'

const promisify = require('promisify-es6')
const createServer = require('ipfsd-ctl').createServer

const EchoServer = require('interface-ipfs-core/src/utils/echo-http-server')
const server = createServer()
const echoServer = EchoServer.createServer()

const echoServeStart = promisify(echoServer.start)
achingbrain marked this conversation as resolved.
Show resolved Hide resolved
const echoServeStop = promisify(echoServer.stop)
module.exports = {
bundlesize: { maxSize: '245kB' },
webpack: {
Expand All @@ -22,9 +26,24 @@ module.exports = {
singleRun: true
},
hooks: {
node: {
pre: () => echoServeStart(),
post: () => echoServeStop()
},
browser: {
pre: () => server.start(),
post: () => server.stop()
pre: () => {
return Promise.all([
server.start(),
echoServeStart()

])
},
post: () => {
return Promise.all([
server.stop(),
echoServeStop()
])
}
}
}
}
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ script: npx nyc -s npm run test:node -- --bail
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov

jobs:
allow_failures:
- name: electron-renderer

fast_finish: true

include:
- stage: check
script:
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@
"through2": "^3.0.1"
},
"devDependencies": {
"aegir": "^20.0.0",
"aegir": "^20.1.0",
"browser-process-platform": "~0.1.1",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"cross-env": "^5.2.0",
"cross-env": "^5.2.1",
"dirty-chai": "^2.0.1",
"go-ipfs-dep": "^0.4.22",
"interface-ipfs-core": "^0.112.0",
"ipfsd-ctl": "~0.45.0",
"interface-ipfs-core": "^0.113.1",
"ipfsd-ctl": "~0.46.1",
"nock": "^11.3.2",
"stream-equal": "^1.1.1"
},
Expand Down
7 changes: 3 additions & 4 deletions src/add/form-data.browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'
/* eslint-env browser */

const { Buffer } = require('buffer')
const normaliseInput = require('ipfs-utils/src/files/normalise-input')

exports.toFormData = async input => {
Expand All @@ -16,12 +15,12 @@ exports.toFormData = async input => {
// One day, this will be browser streams
const bufs = []
for await (const chunk of file.content) {
bufs.push(Buffer.isBuffer(chunk) ? chunk.buffer : chunk)
bufs.push(chunk)
}

formData.append(`file-${i}`, new Blob(bufs, { type: 'application/octet-stream' }), file.path)
formData.append(`file-${i}`, new Blob(bufs, { type: 'application/octet-stream' }), encodeURIComponent(file.path))
} else {
formData.append(`dir-${i}`, new Blob([], { type: 'application/x-directory' }), file.path)
formData.append(`dir-${i}`, new Blob([], { type: 'application/x-directory' }), encodeURIComponent(file.path))
}

i++
Expand Down
7 changes: 7 additions & 0 deletions src/add/form-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const FormData = require('form-data')
const { Buffer } = require('buffer')
const toStream = require('it-to-stream')
const normaliseInput = require('ipfs-utils/src/files/normalise-input')
const { isElectronRenderer } = require('ipfs-utils/src/env')

exports.toFormData = async input => {
const files = normaliseInput(input)
Expand Down Expand Up @@ -40,3 +41,9 @@ exports.toFormData = async input => {

return formData
}

// TODO remove this when upstream fix for ky-universal is merged
hugomrdias marked this conversation as resolved.
Show resolved Hide resolved
// also this should only be necessary when nodeIntegration is false in electron renderer
if (isElectronRenderer) {
exports.toFormData = require('./form-data.browser').toFormData
}
14 changes: 3 additions & 11 deletions test/get.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const chaiAsPromised = require('chai-as-promised')
const expect = chai.expect
chai.use(dirtyChai)
chai.use(chaiAsPromised)
const isNode = require('detect-node')
const loadFixture = require('aegir/fixtures')

const ipfsClient = require('../src')
Expand Down Expand Up @@ -75,26 +74,19 @@ describe('.get (specific go-ipfs features)', function () {
})

it('add path containing "+"s (for testing get)', async () => {
if (!isNode) {
return
}

const filename = 'ti,c64x+mega++mod-pic.txt'
const subdir = 'tmp/c++files'
const expectedCid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff'
const path = `${subdir}/${filename}`
const files = await ipfs.add([{
path: subdir + '/' + filename,
content: Buffer.from(subdir + '/' + filename, 'utf-8')
path,
content: Buffer.from(path)
}])

expect(files[2].hash).to.equal(expectedCid)
})

it('get path containing "+"s', async () => {
if (!isNode) {
return
}

const cid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff'
let count = 0
const files = await ipfs.get(cid)
Expand Down
88 changes: 39 additions & 49 deletions test/interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,40 +102,30 @@ describe('interface-ipfs-core tests', () => {

tests.filesRegular(defaultCommonFactory, {
skip: [
// .add
isNode ? null : {
name: 'should add a nested directory as array of tupples',
reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
},
isNode ? null : {
name: 'should add a nested directory as array of tupples with progress',
reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
},
// .addPullStream
isNode ? null : {
name: 'should add pull stream of valid files and dirs',
reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
},
// .addReadableStream
isNode ? null : {
name: 'should add readable stream of valid files and dirs',
reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
},
// // .add
// isNode ? null : {
// name: 'should add a nested directory as array of tupples',
// reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
// },
// isNode ? null : {
// name: 'should add a nested directory as array of tupples with progress',
// reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
// },
// // .addPullStream
// isNode ? null : {
// name: 'should add pull stream of valid files and dirs',
// reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
// },
// // .addReadableStream
// isNode ? null : {
// name: 'should add readable stream of valid files and dirs',
// reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
// },
hugomrdias marked this conversation as resolved.
Show resolved Hide resolved
// .addFromFs
isNode ? null : {
name: 'addFromFs',
reason: 'Not designed to run in the browser'
},
// .addFromURL
isNode ? null : {
name: 'addFromURL',
reason: 'Not designed to run in the browser'
},
// TODO: remove when interface-ipfs-core updated
isNode ? null : {
name: 'addFromUrl',
reason: 'Not designed to run in the browser'
},
// .catPullStream
{
name: 'should export a chunk of a file',
Expand All @@ -148,27 +138,27 @@ describe('interface-ipfs-core tests', () => {
{
name: 'should export a chunk of a file in a Readable Stream',
reason: 'TODO not implemented in go-ipfs yet'
},
// .get
isNode ? null : {
name: 'should get a directory',
reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
},
// .ls
isNode ? null : {
name: 'should ls with a base58 encoded CID',
reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
},
// .lsPullStream
isNode ? null : {
name: 'should pull stream ls with a base58 encoded CID',
reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
},
// .lsReadableStream
isNode ? null : {
name: 'should readable stream ls with a base58 encoded CID',
reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
}
// // .get
// isNode ? null : {
// name: 'should get a directory',
// reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
// },
// // .ls
// isNode ? null : {
// name: 'should ls with a base58 encoded CID',
// reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
// },
// // .lsPullStream
// isNode ? null : {
// name: 'should pull stream ls with a base58 encoded CID',
// reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
// },
// // .lsReadableStream
// isNode ? null : {
// name: 'should readable stream ls with a base58 encoded CID',
// reason: 'FIXME https://github.com/ipfs/js-ipfs-http-client/issues/339'
// }
hugomrdias marked this conversation as resolved.
Show resolved Hide resolved
]
})

Expand Down