Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

dedupe tests #2669

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/cli/commands/add.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable complexity */
'use strict'

const promisify = require('promisify-es6')
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {

return new Promise((resolve, reject) => {
const peerId = argv.peerId
const count = argv.count || 10
const count = argv.count
pull(
ipfs.pingPullStream(peerId, { count }),
pull.drain(({ success, time, text }) => {
Expand Down
47 changes: 1 addition & 46 deletions test/cli/bitswap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

const { expect } = require('interface-ipfs-core/src/utils/mocha')
const runOn = require('../utils/on-and-off').on
const PeerId = require('peer-id')
const CID = require('cids')
const waitFor = require('../utils/wait-for')

describe('bitswap', () => runOn((thing) => {
let ipfs
let peerId
const key0 = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR'
const key1 = 'zb2rhafnd6kEUujnoMkozHnWXY7XpWttyVDWKXfChqA42VTDU'

Expand All @@ -22,14 +20,6 @@ describe('bitswap', () => runOn((thing) => {
ipfs('block get ' + key1).catch(() => {})
})

before(function (done) {
PeerId.create({ bits: 512 }, (err, peer) => {
expect(err).to.not.exist()
peerId = peer.toB58String()
done()
})
})

before(async () => {
const test = async () => {
const out = await ipfs('bitswap wantlist')
Expand All @@ -43,45 +33,13 @@ describe('bitswap', () => runOn((thing) => {
})
})

it('wantlist', async function () {
const out = await ipfs('bitswap wantlist')
expect(out).to.include(key0)
expect(out).to.include(key1)
})

it('should get wantlist with CIDs encoded in specified base', async function () {
this.timeout(20 * 1000)

const out = await ipfs('bitswap wantlist --cid-base=base64')
expect(out).to.include(new CID(key1).toBaseEncodedString('base64') + '\n')
})

it('wantlist peerid', async function () {
this.timeout(20 * 1000)

const out = await ipfs('bitswap wantlist ' + peerId)
expect(out).to.eql('')
})

it('stat', async function () {
this.timeout(20 * 1000)

const out = await ipfs('bitswap stat')

expect(out).to.include('bitswap status')
expect(out).to.match(/provides buffer:\s\d+$/m)
expect(out).to.match(/blocks received:\s\d+$/m)
expect(out).to.match(/blocks sent:\s\d+$/m)
expect(out).to.match(/data received:\s\d+$/m)
expect(out).to.match(/data sent:\s\d+$/m)
expect(out).to.match(/dup blocks received:\s\d+$/m)
expect(out).to.match(/dup data received:\s\d+$/m)
expect(out).to.match(/wantlist\s\[\d+\skeys\]$/m)
expect(out).to.include(key0)
expect(out).to.include(key1)
expect(out).to.match(/partners\s\[\d+\]$/m)
})

it('stat --human', async function () {
this.timeout(20 * 1000)

Expand All @@ -108,8 +66,5 @@ describe('bitswap', () => runOn((thing) => {
expect(out).to.include(new CID(key1).toBaseEncodedString('base64'))
})

it('unwant', async function () {
const out = await ipfs('bitswap unwant ' + key0)
expect(out).to.eql(`Key ${key0} removed from wantlist\n`)
})
// TODO: missing unwant with cid-base arg
Copy link
Member

@achingbrain achingbrain Dec 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are quite a lot of TODOs being added here - how will they be resolved? By adding tests to these suites or the interface tests?

Copy link
Member Author

@hugomrdias hugomrdias Dec 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything related to cli logic will be added to js-ipfs cli suite, everything that needed to be extracted to interface-core is already ipfs-inactive/interface-js-ipfs-core#573.

The comments may refer to new tests that need to be added by the follow up PRs but this is only related to the CLI tests.

}))
33 changes: 1 addition & 32 deletions test/cli/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ describe('block', () => runOnAndOff((thing) => {
ipfs = thing.ipfs
})

it('put', async function () {
this.timeout(40 * 1000)

const out = await ipfs('block put test/fixtures/test-data/hello')
expect(out).to.eql('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp\n')
})

it('put with flags, format and mhtype', async function () {
this.timeout(40 * 1000)

Expand All @@ -32,13 +25,6 @@ describe('block', () => runOnAndOff((thing) => {
expect(out).to.eql('mAXASIKlIkE8vD0ebj4GXaUswGEsNLtHBzSoewPuF0pmhkqRH\n')
})

it('get', async function () {
this.timeout(40 * 1000)

const out = await ipfs('block get QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp')
expect(out).to.eql('hello world\n')
})

it('get block from file without a final newline', async function () {
this.timeout(40 * 1000)

Expand All @@ -49,15 +35,7 @@ describe('block', () => runOnAndOff((thing) => {
expect(out2).to.eql('there is no newline at end of this file')
})

it('stat', async function () {
this.timeout(40 * 1000)

const out = await ipfs('block stat QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp')
expect(out).to.eql([
'Key: QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp',
'Size: 12'
].join('\n') + '\n')
})
// TODO: missing block.get error test when block is undefined

it('should stat and print CID encoded in specified base', async function () {
this.timeout(80 * 1000)
Expand All @@ -72,15 +50,6 @@ describe('block', () => runOnAndOff((thing) => {
].join('\n') + '\n')
})

it('rm', async function () {
this.timeout(40 * 1000)

await ipfs('block put test/fixtures/test-data/hello')

const out = await ipfs('block rm QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp')
expect(out).to.eql('removed QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp\n')
})

it('rm quietly', async function () {
this.timeout(40 * 1000)

Expand Down
79 changes: 0 additions & 79 deletions test/cli/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,85 +12,6 @@ describe('bootstrap', () => runOnAndOff((thing) => {
ipfs = thing.ipfs
})

const defaultList = [
'/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z',
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
'/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',
'/ip6/2604:a880:1:20::1f9:9001/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z',
'/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM',
'/ip6/2604:a880:0:1010::23:d001/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm',
'/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu',
'/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
'/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd',
'/ip6/2a03:b0c0:1:d0::e7:1/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3',
'/ip6/2604:a880:1:20::1d9:6001/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx',
'/dns4/node0.preload.ipfs.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic',
'/dns4/node1.preload.ipfs.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6'
]

const updatedList = [
'/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z',
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
'/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',
'/ip6/2604:a880:1:20::1f9:9001/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z',
'/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM',
'/ip6/2604:a880:0:1010::23:d001/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm',
'/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu',
'/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
'/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd',
'/ip6/2a03:b0c0:1:d0::e7:1/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3',
'/ip6/2604:a880:1:20::1d9:6001/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx',
'/dns4/node0.preload.ipfs.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic',
'/dns4/node1.preload.ipfs.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6',
'/ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD'
]

it('add default', async function () {
this.timeout(40 * 1000)

const out = await ipfs('bootstrap add --default')
expect(out).to.equal(defaultList.join('\n') + '\n')
})

it('list the bootstrap nodes', async function () {
this.timeout(40 * 1000)

const out = await ipfs('bootstrap list')
expect(out).to.equal(defaultList.join('\n') + '\n')
})

it('add another bootstrap node', async function () {
this.timeout(40 * 1000)

const out = await ipfs('bootstrap add /ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD')
expect(out).to.equal('/ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD\n')

const out2 = await ipfs('bootstrap list')
expect(out2).to.equal(updatedList.join('\n') + '\n')
})

it('rm a bootstrap node', async function () {
this.timeout(40 * 1000)

const out = await ipfs('bootstrap rm /ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD')
expect(out).to.equal('/ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD\n')

const out2 = await ipfs('bootstrap list')
expect(out2).to.equal(defaultList.join('\n') + '\n')
})

it('rm all bootstrap nodes', async function () {
this.timeout(40 * 1000)

Expand Down
6 changes: 2 additions & 4 deletions test/cli/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ describe('config', () => runOnAndOff((thing) => {
describe('show', function () {
this.timeout(40 * 1000)

it('returns the full config', async () => {
const out = await ipfs('config show')
expect(JSON.parse(out)).to.be.eql(updatedConfig())
})
// TODO test json output format
})

// TODO unskip this test
describe.skip('replace', () => {
it('replace config with file', async () => {
const filePath = 'test/fixtures/test-data/otherconfig'
Expand Down
12 changes: 5 additions & 7 deletions test/cli/dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ describe('dag', () => runOnAndOff.off((thing) => {
})

describe('get', () => {
// TODO test local-resolve
// TODO output format
// TODO err output format
it('get', async function () {
this.timeout(20 * 1000)

Expand All @@ -36,19 +39,14 @@ describe('dag', () => runOnAndOff.off((thing) => {
})

describe('resolve', () => {
// TODO test err output format
// TODO test empty lastCid logic
it('resolve cid', async function () {
this.timeout(20 * 1000)

const out = await ipfs('dag resolve Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z')
expect(out).to.equal('Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z\n')
})

it('resolve sub directory', async function () {
this.timeout(20 * 1000)

const out = await ipfs('dag resolve Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/init-docs/tour/0.0-intro')
expect(out).to.equal('QmYE7xo6NxbHEVEHej1yzxijYaNY51BaeKxjXxn6Ssa6Bs\n')
})
})

describe('put', () => {
Expand Down
49 changes: 5 additions & 44 deletions test/cli/dns.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,17 @@
/* eslint-env mocha */
'use strict'

const { expect } = require('interface-ipfs-core/src/utils/mocha')
// const { expect } = require('interface-ipfs-core/src/utils/mocha')
const runOnAndOff = require('../utils/on-and-off')
const isIPFS = require('is-ipfs')
// const isIPFS = require('is-ipfs')

describe('dns', () => runOnAndOff((thing) => {
let ipfs
// let ipfs

before(function () {
this.timeout(60 * 1000)
ipfs = thing.ipfs
// ipfs = thing.ipfs
})

it('recursively resolve ipfs.io dns', async function () {
this.timeout(60 * 1000)

const res = await ipfs('dns ipfs.io')
expect(res.substr(0, 6)).to.eql('/ipfs/')
const resultingDomainOrCid = res.split('/')[2].trim()
expect(isIPFS.cid(resultingDomainOrCid)).to.eql(true)
})

it('recursively resolve _dnslink.ipfs.io dns', async function () {
this.timeout(60 * 1000)

const res = await ipfs('dns _dnslink.ipfs.io')
expect(res.substr(0, 6)).to.eql('/ipfs/')
const resultingDomainOrCid = res.split('/')[2].trim()
expect(isIPFS.cid(resultingDomainOrCid)).to.eql(true)
})

it('non-recursive resolve ipfs.io', async function () {
this.timeout(60 * 1000)

const res = await ipfs('dns --recursive false ipfs.io')
expect(res.substr(0, 6)).to.eql('/ipns/')
const resultingDomainOrCid = res.split('/')[2].trim()
expect(isIPFS.cid(resultingDomainOrCid)).to.eql(false)
})

it('resolve subdomain docs.ipfs.io dns', async function () {
this.timeout(60 * 1000)

const res = await ipfs('dns docs.ipfs.io')
expect(res.substr(0, 6)).to.eql('/ipfs/')
})

it('resolve subdomain _dnslink.docs.ipfs.io dns', async function () {
this.timeout(60 * 1000)

const res = await ipfs('dns _dnslink.docs.ipfs.io')
expect(res.substr(0, 6)).to.eql('/ipfs/')
})
// TODO add smoke test plus maybe errors just to make sure this works
}))
38 changes: 0 additions & 38 deletions test/cli/file.js

This file was deleted.

Loading