Merge pull request #1050 from orbitdb/fix/update-to-latest-ipfs

Update to latest ipfs
This commit is contained in:
Haad 2023-01-17 10:38:02 +02:00 committed by GitHub
commit ee899c68bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 8209 additions and 7294 deletions

View File

@ -13,7 +13,7 @@ jobs:
node-version: 'lts/*'
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci
run: npm ci --force
- name: Run linter
run: npm run lint
- name: Run tests

View File

@ -6,28 +6,28 @@ deps:
test: deps
npm run test:all -- --exit
build:
build: test
mkdir -p examples/browser/lib/
npm run build
cp dist/orbitdb.min.js examples/browser/lib/orbitdb.min.js
cp node_modules/ipfs/index.min.js examples/browser/lib/ipfs.min.js
cp dist/orbitdb.js examples/browser/lib/orbitdb.js
cp dist/orbitdb.js.map examples/browser/lib/orbitdb.js.map
cp node_modules/ipfs/index.min.js examples/browser/lib/ipfs.js
cp node_modules/ipfs/dist/index.min.js examples/browser/lib/ipfs.min.js
cp node_modules/ipfs/dist/index.min.js examples/browser/lib/ipfs.js
@echo "Build success!"
@echo "Output: 'dist/', 'examples/browser/'"
clean:
rm -rf orbitdb/
rm -rf node_modules/
rm test/browser/identities.js
rm test/browser/ipfs.js
rm test/browser/orbitdb.js
rm test/browser/ipfslog.min.js
rm -f test/browser/identities.js
rm -f test/browser/ipfs.js
rm -f test/browser/orbitdb.js
rm -f test/browser/ipfslog.min.js
clean-dependencies: clean
rm -f package-lock.json
rebuild: | clean-dependencies deps build
rebuild: | clean-dependencies build
.PHONY: test build

15371
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,6 @@
"ipfs-pubsub-1on1": "next",
"is-node": "^1.0.2",
"logplease": "^1.2.15",
"multihashes": "^4.0.3",
"orbit-db-access-controllers": "next",
"orbit-db-cache": "next",
"orbit-db-counterstore": "next",
@ -48,16 +47,16 @@
"chromium": "^3.0.3",
"cpy-cli": "^4.2.0",
"cross-env": "^7.0.3",
"eslint": "^8.31.0",
"eslint": "^8.32.0",
"fs-extra": "^11.1.0",
"ganache-cli": "^6.12.2",
"go-ipfs": "^0.9.1",
"ipfs": "^0.59.0",
"ipfsd-ctl": "^10.0.3",
"go-ipfs": "^0.17.0",
"ipfs": "^0.66.0",
"ipfsd-ctl": "^13.0.0",
"localstorage-down": "^0.6.7",
"localstorage-level-migration": "next",
"markdown-toc": "^1.2.0",
"mkdirp": "^1.0.4",
"mkdirp": "^2.1.1",
"mocha": "^10.2.0",
"node-pre-gyp": "^0.13.0",
"open-cli": "^7.1.0",
@ -70,7 +69,7 @@
"puppeteer-core": "^19.5.2",
"remark-cli": "^11.0.0",
"remark-validate-links": "^12.1.0",
"rimraf": "^3.0.2",
"rimraf": "^4.1.0",
"standard": "^17.0.0",
"validate-maintainers": "^1.2.2",
"web3": "^1.8.1",
@ -85,7 +84,7 @@
"lint:docs": "remark -qf -u validate-links .",
"test:all": "npm run test:browser-multiple-tabs && npm run test",
"test": "cross-env TEST=all mocha --config test/.mocharc.json",
"test:browser-multiple-tabs": "npm run build:dist && cpy dist/orbitdb.min.js ./test/browser/ --rename=orbitdb.js --flat && cpy node_modules/ipfs/index.min.js ./test/browser --rename=ipfs.js --flat && cpy node_modules/orbit-db-identity-provider/dist/orbit-db-identity-provider.min.js ./test/browser --rename=identities.js --flat && cpy node_modules/ipfs-log/dist/ipfslog.min.js ./test/browser --flat && mocha ./test/browser/concurrent.spec.js",
"test:browser-multiple-tabs": "npm run build:dist && cpy dist/orbitdb.min.js ./test/browser/ --rename=orbitdb.js --flat && cpy node_modules/ipfs/dist/index.min.js ./test/browser --rename=ipfs.js --flat && cpy node_modules/orbit-db-identity-provider/dist/orbit-db-identity-provider.min.js ./test/browser --rename=identities.js --flat && cpy node_modules/ipfs-log/dist/ipfslog.min.js ./test/browser --flat && mocha ./test/browser/concurrent.spec.js",
"build": "npm run build:dist",
"build:examples": "webpack --config conf/webpack.example.config.js",
"build:dist": "webpack --config conf/webpack.config.js",

