This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: the first pass of a big refactor of tests towards using only ip…
…fs-factory to spawn nodes (#750) * test: mega clean up to the tests * fix: but in starting api on port 0
- Loading branch information
Showing
113 changed files
with
845 additions
and
1,130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const runOn = require('../utils/on-and-off').on | ||
|
||
describe('bitswap', () => runOn((thing) => { | ||
let ipfs | ||
const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR' | ||
|
||
before((done) => { | ||
ipfs = thing.ipfs | ||
ipfs('block get ' + key) | ||
.then(() => {}) | ||
.catch(() => {}) | ||
setTimeout(done, 100) | ||
}) | ||
|
||
it('wantlist', () => { | ||
return ipfs('bitswap wantlist').then((out) => { | ||
expect(out).to.eql(key) | ||
}) | ||
}) | ||
|
||
it('stat', () => { | ||
return ipfs('bitswap stat').then((out) => { | ||
expect(out).to.be.eql([ | ||
'bitswap status', | ||
' blocks received: 0', | ||
' dup blocks received: 0', | ||
' dup data received: 0B', | ||
' wantlist [1 keys]', | ||
` ${key}`, | ||
' partners [0]', | ||
' ' | ||
].join('\n')) | ||
}) | ||
}) | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const runOnAndOff = require('../utils/on-and-off') | ||
|
||
describe('block', () => runOnAndOff((thing) => { | ||
let ipfs | ||
|
||
before(() => { | ||
ipfs = thing.ipfs | ||
}) | ||
|
||
it('put', () => { | ||
return ipfs('block put test/test-data/hello').then((out) => { | ||
expect(out).to.eql('zdj7Wgpi9yzsvjJerghrdhPFpe1p1jZFyB5GKLyXEzFQyaxVk') | ||
}) | ||
}) | ||
|
||
it('put with flags, format and mhtype', () => { | ||
return ipfs('block put --format eth-block --mhtype keccak-256 test/test-data/eth-block') | ||
.then((out) => expect(out).to.eql('z43AaGF23fmvRnDP56Ub9WcJCfzSfqtmzNCCvmz5eudT8dtdCDS')) | ||
}) | ||
|
||
it('get', () => { | ||
return ipfs('block get QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp') | ||
.then((out) => expect(out).to.eql('hello world\n')) | ||
}) | ||
|
||
it('stat', () => { | ||
return ipfs('block stat QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp') | ||
.then((out) => { | ||
expect(out).to.eql([ | ||
'Key: QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp', | ||
'Size: 12' | ||
].join('\n')) | ||
}) | ||
}) | ||
|
||
it.skip('rm', () => { | ||
return ipfs('block rm QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp') | ||
.then((out) => { | ||
expect(out).to.eql( | ||
'removed QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp' | ||
) | ||
}) | ||
}) | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* eslint max-nested-callbacks: ["error", 8] */ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const runOnAndOff = require('../utils/on-and-off') | ||
|
||
describe('bootstrap', () => runOnAndOff((thing) => { | ||
let ipfs | ||
|
||
before(() => { | ||
ipfs = thing.ipfs | ||
}) | ||
|
||
const defaultList = [ | ||
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ', | ||
'/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z', | ||
'/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM', | ||
'/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm', | ||
'/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu', | ||
'/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64', | ||
'/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd', | ||
'/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3', | ||
'/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx' | ||
] | ||
|
||
const updatedList = [ | ||
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ', | ||
'/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z', | ||
'/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM', | ||
'/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm', | ||
'/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu', | ||
'/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64', | ||
'/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd', | ||
'/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3', | ||
'/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx', | ||
'/ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD' | ||
] | ||
|
||
it('add default', () => { | ||
return ipfs('bootstrap add --default').then((out) => { | ||
expect(out).to.be.eql(defaultList.join('\n')) | ||
}) | ||
}) | ||
|
||
it('list the bootstrap nodes', () => { | ||
return ipfs('bootstrap list').then((out) => { | ||
expect(out).to.eql(defaultList.join('\n')) | ||
}) | ||
}) | ||
|
||
it('add another bootstrap node', () => { | ||
return ipfs('bootstrap add /ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD').then((out) => { | ||
expect(out).to.be.eql('/ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD') | ||
return ipfs('bootstrap list') | ||
}).then((out) => { | ||
expect(out).to.be.eql(updatedList.join('\n')) | ||
}) | ||
}) | ||
|
||
it('rm a bootstrap node', () => { | ||
return ipfs('bootstrap rm /ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD').then((out) => { | ||
expect(out).to.be.eql('/ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD') | ||
return ipfs('bootstrap list') | ||
}).then((out) => { | ||
expect(out).to.deep.equal(defaultList.join('\n')) | ||
}) | ||
}) | ||
|
||
it('rm all bootstrap nodes', () => { | ||
return ipfs('bootstrap rm --all').then((out) => { | ||
expect(out).to.be.eql('') | ||
return ipfs('bootstrap list') | ||
}).then((out) => { | ||
expect(out).to.deep.equal('') | ||
}) | ||
}) | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const repoPath = require('./index').repoPath | ||
const ipfsBase = require('../utils/ipfs-exec') | ||
const runOnAndOff = require('../utils/on-and-off') | ||
|
||
const commandCount = 61 | ||
|
||
describe('commands', () => runOnAndOff((thing) => { | ||
let ipfs | ||
|
||
before(() => { | ||
ipfs = thing.ipfs | ||
}) | ||
|
||
it('list the commands', () => { | ||
return ipfs('commands').then((out) => { | ||
expect(out.split('\n')).to.have.length(commandCount) | ||
}) | ||
}) | ||
})) |
Oops, something went wrong.