mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
119 lines
3.9 KiB
JavaScript
119 lines
3.9 KiB
JavaScript
// import assert from 'assert'
|
|
// import rmrf from 'rimraf'
|
|
// import OrbitDB from '../src/OrbitDB.js'
|
|
// import OrbitDBAddress from '../src/orbit-db-address.js'
|
|
// import {
|
|
// config,
|
|
// startIpfs,
|
|
// stopIpfs,
|
|
// testAPIs
|
|
// } from 'orbit-db-test-utils'
|
|
|
|
// const dbPath = './orbitdb/tests/orbit-db-address'
|
|
|
|
// Object.keys(testAPIs).forEach(API => {
|
|
// describe(`orbit-db - OrbitDB Address (${API})`, function() {
|
|
// this.timeout(config.timeout)
|
|
|
|
// let ipfsd, ipfs, orbitdb
|
|
|
|
// before(async () => {
|
|
// rmrf.sync(dbPath)
|
|
// ipfsd = await startIpfs(API, config.daemon1)
|
|
// ipfs = ipfsd.api
|
|
// orbitdb = await OrbitDB.createInstance(ipfs, { directory: dbPath })
|
|
// })
|
|
|
|
// after(async () => {
|
|
// if(orbitdb)
|
|
// await orbitdb.stop()
|
|
|
|
// if (ipfsd)
|
|
// await stopIpfs(ipfsd)
|
|
// })
|
|
|
|
// describe('Parse Address', () => {
|
|
// it('throws an error if address is empty', () => {
|
|
// let err
|
|
// try {
|
|
// const result = OrbitDB.parseAddress('')
|
|
// } catch (e) {
|
|
// err = e.toString()
|
|
// }
|
|
// assert.equal(err, 'Error: Not a valid OrbitDB address: ')
|
|
// })
|
|
|
|
// it('parse address successfully', () => {
|
|
// const address = '/orbitdb/zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13/first-database'
|
|
// const result = OrbitDB.parseAddress(address)
|
|
|
|
// const isInstanceOf = result instanceof OrbitDBAddress
|
|
// assert.equal(isInstanceOf, true)
|
|
|
|
// assert.equal(result.root, 'zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13')
|
|
// assert.equal(result.path, 'first-database')
|
|
|
|
// assert.equal(result.toString().indexOf('/orbitdb'), 0)
|
|
// assert.equal(result.toString().indexOf('zd'), 9)
|
|
// })
|
|
|
|
// it('parse address with backslashes (win32) successfully', () => {
|
|
// const address = '\\orbitdb\\Qmdgwt7w4uBsw8LXduzCd18zfGXeTmBsiR8edQ1hSfzcJC\\first-database'
|
|
// const result = OrbitDB.parseAddress(address)
|
|
|
|
// const isInstanceOf = result instanceof OrbitDBAddress
|
|
// assert.equal(isInstanceOf, true)
|
|
|
|
// assert.equal(result.root, 'Qmdgwt7w4uBsw8LXduzCd18zfGXeTmBsiR8edQ1hSfzcJC')
|
|
// assert.equal(result.path, 'first-database')
|
|
|
|
// assert.equal(result.toString().indexOf('/orbitdb'), 0)
|
|
// assert.equal(result.toString().indexOf('Qm'), 9)
|
|
// })
|
|
// })
|
|
|
|
// describe('isValid Address', () => {
|
|
// it('returns false for empty string', () => {
|
|
// const result = OrbitDB.isValidAddress('')
|
|
// assert.equal(result, false)
|
|
// })
|
|
|
|
// it('validate address successfully', () => {
|
|
// const address = '/orbitdb/zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13/first-database'
|
|
// const result = OrbitDB.isValidAddress(address)
|
|
|
|
// assert.equal(result, true)
|
|
// })
|
|
|
|
// it('handle missing orbitdb prefix', () => {
|
|
// const address = 'zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13/first-database'
|
|
// const result = OrbitDB.isValidAddress(address)
|
|
|
|
// assert.equal(result, true)
|
|
// })
|
|
|
|
// it('handle missing db address name', () => {
|
|
// const address = '/orbitdb/zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13'
|
|
// const result = OrbitDB.isValidAddress(address)
|
|
|
|
// assert.equal(result, true)
|
|
// })
|
|
|
|
// it('handle invalid multihash', () => {
|
|
// const address = '/orbitdb/Qmdgwt7w4uBsw8LXduzCd18zfGXeTmBsiR8edQ1hSfzc/first-database'
|
|
// const result = OrbitDB.isValidAddress(address)
|
|
|
|
// assert.equal(result, false)
|
|
// })
|
|
|
|
// it('validate address with backslashes (win32) successfully', () => {
|
|
// const address = '\\orbitdb\\Qmdgwt7w4uBsw8LXduzCd18zfGXeTmBsiR8edQ1hSfzcJC\\first-database'
|
|
// const result = OrbitDB.isValidAddress(address)
|
|
|
|
// assert.equal(result, true)
|
|
// })
|
|
// })
|
|
|
|
// })
|
|
// })
|