View File

@ -90,7 +90,7 @@ Object.keys(testAPIs).forEach(API => {
it('has IPFS instance', async () => {
const peerId1 = await accessController._ipfs.id()
const peerId2 = await ipfs1.id()
assert.strictEqual(peerId1.id, peerId2.id)
assert.strictEqual(String(peerId1.id), String(peerId2.id))
})
it('sets default capabilities', async () => {

View File

@ -93,7 +93,7 @@ Object.keys(testAPIs).forEach(API => {
it('has IPFS instance', async () => {
const peerId1 = await accessController._orbitdb._ipfs.id()
const peerId2 = await ipfs1.id()
assert.strictEqual(peerId1.id, peerId2.id)
assert.strictEqual(String(peerId1.id), String(peerId2.id))
})
it('sets default capabilities', async () => {

View File

@ -1,8 +1,8 @@
// TODO: these should be replace with orbit-db-test-utils
export { default as config } from './config.js'
export { testAPIs } from './test-apis.js'
export { default as startIpfs } from './start-ipfs.js'
export { default as stopIpfs } from './stop-ipfs.js'
export { default as waitForPeers } from './wait-for-peers.js'
export { default as connectPeers } from './connect-peers.js'
export { default as MemStore } from './mem-store.js'
export { default as CustomTestKeystore } from './custom-test-keystore.js'

View File

@ -1,46 +0,0 @@
import multihashing from 'multihashing-async'
import mh from 'multihashes'
const defaultHashAlg = 'sha2-256'
const createMultihash = (data, hashAlg) => {
return new Promise((resolve, reject) => {
multihashing(data, hashAlg || defaultHashAlg, (err, multihash) => {
if (err) { return reject(err) }
resolve(mh.toB58String(multihash))
})
})
}
export default class MemStore {
constructor () {
this._store = {}
}
async put (value) {
const data = value
const hash = await createMultihash(data)
if (!this._store) this._store = {}
this._store[hash] = data
return {
toJSON: () => {
return {
data: value,
multihash: hash
}
}
}
}
async get (key) {
return {
toJSON: () => {
return {
data: this._store[key],
multihash: key
}
}
}
}
}

View File

@ -12,11 +12,6 @@ export default (type, config = {}) => {
reject(new Error(`Wanted API type ${JSON.stringify(type)} is unknown. Available types: ${Object.keys(testAPIs).join(', ')}`))
}
// If we're starting a process, pass command line arguments to it
if (!config.args) {
config.args = ['--enable-pubsub-experiment']
}
// Spawn an IPFS daemon (type defined in)
IPFSFactory
.create(testAPIs[type])
@ -25,14 +20,6 @@ export default (type, config = {}) => {
reject(err)
}
// Monkey patch _peerInfo to the ipfs api/instance
// to make js-ipfs-api compatible with js-ipfs
// TODO: Get IPFS id via coherent API call (without it being asynchronous)
if (!ipfsd.api._peerInfo) {
const { id } = await ipfsd.api.id()
ipfsd.api._peerInfo = { id: { _idB58String: id } }
}
resolve(ipfsd)
})
})

View File

@ -23,7 +23,7 @@ const ipfsFixturesDir = path.join('./test', 'fixtures', 'ipfs')
Object.keys(testAPIs).forEach(API => {
describe(`orbit-db - Create & Open (${API})`, function () {
let ipfsFixtures = path.join('./test', 'fixtures', `${API}.zip`)
let ipfsFixtures = path.join('./test', 'fixtures', `js-ipfs.zip`)
this.retries(1) // windows...
this.timeout(config.timeout)

View File

@ -31,7 +31,7 @@ const keyFixtures = path.join('./test', 'fixtures', 'keys','QmRfPsKJs9YqTot5krRi
const ipfsFixturesDir = path.join('./test', 'fixtures', 'ipfs')
Object.keys(testAPIs).forEach(API => {
const ipfsFixtures = path.join('./test', 'fixtures', `${API}.zip`)
const ipfsFixtures = path.join('./test', 'fixtures', `js-ipfs.zip`)
describe(`orbit-db - Backward-Compatibility - Open & Load (${API})`, function () {
this.retries(1) // windows...
@ -57,7 +57,7 @@ Object.keys(testAPIs).forEach(API => {
await fs.copy(path.join(ipfsFixturesDir, 'blocks'), path.join(ipfsd.path, 'blocks'))
await fs.copy(path.join(ipfsFixturesDir, 'datastore'), path.join(ipfsd.path, 'datastore'), { filter: filterFunc })
const peerId = (await ipfs.id()).id
const peerId = String((await ipfs.id()).id)
const store = await storage.createStore(path.join(dbPath, peerId, 'keys'))
keystore = new Keystore(store)