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

Commit

Permalink
chore: update deps, allow tests to run offline
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Oct 20, 2022
1 parent 93736ef commit c254552
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"aegir": "^37.0.11",
"blockstore-core": "^2.0.1",
"copyfiles": "^2.4.1",
"dag-jose": "^3.0.0",
"dag-jose": "^3.0.1",
"delay": "^5.0.0",
"did-jwt": "^6.2.0",
"err-code": "^3.0.1",
Expand Down
30 changes: 27 additions & 3 deletions packages/interface-ipfs-core/src/miscellaneous/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ export function testDns (factory, options) {
after(() => factory.clean())

it('should non-recursively resolve ipfs.io', async function () {
const domain = 'ipfs.io'

try {
const res = await ipfs.dns('ipfs.io', { recursive: false })
const res = await ipfs.dns(domain, { recursive: false })

// matches pattern /ipns/<ipnsaddress>
expect(res).to.match(/\/ipns\/.+$/)
Expand All @@ -40,13 +42,21 @@ export function testDns (factory, options) {
return this.skip()
}

// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

throw err
}
})

it('should recursively resolve ipfs.io', async function () {
const domain = 'ipfs.io'

try {
const res = await ipfs.dns('ipfs.io', { recursive: true })
const res = await ipfs.dns(domain, { recursive: true })

// matches pattern /ipfs/<hash>
expect(res).to.match(/\/ipfs\/.+$/)
Expand All @@ -56,13 +66,21 @@ export function testDns (factory, options) {
return this.skip()
}

// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

throw err
}
})

it('should resolve subdomain docs.ipfs.io', async function () {
const domain = 'docs.ipfs.io'

try {
const res = await ipfs.dns('docs.ipfs.io')
const res = await ipfs.dns(domain)

// matches pattern /ipfs/<hash>
expect(res).to.match(/\/ipfs\/.+$/)
Expand All @@ -72,6 +90,12 @@ export function testDns (factory, options) {
return this.skip()
}

// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

throw err
}
})
Expand Down
16 changes: 14 additions & 2 deletions packages/interface-ipfs-core/src/miscellaneous/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,21 @@ export function testResolve (factory, options) {
it('should resolve an IPNS DNS link', async function () {
// @ts-expect-error this is mocha
this.retries(3)
const resolved = await ipfs.resolve('/ipns/ipfs.io')
const domain = 'ipfs.io'

expect(isIpfs.ipfsPath(resolved)).to.be.true()
try {
const resolved = await ipfs.resolve(`/ipns/${domain}`)

expect(isIpfs.ipfsPath(resolved)).to.be.true()
} catch (/** @type {any} */ err) {
// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

throw err
}
})

it('should resolve IPNS link recursively by default', async function () {
Expand Down
126 changes: 105 additions & 21 deletions packages/interface-ipfs-core/src/name/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,34 +160,106 @@ export function testResolve (factory, options) {

after(() => factory.clean())

it('should resolve /ipns/ipfs.io', async () => {
expect(await last(ipfs.name.resolve('/ipns/ipfs.io')))
.to.match(/\/ipfs\/.+$/)
it('should resolve /ipns/ipfs.io', async function () {
const domain = 'ipfs.io'

try {
expect(await last(ipfs.name.resolve(`/ipns/${domain}`)))
.to.match(/\/ipfs\/.+$/)
} catch (/** @type {any} */ err) {
// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

throw err
}
})

it('should resolve /ipns/ipfs.io recursive === false', async () => {
expect(await last(ipfs.name.resolve('/ipns/ipfs.io', { recursive: false })))
.to.match(/\/ipns\/.+$/)
it('should resolve /ipns/ipfs.io recursive === false', async function () {
const domain = 'ipfs.io'

try {
expect(await last(ipfs.name.resolve(`/ipns/${domain}`, { recursive: false })))
.to.match(/\/ipns\/.+$/)
} catch (/** @type {any} */ err) {
// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

throw err
}
})

it('should resolve /ipns/ipfs.io recursive === true', async () => {
expect(await last(ipfs.name.resolve('/ipns/ipfs.io', { recursive: true })))
.to.match(/\/ipfs\/.+$/)
it('should resolve /ipns/ipfs.io recursive === true', async function () {
const domain = 'ipfs.io'

try {
expect(await last(ipfs.name.resolve(`/ipns/${domain}`, { recursive: true })))
.to.match(/\/ipfs\/.+$/)
} catch (/** @type {any} */ err) {
// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

throw err
}
})

it('should resolve /ipns/ipfs.io with remainder', async () => {
expect(await last(ipfs.name.resolve('/ipns/ipfs.io/images/ipfs-logo.svg')))
.to.match(/\/ipfs\/.+\/images\/ipfs-logo.svg$/)
it('should resolve /ipns/ipfs.io with remainder', async function () {
const domain = 'ipfs.io'

try {
expect(await last(ipfs.name.resolve(`/ipns/${domain}/images/ipfs-logo.svg`)))
.to.match(/\/ipfs\/.+\/images\/ipfs-logo.svg$/)
} catch (/** @type {any} */ err) {
// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

throw err
}
})

it('should resolve /ipns/ipfs.io with remainder recursive === false', async () => {
expect(await last(ipfs.name.resolve('/ipns/ipfs.io/images/ipfs-logo.svg', { recursive: false })))
.to.match(/\/ipns\/.+\/images\/ipfs-logo.svg$/)
it('should resolve /ipns/ipfs.io with remainder recursive === false', async function () {
const domain = 'ipfs.io'

try {
expect(await last(ipfs.name.resolve(`/ipns/${domain}/images/ipfs-logo.svg`, { recursive: false })))
.to.match(/\/ipns\/.+\/images\/ipfs-logo.svg$/)
} catch (/** @type {any} */ err) {
// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

throw err
}
})

it('should resolve /ipns/ipfs.io with remainder recursive === true', async () => {
expect(await last(ipfs.name.resolve('/ipns/ipfs.io/images/ipfs-logo.svg', { recursive: true })))
.to.match(/\/ipfs\/.+\/images\/ipfs-logo.svg$/)
it('should resolve /ipns/ipfs.io with remainder recursive === true', async function () {
const domain = 'ipfs.io'

try {
expect(await last(ipfs.name.resolve(`/ipns/${domain}/images/ipfs-logo.svg`, { recursive: true })))
.to.match(/\/ipfs\/.+\/images\/ipfs-logo.svg$/)
} catch (/** @type {any} */ err) {
// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

throw err
}
})

it('should fail to resolve /ipns/ipfs.a', async () => {
Expand All @@ -198,9 +270,21 @@ export function testResolve (factory, options) {
}
})

it('should resolve ipns path with hamt-shard recursive === true', async () => {
expect(await last(ipfs.name.resolve('/ipns/tr.wikipedia-on-ipfs.org/wiki/Anasayfa.html', { recursive: true })))
.to.match(/\/ipfs\/.+$/)
it('should resolve ipns path with hamt-shard recursive === true', async function () {
const domain = 'tr.wikipedia-on-ipfs.org'

try {
expect(await last(ipfs.name.resolve(`/ipns/${domain}/wiki/Anasayfa.html`, { recursive: true })))
.to.match(/\/ipfs\/.+$/)
} catch (/** @type {any} */ err) {
// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

throw err
}
})
})
}
2 changes: 1 addition & 1 deletion packages/ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"any-signal": "^3.0.0",
"array-shuffle": "^3.0.0",
"blockstore-core": "^2.0.1",
"dag-jose": "^3.0.0",
"dag-jose": "^3.0.1",
"datastore-core": "^8.0.1",
"datastore-pubsub": "^6.0.0",
"dlv": "^1.1.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@libp2p/peer-id": "^1.1.10",
"@multiformats/multiaddr": "^11.0.0",
"any-signal": "^3.0.0",
"dag-jose": "^3.0.0",
"dag-jose": "^3.0.1",
"err-code": "^3.0.1",
"ipfs-core-types": "^0.12.1",
"ipfs-core-utils": "^0.16.1",
Expand Down
1 change: 1 addition & 0 deletions packages/ipfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"ipfs-utils": "^9.0.6",
"ipfsd-ctl": "^12.0.3",
"iso-url": "^1.0.0",
"kubo-rpc-client": "^1.0.1",
"merge-options": "^3.0.4",
"mock-ipfs-pinning-service": "^0.4.2",
"url": "^0.11.0",
Expand Down

0 comments on commit c254552

Please sign in to comment.