Fix segmentation fault
Add a test for closing the db while loading Catch replication test asserts properly Use latest orbit-db-cache containing the fix for segmentation fault
This commit is contained in:
parent
962a85bdbb
commit
e0bff3dcce
146
package-lock.json
generated
146
package-lock.json
generated
@ -920,16 +920,6 @@
|
||||
"to-fast-properties": "1.0.3"
|
||||
}
|
||||
},
|
||||
"babelify": {
|
||||
"version": "7.3.0",
|
||||
"resolved": "https://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz",
|
||||
"integrity": "sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-core": "6.26.0",
|
||||
"object-assign": "4.1.1"
|
||||
}
|
||||
},
|
||||
"babylon": {
|
||||
"version": "6.18.0",
|
||||
"resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz",
|
||||
@ -1380,9 +1370,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"cacache": {
|
||||
"version": "10.0.1",
|
||||
"resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.1.tgz",
|
||||
"integrity": "sha512-dRHYcs9LvG9cHgdPzjiI+/eS7e1xRhULrcyOx04RZQsszNJXU2SL9CyG60yLnge282Qq5nwTv+ieK2fH+WPZmA==",
|
||||
"version": "10.0.2",
|
||||
"resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.2.tgz",
|
||||
"integrity": "sha512-dljb7dk1jqO5ogE+dRpoR9tpHYv5xz9vPSNunh1+0wRuNdYxmzp9WmsyokgW/DUF1FDRVA/TMsmxt027R8djbQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bluebird": "3.5.1",
|
||||
@ -1441,7 +1431,7 @@
|
||||
},
|
||||
"capture-stack-trace": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz",
|
||||
"integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=",
|
||||
"dev": true
|
||||
},
|
||||
@ -1562,7 +1552,7 @@
|
||||
"requires": {
|
||||
"multibase": "0.3.4",
|
||||
"multicodec": "0.2.5",
|
||||
"multihashes": "0.4.12"
|
||||
"multihashes": "0.4.13"
|
||||
}
|
||||
},
|
||||
"cipher-base": {
|
||||
@ -1801,7 +1791,7 @@
|
||||
},
|
||||
"create-error-class": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz",
|
||||
"resolved": "http://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz",
|
||||
"integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
@ -2473,23 +2463,22 @@
|
||||
"async": "2.6.0",
|
||||
"ethereum-common": "0.2.0",
|
||||
"ethereumjs-tx": "1.3.3",
|
||||
"ethereumjs-util": "5.1.2",
|
||||
"ethereumjs-util": "5.1.3",
|
||||
"merkle-patricia-tree": "2.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethereumjs-util": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.1.2.tgz",
|
||||
"integrity": "sha1-JboCFcu0wvCxCKb5avKi5i5Fkh8=",
|
||||
"version": "5.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.1.3.tgz",
|
||||
"integrity": "sha512-U/wmHagElZVxnpo3bFsvk5beFADegUcEzqtA/NfQbitAPOs6JoYq8M4SY9NfH4HD8236i63UOkkXafd7bqBL9A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-preset-es2015": "6.24.1",
|
||||
"babelify": "7.3.0",
|
||||
"bn.js": "4.11.8",
|
||||
"create-hash": "1.1.3",
|
||||
"ethjs-util": "0.1.4",
|
||||
"keccak": "1.4.0",
|
||||
"rlp": "2.0.0",
|
||||
"safe-buffer": "5.1.1",
|
||||
"secp256k1": "3.4.0"
|
||||
}
|
||||
}
|
||||
@ -2502,7 +2491,7 @@
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ethereum-common": "0.0.18",
|
||||
"ethereumjs-util": "5.1.2"
|
||||
"ethereumjs-util": "5.1.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethereum-common": {
|
||||
@ -2512,18 +2501,17 @@
|
||||
"dev": true
|
||||
},
|
||||
"ethereumjs-util": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.1.2.tgz",
|
||||
"integrity": "sha1-JboCFcu0wvCxCKb5avKi5i5Fkh8=",
|
||||
"version": "5.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.1.3.tgz",
|
||||
"integrity": "sha512-U/wmHagElZVxnpo3bFsvk5beFADegUcEzqtA/NfQbitAPOs6JoYq8M4SY9NfH4HD8236i63UOkkXafd7bqBL9A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-preset-es2015": "6.24.1",
|
||||
"babelify": "7.3.0",
|
||||
"bn.js": "4.11.8",
|
||||
"create-hash": "1.1.3",
|
||||
"ethjs-util": "0.1.4",
|
||||
"keccak": "1.4.0",
|
||||
"rlp": "2.0.0",
|
||||
"safe-buffer": "5.1.1",
|
||||
"secp256k1": "3.4.0"
|
||||
}
|
||||
}
|
||||
@ -4491,7 +4479,7 @@
|
||||
"ipld-resolver": "0.14.1",
|
||||
"is-ipfs": "0.3.2",
|
||||
"is-stream": "1.1.0",
|
||||
"joi": "13.0.2",
|
||||
"joi": "13.1.0",
|
||||
"libp2p": "0.14.3",
|
||||
"libp2p-circuit": "0.1.4",
|
||||
"libp2p-floodsub": "0.13.1",
|
||||
@ -4512,7 +4500,7 @@
|
||||
"mime-types": "2.1.17",
|
||||
"mkdirp": "0.5.1",
|
||||
"multiaddr": "3.0.1",
|
||||
"multihashes": "0.4.12",
|
||||
"multihashes": "0.4.13",
|
||||
"once": "1.4.0",
|
||||
"path-exists": "3.0.0",
|
||||
"peer-book": "0.5.2",
|
||||
@ -4564,7 +4552,7 @@
|
||||
"is-stream": "1.1.0",
|
||||
"lru-cache": "4.1.1",
|
||||
"multiaddr": "3.0.1",
|
||||
"multihashes": "0.4.12",
|
||||
"multihashes": "0.4.13",
|
||||
"ndjson": "1.5.0",
|
||||
"once": "1.4.0",
|
||||
"peer-id": "0.10.4",
|
||||
@ -4740,7 +4728,7 @@
|
||||
"ipld-resolver": "0.14.1",
|
||||
"left-pad": "1.2.0",
|
||||
"lodash": "4.17.4",
|
||||
"multihashes": "0.4.12",
|
||||
"multihashes": "0.4.13",
|
||||
"multihashing-async": "0.4.7",
|
||||
"pull-batch": "1.0.0",
|
||||
"pull-block": "1.4.0",
|
||||
@ -4774,7 +4762,7 @@
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.5.2",
|
||||
"is-circular": "1.0.1",
|
||||
"multihashes": "0.4.12",
|
||||
"multihashes": "0.4.13",
|
||||
"multihashing-async": "0.4.7",
|
||||
"traverse": "0.6.6"
|
||||
}
|
||||
@ -4791,7 +4779,7 @@
|
||||
"cids": "0.5.2",
|
||||
"ipfs-block": "0.6.1",
|
||||
"is-ipfs": "0.3.2",
|
||||
"multihashes": "0.4.12",
|
||||
"multihashes": "0.4.13",
|
||||
"multihashing-async": "0.4.7",
|
||||
"protons": "1.0.1",
|
||||
"pull-stream": "3.6.1",
|
||||
@ -4812,7 +4800,7 @@
|
||||
"ethereumjs-tx": "1.3.3",
|
||||
"ipfs-block": "0.6.1",
|
||||
"merkle-patricia-tree": "2.3.0",
|
||||
"multihashes": "0.4.12",
|
||||
"multihashes": "0.4.13",
|
||||
"multihashing-async": "0.4.7",
|
||||
"rlp": "2.0.0"
|
||||
}
|
||||
@ -4826,7 +4814,7 @@
|
||||
"async": "2.6.0",
|
||||
"cids": "0.5.2",
|
||||
"multicodec": "0.2.5",
|
||||
"multihashes": "0.4.12",
|
||||
"multihashes": "0.4.13",
|
||||
"multihashing-async": "0.4.7",
|
||||
"smart-buffer": "4.0.1",
|
||||
"traverse": "0.6.6"
|
||||
@ -4862,7 +4850,7 @@
|
||||
"lodash.flatten": "4.4.0",
|
||||
"lodash.includes": "4.3.0",
|
||||
"memdown": "1.4.1",
|
||||
"multihashes": "0.4.12",
|
||||
"multihashes": "0.4.13",
|
||||
"pull-sort": "1.0.1",
|
||||
"pull-stream": "3.6.1",
|
||||
"pull-traverse": "1.0.3"
|
||||
@ -5009,7 +4997,7 @@
|
||||
"requires": {
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.5.2",
|
||||
"multihashes": "0.4.12"
|
||||
"multihashes": "0.4.13"
|
||||
}
|
||||
},
|
||||
"is-npm": {
|
||||
@ -5130,9 +5118,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"joi": {
|
||||
"version": "13.0.2",
|
||||
"resolved": "https://registry.npmjs.org/joi/-/joi-13.0.2.tgz",
|
||||
"integrity": "sha512-kVka3LaHQyENvcMW4WJPSepGM43oCofcKxfs9HbbKd/FrwBAAt4lNNTPKOzSMmV53GIspmNO4U3O2TzoGvxxCA==",
|
||||
"version": "13.1.0",
|
||||
"resolved": "https://registry.npmjs.org/joi/-/joi-13.1.0.tgz",
|
||||
"integrity": "sha512-x6pGmDYI6hwNi3skP6irQqRaJntzeaWmZ4rsnjc/NTlf6P5Gp3Aw/O8REe8oLJ6wPhrzd9K3RW1m3Yz/Hx4Weg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"hoek": "5.0.2",
|
||||
@ -5765,7 +5753,7 @@
|
||||
"async": "2.6.0",
|
||||
"buffer-split": "1.0.0",
|
||||
"left-pad": "1.2.0",
|
||||
"multihashes": "0.4.12",
|
||||
"multihashes": "0.4.13",
|
||||
"multihashing-async": "0.4.7",
|
||||
"peer-id": "0.10.4",
|
||||
"protons": "1.0.1"
|
||||
@ -6299,7 +6287,7 @@
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"async": "1.5.2",
|
||||
"ethereumjs-util": "5.1.2",
|
||||
"ethereumjs-util": "5.1.3",
|
||||
"level-ws": "0.0.0",
|
||||
"levelup": "1.3.9",
|
||||
"memdown": "1.4.1",
|
||||
@ -6315,18 +6303,17 @@
|
||||
"dev": true
|
||||
},
|
||||
"ethereumjs-util": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.1.2.tgz",
|
||||
"integrity": "sha1-JboCFcu0wvCxCKb5avKi5i5Fkh8=",
|
||||
"version": "5.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.1.3.tgz",
|
||||
"integrity": "sha512-U/wmHagElZVxnpo3bFsvk5beFADegUcEzqtA/NfQbitAPOs6JoYq8M4SY9NfH4HD8236i63UOkkXafd7bqBL9A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-preset-es2015": "6.24.1",
|
||||
"babelify": "7.3.0",
|
||||
"bn.js": "4.11.8",
|
||||
"create-hash": "1.1.3",
|
||||
"ethjs-util": "0.1.4",
|
||||
"keccak": "1.4.0",
|
||||
"rlp": "2.0.0",
|
||||
"safe-buffer": "5.1.1",
|
||||
"secp256k1": "3.4.0"
|
||||
}
|
||||
}
|
||||
@ -6586,9 +6573,9 @@
|
||||
}
|
||||
},
|
||||
"multihashes": {
|
||||
"version": "0.4.12",
|
||||
"resolved": "https://registry.npmjs.org/multihashes/-/multihashes-0.4.12.tgz",
|
||||
"integrity": "sha512-NU9bw9v9Lk1yd25qv4/c9Ks5ru85F3U0XBGmgooXX+BHVnHWyhgCZS0fsq0a2Jqjj2hqpT1AKjWw+og0e+OrpQ==",
|
||||
"version": "0.4.13",
|
||||
"resolved": "https://registry.npmjs.org/multihashes/-/multihashes-0.4.13.tgz",
|
||||
"integrity": "sha512-HwJGEKPCpLlNlgGQA56CYh/Wsqa+c4JAq8+mheIgw7OK5T4QvNJqgp6TH8gZ4q4l1aiWeNat/H/MrFXmTuoFfQ==",
|
||||
"requires": {
|
||||
"bs58": "4.0.1",
|
||||
"varint": "5.0.0"
|
||||
@ -6603,7 +6590,7 @@
|
||||
"async": "2.6.0",
|
||||
"blakejs": "1.1.0",
|
||||
"js-sha3": "0.6.1",
|
||||
"multihashes": "0.4.12",
|
||||
"multihashes": "0.4.13",
|
||||
"murmurhash3js": "3.0.1",
|
||||
"nodeify": "1.0.1"
|
||||
}
|
||||
@ -6892,12 +6879,13 @@
|
||||
"dev": true
|
||||
},
|
||||
"orbit-db-cache": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/orbit-db-cache/-/orbit-db-cache-0.2.0.tgz",
|
||||
"integrity": "sha512-p+tqK+yDekTgPpBBgnYP1MlVRaHzvqiy0Md1ifpBXP4obdQtVT3YI5mK6ltL5rd7KF620lv0rxgQPLbpmbOvnQ==",
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/orbit-db-cache/-/orbit-db-cache-0.2.1.tgz",
|
||||
"integrity": "sha512-8TzMxV+HoDgxOmcDij8943MuByBQtwSkXy3OAcxGbtmF2r7lDY4DESO6ODsdHEGp+8rxkgOe5unkaACQ5A10hg==",
|
||||
"requires": {
|
||||
"level-js": "2.2.4",
|
||||
"leveldown": "1.9.0",
|
||||
"logplease": "1.2.14",
|
||||
"mkdirp": "0.5.1"
|
||||
}
|
||||
},
|
||||
@ -7034,10 +7022,13 @@
|
||||
"dev": true
|
||||
},
|
||||
"p-limit": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.1.0.tgz",
|
||||
"integrity": "sha1-sH/y2aXYi+yAYDWJWiurZqJ5iLw=",
|
||||
"dev": true
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz",
|
||||
"integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-try": "1.0.0"
|
||||
}
|
||||
},
|
||||
"p-locate": {
|
||||
"version": "2.0.0",
|
||||
@ -7045,7 +7036,7 @@
|
||||
"integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-limit": "1.1.0"
|
||||
"p-limit": "1.2.0"
|
||||
}
|
||||
},
|
||||
"p-map": {
|
||||
@ -7067,6 +7058,12 @@
|
||||
"resolved": "https://registry.npmjs.org/p-reduce/-/p-reduce-1.0.0.tgz",
|
||||
"integrity": "sha1-GMKw3ZNqRpClKfgjH1ig/bakffo="
|
||||
},
|
||||
"p-try": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
|
||||
"integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=",
|
||||
"dev": true
|
||||
},
|
||||
"p-whilst": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/p-whilst/-/p-whilst-1.0.0.tgz",
|
||||
@ -7239,7 +7236,7 @@
|
||||
"async": "2.6.0",
|
||||
"libp2p-crypto": "0.11.0",
|
||||
"lodash": "4.17.4",
|
||||
"multihashes": "0.4.12"
|
||||
"multihashes": "0.4.13"
|
||||
}
|
||||
},
|
||||
"peer-info": {
|
||||
@ -8163,12 +8160,13 @@
|
||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
|
||||
},
|
||||
"schema-utils": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.3.0.tgz",
|
||||
"integrity": "sha1-9YdyIs4+kx7a4DnxfrNxbnE3+M8=",
|
||||
"version": "0.4.3",
|
||||
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.3.tgz",
|
||||
"integrity": "sha512-sgv/iF/T4/SewJkaVpldKC4WjSkz0JsOh2eKtxCPpCO1oR05+7MOF+H476HVRbLArkgA7j5TRJJ4p2jdFkUGQQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ajv": "5.5.2"
|
||||
"ajv": "5.5.2",
|
||||
"ajv-keywords": "2.1.1"
|
||||
}
|
||||
},
|
||||
"secp256k1": {
|
||||
@ -9084,9 +9082,9 @@
|
||||
"integrity": "sha1-m7i6DoQfs/TPH+fCRenz+opf6Zw="
|
||||
},
|
||||
"uglify-es": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.2.2.tgz",
|
||||
"integrity": "sha512-l+s5VLzFwGJfS+fbqaGf/Dfwo1MF13jLOF2ekL0PytzqEqQ6cVppvHf4jquqFok+35USMpKjqkYxy6pQyUcuug==",
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.4.tgz",
|
||||
"integrity": "sha512-vDOyDaf7LcABZI5oJt8bin5FD8kYONux5jd8FY6SsV2SfD+MMXaPeGUotysbycSxdu170y5IQ8FvlKzU/TUryw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"commander": "2.12.2",
|
||||
@ -9109,17 +9107,17 @@
|
||||
"optional": true
|
||||
},
|
||||
"uglifyjs-webpack-plugin": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.1.5.tgz",
|
||||
"integrity": "sha512-YBGc9G7dv12Vjx8vUQs54DZgAXVf04LlG6dNNiEbTZjL3PbUqiY4uPB9Kv+fUJaqRskEGva/lS7sh08yJr7jnA==",
|
||||
"version": "1.1.6",
|
||||
"resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.1.6.tgz",
|
||||
"integrity": "sha512-VUja+7rYbznEvUaeb8IxOCTUrq4BCb1ml0vffa+mfwKtrAwlqnU0ENF14DtYltV1cxd/HSuK51CCA/D/8kMQVw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cacache": "10.0.1",
|
||||
"cacache": "10.0.2",
|
||||
"find-cache-dir": "1.0.0",
|
||||
"schema-utils": "0.3.0",
|
||||
"schema-utils": "0.4.3",
|
||||
"serialize-javascript": "1.4.0",
|
||||
"source-map": "0.6.1",
|
||||
"uglify-es": "3.2.2",
|
||||
"uglify-es": "3.3.4",
|
||||
"webpack-sources": "1.1.0",
|
||||
"worker-farm": "1.5.2"
|
||||
},
|
||||
|
@ -15,7 +15,7 @@
|
||||
"dependencies": {
|
||||
"logplease": "^1.2.14",
|
||||
"multihashes": "^0.4.12",
|
||||
"orbit-db-cache": "~0.2.0",
|
||||
"orbit-db-cache": "~0.2.1",
|
||||
"orbit-db-counterstore": "~1.2.0",
|
||||
"orbit-db-docstore": "~1.2.0",
|
||||
"orbit-db-eventstore": "~1.2.0",
|
||||
|
@ -86,6 +86,13 @@ describe('orbit-db - Persistency', function() {
|
||||
}
|
||||
})
|
||||
|
||||
it('closes database while loading', async () => {
|
||||
db = await orbitdb1.eventlog(address)
|
||||
db.load() // don't wait for load to finish
|
||||
await db.close()
|
||||
assert.equal(db._cache.store, null)
|
||||
})
|
||||
|
||||
it('load, add one, close - several times', async () => {
|
||||
const amount = 8
|
||||
for (let i = 0; i < amount; i ++) {
|
||||
|
@ -192,32 +192,36 @@ describe('orbit-db - Replication', function() {
|
||||
})
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
timer = setInterval(() => {
|
||||
if (finished) {
|
||||
clearInterval(timer)
|
||||
try {
|
||||
timer = setInterval(() => {
|
||||
if (finished) {
|
||||
clearInterval(timer)
|
||||
|
||||
assert.equal(eventCount['replicate'], expectedEventCount)
|
||||
assert.equal(eventCount['replicate.progress'], expectedEventCount)
|
||||
assert.equal(eventCount['replicate'], expectedEventCount)
|
||||
assert.equal(eventCount['replicate.progress'], expectedEventCount)
|
||||
|
||||
const replicateEvents = events.filter(e => e.event === 'replicate')
|
||||
assert.equal(replicateEvents.length, expectedEventCount)
|
||||
assert.equal(replicateEvents[0].entry.payload.value.split(' ')[0], 'hello')
|
||||
assert.equal(replicateEvents[0].entry.clock.time, 1)
|
||||
const replicateEvents = events.filter(e => e.event === 'replicate')
|
||||
assert.equal(replicateEvents.length, expectedEventCount)
|
||||
assert.equal(replicateEvents[0].entry.payload.value.split(' ')[0], 'hello')
|
||||
assert.equal(replicateEvents[0].entry.clock.time, 1)
|
||||
|
||||
const replicateProgressEvents = events.filter(e => e.event === 'replicate.progress')
|
||||
assert.equal(replicateProgressEvents.length, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[0].entry.payload.value.split(' ')[0], 'hello')
|
||||
assert.equal(replicateProgressEvents[0].entry.clock.time, 1)
|
||||
assert.equal(replicateProgressEvents[0].replicationInfo.max, 1)
|
||||
assert.equal(replicateProgressEvents[0].replicationInfo.progress, 1)
|
||||
const replicateProgressEvents = events.filter(e => e.event === 'replicate.progress')
|
||||
assert.equal(replicateProgressEvents.length, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[0].entry.payload.value.split(' ')[0], 'hello')
|
||||
assert.equal(replicateProgressEvents[0].entry.clock.time, 1)
|
||||
assert.equal(replicateProgressEvents[0].replicationInfo.max, 1)
|
||||
assert.equal(replicateProgressEvents[0].replicationInfo.progress, 1)
|
||||
|
||||
const replicatedEvents = events.filter(e => e.event === 'replicated')
|
||||
assert.equal(replicatedEvents[0].replicationInfo.max, 1)
|
||||
assert.equal(replicatedEvents[0].replicationInfo.progress, 1)
|
||||
const replicatedEvents = events.filter(e => e.event === 'replicated')
|
||||
assert.equal(replicatedEvents[0].replicationInfo.max, 1)
|
||||
assert.equal(replicatedEvents[0].replicationInfo.progress, 1)
|
||||
|
||||
resolve()
|
||||
}
|
||||
}, 100)
|
||||
resolve()
|
||||
}
|
||||
}, 100)
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
|
||||
// Trigger replication
|
||||
let adds = []
|
||||
@ -237,8 +241,8 @@ describe('orbit-db - Replication', function() {
|
||||
let expectedEventCount = 512
|
||||
|
||||
// Close second instance
|
||||
// await db2.close()
|
||||
// await db2.drop()
|
||||
await db2.close()
|
||||
await db2.drop()
|
||||
|
||||
// Trigger replication
|
||||
let adds = []
|
||||
@ -332,36 +336,40 @@ describe('orbit-db - Replication', function() {
|
||||
}, 500)
|
||||
})
|
||||
|
||||
const st = new Date().getTime()
|
||||
timer = setInterval(async () => {
|
||||
if (finished) {
|
||||
clearInterval(timer)
|
||||
try {
|
||||
const st = new Date().getTime()
|
||||
timer = setInterval(async () => {
|
||||
if (finished) {
|
||||
clearInterval(timer)
|
||||
|
||||
const et = new Date().getTime()
|
||||
console.log("Duration:", et - st, "ms")
|
||||
const et = new Date().getTime()
|
||||
console.log("Duration:", et - st, "ms")
|
||||
|
||||
assert.equal(eventCount['replicate'], expectedEventCount)
|
||||
assert.equal(eventCount['replicate.progress'], expectedEventCount)
|
||||
assert.equal(eventCount['replicate'], expectedEventCount)
|
||||
assert.equal(eventCount['replicate.progress'], expectedEventCount)
|
||||
|
||||
const replicateEvents = events.filter(e => e.event === 'replicate')
|
||||
assert.equal(replicateEvents.length, expectedEventCount)
|
||||
assert.equal(replicateEvents[0].entry.payload.value.split(' ')[0], 'hello')
|
||||
assert.equal(replicateEvents[0].entry.clock.time, expectedEventCount)
|
||||
const replicateEvents = events.filter(e => e.event === 'replicate')
|
||||
assert.equal(replicateEvents.length, expectedEventCount)
|
||||
assert.equal(replicateEvents[0].entry.payload.value.split(' ')[0], 'hello')
|
||||
assert.equal(replicateEvents[0].entry.clock.time, expectedEventCount)
|
||||
|
||||
const replicateProgressEvents = events.filter(e => e.event === 'replicate.progress')
|
||||
assert.equal(replicateProgressEvents.length, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[0].entry.payload.value.split(' ')[0], 'hello')
|
||||
assert.equal(replicateProgressEvents[0].entry.clock.time, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[0].replicationInfo.max, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[0].replicationInfo.progress, 1)
|
||||
const replicateProgressEvents = events.filter(e => e.event === 'replicate.progress')
|
||||
assert.equal(replicateProgressEvents.length, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[0].entry.payload.value.split(' ')[0], 'hello')
|
||||
assert.equal(replicateProgressEvents[0].entry.clock.time, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[0].replicationInfo.max, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[0].replicationInfo.progress, 1)
|
||||
|
||||
const replicatedEvents = events.filter(e => e.event === 'replicated')
|
||||
assert.equal(replicatedEvents[0].replicationInfo.max, expectedEventCount)
|
||||
assert.equal(replicatedEvents[replicatedEvents.length - 1].replicationInfo.progress, expectedEventCount)
|
||||
const replicatedEvents = events.filter(e => e.event === 'replicated')
|
||||
assert.equal(replicatedEvents[0].replicationInfo.max, expectedEventCount)
|
||||
assert.equal(replicatedEvents[replicatedEvents.length - 1].replicationInfo.progress, expectedEventCount)
|
||||
|
||||
resolve()
|
||||
}
|
||||
}, 100)
|
||||
resolve()
|
||||
}
|
||||
}, 100)
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@ -456,49 +464,53 @@ describe('orbit-db - Replication', function() {
|
||||
|
||||
const st = new Date().getTime()
|
||||
|
||||
await mapSeries(adds, add)
|
||||
try {
|
||||
await mapSeries(adds, add)
|
||||
|
||||
timer = setInterval(async () => {
|
||||
if (finished) {
|
||||
clearInterval(timer)
|
||||
timer = setInterval(() => {
|
||||
if (finished) {
|
||||
clearInterval(timer)
|
||||
|
||||
const et = new Date().getTime()
|
||||
console.log("Duration:", et - st, "ms")
|
||||
const et = new Date().getTime()
|
||||
console.log("Duration:", et - st, "ms")
|
||||
|
||||
assert.equal(eventCount['replicate'], expectedEventCount)
|
||||
assert.equal(eventCount['replicate.progress'], expectedEventCount)
|
||||
assert.equal(eventCount['replicated'], expectedEventCount)
|
||||
assert.equal(eventCount['replicate'], expectedEventCount)
|
||||
assert.equal(eventCount['replicate.progress'], expectedEventCount)
|
||||
assert.equal(eventCount['replicated'], expectedEventCount)
|
||||
|
||||
const replicateEvents = events.filter(e => e.event === 'replicate')
|
||||
assert.equal(replicateEvents.length, expectedEventCount)
|
||||
const replicateEvents = events.filter(e => e.event === 'replicate')
|
||||
assert.equal(replicateEvents.length, expectedEventCount)
|
||||
|
||||
const replicateProgressEvents = events.filter(e => e.event === 'replicate.progress')
|
||||
assert.equal(replicateProgressEvents.length, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[replicateProgressEvents.length - 1].entry.clock.time, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[replicateProgressEvents.length - 1].replicationInfo.max, expectedEventCount * 2)
|
||||
assert.equal(replicateProgressEvents[replicateProgressEvents.length - 1].replicationInfo.progress, expectedEventCount * 2)
|
||||
const replicateProgressEvents = events.filter(e => e.event === 'replicate.progress')
|
||||
assert.equal(replicateProgressEvents.length, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[replicateProgressEvents.length - 1].entry.clock.time, expectedEventCount)
|
||||
assert.equal(replicateProgressEvents[replicateProgressEvents.length - 1].replicationInfo.max, expectedEventCount * 2)
|
||||
assert.equal(replicateProgressEvents[replicateProgressEvents.length - 1].replicationInfo.progress, expectedEventCount * 2)
|
||||
|
||||
const replicatedEvents = events.filter(e => e.event === 'replicated')
|
||||
assert.equal(replicatedEvents[replicatedEvents.length - 1].replicationInfo.progress, expectedEventCount * 2)
|
||||
assert.equal(replicatedEvents[replicatedEvents.length - 1].replicationInfo.max, expectedEventCount * 2)
|
||||
const replicatedEvents = events.filter(e => e.event === 'replicated')
|
||||
assert.equal(replicatedEvents[replicatedEvents.length - 1].replicationInfo.progress, expectedEventCount * 2)
|
||||
assert.equal(replicatedEvents[replicatedEvents.length - 1].replicationInfo.max, expectedEventCount * 2)
|
||||
|
||||
const values1 = db1.iterator({limit: -1}).collect()
|
||||
const values2 = db2.iterator({limit: -1}).collect()
|
||||
assert.deepEqual(values1, values2)
|
||||
const values1 = db1.iterator({limit: -1}).collect()
|
||||
const values2 = db2.iterator({limit: -1}).collect()
|
||||
assert.deepEqual(values1, values2)
|
||||
|
||||
// Test the replicator state
|
||||
assert.equal(db1._loader.tasksRequested, expectedEventCount)
|
||||
assert.equal(db1._loader.tasksQueued, 0)
|
||||
assert.equal(db1._loader.tasksRunning, 0)
|
||||
assert.equal(db1._loader.tasksFinished, expectedEventCount)
|
||||
assert.equal(db2._loader.tasksRequested, expectedEventCount)
|
||||
assert.equal(db2._loader.tasksQueued, 0)
|
||||
assert.equal(db2._loader.tasksRunning, 0)
|
||||
assert.equal(db2._loader.tasksFinished, expectedEventCount)
|
||||
// Test the replicator state
|
||||
assert.equal(db1._loader.tasksRequested, expectedEventCount)
|
||||
assert.equal(db1._loader.tasksQueued, 0)
|
||||
assert.equal(db1._loader.tasksRunning, 0)
|
||||
assert.equal(db1._loader.tasksFinished, expectedEventCount)
|
||||
assert.equal(db2._loader.tasksRequested, expectedEventCount)
|
||||
assert.equal(db2._loader.tasksQueued, 0)
|
||||
assert.equal(db2._loader.tasksRunning, 0)
|
||||
assert.equal(db2._loader.tasksFinished, expectedEventCount)
|
||||
|
||||
resolve()
|
||||
}
|
||||
}, 100)
|
||||
resolve()
|
||||
}
|
||||
}, 100)
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user