From d0af9a45bda7fd39355d5d626fcfa35d766ce782 Mon Sep 17 00:00:00 2001 From: haad Date: Fri, 30 Mar 2018 12:46:53 +0200 Subject: [PATCH] Add tests for replication status information Use latest store modules Add a set of tests for checking database replication status Fix tests as per new replication status api --- package-lock.json | 243 ++++++++++++++------------------ package.json | 12 +- test/persistency.js | 15 +- test/replicate.test.js | 60 ++++---- test/replication-status.test.js | 103 ++++++++++++++ 5 files changed, 257 insertions(+), 176 deletions(-) create mode 100644 test/replication-status.test.js diff --git a/package-lock.json b/package-lock.json index 3874631..3432b8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -302,9 +302,9 @@ "dev": true }, "atob": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.0.3.tgz", - "integrity": "sha1-GcenYEc3dEaPILLS0DNyrX1Mv10=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.0.tgz", + "integrity": "sha512-SuiKH8vbsOyCALjA/+EINmt/Kdl+TQPrtFgW7XZZcwtryFu9e5kQoX3bjCW6mIvGH1fbeAZZuvwGR5IlBRznGw==", "dev": true }, "aws-sign2": { @@ -790,7 +790,7 @@ "dev": true, "requires": { "babel-runtime": "6.26.0", - "core-js": "2.5.3", + "core-js": "2.5.4", "regenerator-runtime": "0.10.5" }, "dependencies": { @@ -842,7 +842,7 @@ "requires": { "babel-core": "6.26.0", "babel-runtime": "6.26.0", - "core-js": "2.5.3", + "core-js": "2.5.4", "home-or-tmp": "2.0.0", "lodash": "4.17.5", "mkdirp": "0.5.1", @@ -855,7 +855,7 @@ "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", "dev": true, "requires": { - "core-js": "2.5.3", + "core-js": "2.5.4", "regenerator-runtime": "0.11.1" } }, @@ -2048,9 +2048,9 @@ "dev": true }, "core-js": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", - "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=", + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.4.tgz", + "integrity": "sha1-8si/GB8qgLkvNgEhQpzmOi8K6uA=", "dev": true }, "core-util-is": { @@ -2176,7 +2176,7 @@ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "es5-ext": "0.10.41" + "es5-ext": "0.10.42" } }, "dashdash": { @@ -2204,7 +2204,7 @@ "interface-datastore": "0.4.2", "left-pad": "1.2.0", "pull-many": "1.0.8", - "pull-stream": "3.6.3" + "pull-stream": "3.6.7" } }, "datastore-fs": { @@ -2219,7 +2219,7 @@ "graceful-fs": "4.1.11", "interface-datastore": "0.4.2", "mkdirp": "0.5.1", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "write-file-atomic": "2.3.0" }, "dependencies": { @@ -2247,7 +2247,7 @@ "level-js": "2.2.4", "leveldown": "1.9.0", "levelup": "1.3.9", - "pull-stream": "3.6.3" + "pull-stream": "3.6.7" } }, "date-now": { @@ -2546,9 +2546,9 @@ } }, "engine.io": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.1.5.tgz", - "integrity": "sha512-D06ivJkYxyRrcEe0bTpNnBQNgP9d3xog+qZlLbui8EsMr/DouQpf5o9FzJnWYHEYE0YsFHllUv2R1dkgYZXHcA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.2.0.tgz", + "integrity": "sha512-mRbgmAtQ4GAlKwuPnnAvXXwdPhEx+jkc0OBCLrXuD/CRvwNK3AxRSnqK4FSqmAMRRHryVJP8TopOvmEaA64fKw==", "dev": true, "requires": { "accepts": "1.3.5", @@ -2556,14 +2556,13 @@ "cookie": "0.3.1", "debug": "3.1.0", "engine.io-parser": "2.1.2", - "uws": "9.14.0", "ws": "3.3.3" } }, "engine.io-client": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.1.6.tgz", - "integrity": "sha512-hnuHsFluXnsKOndS4Hv6SvUrgdYx1pk2NqfaDMW+GWdgfU3+/V25Cj7I8a0x92idSpa5PIhJRKxPvp9mnoLsfg==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.2.1.tgz", + "integrity": "sha512-y5AbkytWeM4jQr7m/koQLc5AxpRKC1hEVUb/s1FUAWEJq5AzJJ4NLvzuKPuxtDi5Mq755WuDvZ6Iv2rXj4PTzw==", "dev": true, "requires": { "component-emitter": "1.2.1", @@ -2632,9 +2631,9 @@ } }, "es5-ext": { - "version": "0.10.41", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.41.tgz", - "integrity": "sha512-MYK02wXfwTMie5TEJWPolgOsXEmz7wKCQaGzgmRjZOoV6VLG8I5dSv2bn6AOClXhK64gnSQTQ9W9MKvx87J4gw==", + "version": "0.10.42", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.42.tgz", + "integrity": "sha512-AJxO1rmPe1bDEfSR6TJ/FgMFYuTBhR5R57KW58iCkYACMyFbrkqVyzXSurYoScDGvgyMpk7uRF/lPUPPTmsRSA==", "dev": true, "requires": { "es6-iterator": "2.0.3", @@ -2649,7 +2648,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.41", + "es5-ext": "0.10.42", "es6-symbol": "3.1.1" } }, @@ -2660,7 +2659,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.41", + "es5-ext": "0.10.42", "es6-iterator": "2.0.3", "es6-set": "0.1.5", "es6-symbol": "3.1.1", @@ -2674,7 +2673,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.41", + "es5-ext": "0.10.42", "es6-iterator": "2.0.3", "es6-symbol": "3.1.1", "event-emitter": "0.3.5" @@ -2687,7 +2686,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.41" + "es5-ext": "0.10.42" } }, "es6-weak-map": { @@ -2697,7 +2696,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.41", + "es5-ext": "0.10.42", "es6-iterator": "2.0.3", "es6-symbol": "3.1.1" } @@ -2918,7 +2917,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.41" + "es5-ext": "0.10.42" } }, "events": { @@ -5348,9 +5347,9 @@ "dev": true }, "go-ipfs-dep": { - "version": "0.4.13", - "resolved": "https://registry.npmjs.org/go-ipfs-dep/-/go-ipfs-dep-0.4.13.tgz", - "integrity": "sha512-Kwhhk+IpwHY8R4iDSQkaZull23aFg2lAj1ux17fS4JkzMObmv1XYuFo2gTioGSn8Z1R4b5z+kSydJ4Mi/hy/hQ==", + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/go-ipfs-dep/-/go-ipfs-dep-0.4.14.tgz", + "integrity": "sha512-MwIJr8Sy9O6GJrN+BroWR9ywcxagKFrqBdaA4zvg4oyeYow8aGXRzyvDlKtjYNAaT+YQrQmZg69JfK3LAgXk9g==", "dev": true, "requires": { "go-platform": "1.0.0", @@ -5864,7 +5863,7 @@ "requires": { "async": "2.6.0", "pull-defer": "0.2.2", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "uuid": "3.2.1" } }, @@ -5964,7 +5963,7 @@ "libp2p-mdns": "0.9.2", "libp2p-multiplex": "0.5.1", "libp2p-railing": "0.7.1", - "libp2p-secio": "0.9.3", + "libp2p-secio": "0.9.4", "libp2p-tcp": "0.11.6", "libp2p-webrtc-star": "0.13.4", "libp2p-websocket-star": "0.7.7", @@ -5994,7 +5993,7 @@ "pull-paramap": "1.2.2", "pull-pushable": "2.2.0", "pull-sort": "1.0.1", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "pull-stream-to-stream": "1.3.4", "pull-zip": "2.0.1", "read-pkg-up": "3.0.0", @@ -6130,7 +6129,7 @@ "pull-defer": "0.2.2", "pull-length-prefixed": "1.3.0", "pull-pushable": "2.2.0", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "safe-buffer": "5.1.1", "varint-decoder": "0.1.1" }, @@ -6216,7 +6215,7 @@ "lodash.has": "4.5.2", "lodash.set": "4.3.2", "multiaddr": "3.1.0", - "pull-stream": "3.6.3" + "pull-stream": "3.6.7" }, "dependencies": { "abstract-leveldown": { @@ -6285,7 +6284,7 @@ "pull-paramap": "1.2.2", "pull-pause": "0.0.2", "pull-pushable": "2.2.0", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "pull-traverse": "1.0.3", "pull-write": "1.1.4", "sparse-array": "1.3.1" @@ -6373,7 +6372,7 @@ "multihashes": "0.4.13", "pull-defer": "0.2.2", "pull-sort": "1.0.1", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "pull-traverse": "1.0.3" } }, @@ -6429,7 +6428,7 @@ "multihashes": "0.4.13", "multihashing-async": "0.4.8", "protons": "1.0.1", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "pull-traverse": "1.0.3", "stable": "0.1.6" } @@ -7263,7 +7262,7 @@ "protons": "1.0.1", "pull-abortable": "4.1.1", "pull-handshake": "1.1.4", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "safe-buffer": "5.1.1", "setimmediate": "1.0.5" } @@ -7338,7 +7337,7 @@ "peer-info": "0.11.6", "protons": "1.0.1", "pull-length-prefixed": "1.3.0", - "pull-stream": "3.6.3" + "pull-stream": "3.6.7" } }, "libp2p-kad-dht": { @@ -7363,7 +7362,7 @@ "priorityqueue": "0.2.1", "protons": "1.0.1", "pull-length-prefixed": "1.3.0", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "safe-buffer": "5.1.1", "varint": "5.0.0", "xor-distance": "1.0.0" @@ -7379,7 +7378,7 @@ "deepmerge": "1.5.2", "interface-datastore": "0.4.2", "libp2p-crypto": "0.12.1", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "sanitize-filename": "1.6.1" } }, @@ -7405,7 +7404,7 @@ "async": "2.6.0", "multiplex": "github:dignifiedquire/multiplex#b5d5edd30454e2c978ee8c52df86f5f4840d2eab", "pull-catch": "1.0.0", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "pull-stream-to-stream": "1.3.4", "pump": "2.0.1", "stream-to-pull-stream": "1.7.2" @@ -7419,7 +7418,7 @@ "requires": { "libp2p-crypto": "0.12.1", "pull-handshake": "1.1.4", - "pull-stream": "3.6.3" + "pull-stream": "3.6.7" } }, "libp2p-railing": { @@ -7452,9 +7451,9 @@ } }, "libp2p-secio": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/libp2p-secio/-/libp2p-secio-0.9.3.tgz", - "integrity": "sha512-p9EMXKlpuUbqnSC6XjjKvfE8d5fxFEgfB9kUjlU/k0Qayr2MXbktKEle5ocsejFoqr4/sQzLxHi5goPuq+IuyQ==", + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/libp2p-secio/-/libp2p-secio-0.9.4.tgz", + "integrity": "sha512-tbeOi5pk+eSTrOmE8dB/3cEaNATAkpOktwTKGuY72azBepcJWW2d9etAUTJMUGM6GAcf8kqenI8ZarcCz6Eydg==", "dev": true, "requires": { "async": "2.6.0", @@ -7468,7 +7467,7 @@ "pull-defer": "0.2.2", "pull-handshake": "1.1.4", "pull-length-prefixed": "1.3.0", - "pull-stream": "3.6.3" + "pull-stream": "3.6.7" } }, "libp2p-switch": { @@ -7489,7 +7488,7 @@ "once": "1.4.0", "peer-id": "0.10.6", "peer-info": "0.11.6", - "pull-stream": "3.6.3" + "pull-stream": "3.6.7" } }, "libp2p-tcp": { @@ -7528,10 +7527,10 @@ "once": "1.4.0", "peer-id": "0.10.6", "peer-info": "0.11.6", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "simple-peer": "8.5.0", - "socket.io": "2.0.4", - "socket.io-client": "2.0.4", + "socket.io": "2.1.0", + "socket.io-client": "2.1.0", "stream-to-pull-stream": "1.7.2", "webrtcsupport": "github:ipfs/webrtcsupport#0669f576582c53a3a42aa5ac014fcc5966809615" } @@ -7553,8 +7552,8 @@ "once": "1.4.0", "peer-id": "0.10.6", "peer-info": "0.11.6", - "pull-stream": "3.6.3", - "socket.io-client": "2.0.4", + "pull-stream": "3.6.7", + "socket.io-client": "2.1.0", "socket.io-pull-stream": "0.1.5", "uuid": "3.2.1" } @@ -8391,7 +8390,7 @@ "once": "1.4.0", "pull-handshake": "1.1.4", "pull-length-prefixed": "1.3.0", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "semver": "5.5.0", "varint": "5.0.0" } @@ -8753,20 +8752,20 @@ } }, "orbit-db-counterstore": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/orbit-db-counterstore/-/orbit-db-counterstore-1.3.0.tgz", - "integrity": "sha512-PmXvxJzYvHrcPNXjkzOmHpHchIH+WavV8vOXCn/ufvrtpWVmIx7hZVJaz4jppOwX+g3AtgKETcuVv1XokDmuvw==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/orbit-db-counterstore/-/orbit-db-counterstore-1.3.1.tgz", + "integrity": "sha512-ZrSv5dTOslPSkMFOzyGdr9aotioGH6Gg86ULWswF54//uD5p9034Eo0s2L5ez9KRqr196vFo+fx23uU3QAEV5A==", "requires": { "crdts": "0.1.5", - "orbit-db-store": "2.3.1" + "orbit-db-store": "2.4.0" } }, "orbit-db-docstore": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/orbit-db-docstore/-/orbit-db-docstore-1.3.0.tgz", - "integrity": "sha512-+luBcnmjsZ179z+cP14QjxfLNwZSjdEyQIp7X+tJK3TGilCHNXvkksMP3Xqqe6udtZqW7T12en+XPl1dAZzOhg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/orbit-db-docstore/-/orbit-db-docstore-1.3.1.tgz", + "integrity": "sha512-aCYQIQKs1wrY9pUHD94md1hcQ2xC+XEwQd7VoZuPgAiIC/s0dNPpDQKc9L5BdVVozFAfsO5yKxzbk1oHOvObFg==", "requires": { - "orbit-db-store": "2.3.1", + "orbit-db-store": "2.4.0", "p-map": "1.1.1" }, "dependencies": { @@ -8778,19 +8777,19 @@ } }, "orbit-db-eventstore": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/orbit-db-eventstore/-/orbit-db-eventstore-1.3.0.tgz", - "integrity": "sha512-8zFsc/12od4vuqwNq3qMIH/ehaYLote4PWoiBPOEDojPI02NWaiCC1jiyZM669p3ZhLU28UKCRRb3MRapLRAfQ==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/orbit-db-eventstore/-/orbit-db-eventstore-1.3.1.tgz", + "integrity": "sha512-e9/AFS7U6i4hcm35x2CmTyNhVNUfjd4CWgdT6nyF4UIjE4vJvvYmj1qZJx+L54HCqoLKhJuOs/yhmQIhH6wQEA==", "requires": { - "orbit-db-store": "2.3.1" + "orbit-db-store": "2.4.0" } }, "orbit-db-feedstore": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/orbit-db-feedstore/-/orbit-db-feedstore-1.3.0.tgz", - "integrity": "sha512-NMSA6DPK2qzL2ydYiOMLjN29+P0ffepdHezvOH1U9oHI///gUgYs7pRB3nuqtKnxf1jou6QzXQlDFLkvp+AG9A==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/orbit-db-feedstore/-/orbit-db-feedstore-1.3.1.tgz", + "integrity": "sha512-5k3AjoQ5FJbtpHXCi4D4FSmYaleMfKmIQhcOT9M4bS9qZ6w4CZTz44cX/kYobYi7umi8qz0Dm9MXB0rdE8zCeQ==", "requires": { - "orbit-db-eventstore": "1.3.0" + "orbit-db-eventstore": "1.3.1" } }, "orbit-db-keystore": { @@ -8804,11 +8803,11 @@ } }, "orbit-db-kvstore": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/orbit-db-kvstore/-/orbit-db-kvstore-1.3.0.tgz", - "integrity": "sha512-S8cKGDyt8D/mjwC7WzMZCyT+FsyNq3AiTYHKfjNZxZjzpql833SrdaTkSxuHkQ1mQ7V2Gqf9FG028hx62kbl8g==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/orbit-db-kvstore/-/orbit-db-kvstore-1.3.1.tgz", + "integrity": "sha512-4jB123qGQvfPVdF+3cv0gKYr1gcygPWqqO4/hr+9eiAL1NMRAdzo0gCMafOMDv9dWk21ppKKKcgugWBNNtZWyg==", "requires": { - "orbit-db-store": "2.3.1" + "orbit-db-store": "2.4.0" } }, "orbit-db-pubsub": { @@ -8821,9 +8820,9 @@ } }, "orbit-db-store": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/orbit-db-store/-/orbit-db-store-2.3.1.tgz", - "integrity": "sha512-nmEDx4deLARaeyNalczZvdXwD8oh35lws37WZh5/ypevcpL//UxGZGfMGceSCaM3am8llF75WRtCDZTyNiEgxg==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/orbit-db-store/-/orbit-db-store-2.4.0.tgz", + "integrity": "sha512-dIefF8jSvhwHj77YU7IR7rNoOJbUXaM6ByJmuQH05V5f6+b1Uu2vP4wm/9QQazozzU+D472fanpSC9RkBOi3bA==", "requires": { "ipfs-log": "4.0.6", "logplease": "1.2.14", @@ -9446,7 +9445,7 @@ "integrity": "sha1-Pa3ZttFWxUVyG9qNAAPdjqoGKT4=", "dev": true, "requires": { - "pull-stream": "3.6.3" + "pull-stream": "3.6.7" } }, "pull-ndjson": { @@ -9456,7 +9455,7 @@ "dev": true, "requires": { "pull-split": "0.2.0", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "pull-stringify": "1.2.2" } }, @@ -9508,7 +9507,7 @@ "dev": true, "requires": { "pull-defer": "0.2.2", - "pull-stream": "3.6.3" + "pull-stream": "3.6.7" } }, "pull-split": { @@ -9521,9 +9520,9 @@ } }, "pull-stream": { - "version": "3.6.3", - "resolved": "https://registry.npmjs.org/pull-stream/-/pull-stream-3.6.3.tgz", - "integrity": "sha1-gBCGTB2dmehTnVpIfKdYMTHEmbg=", + "version": "3.6.7", + "resolved": "https://registry.npmjs.org/pull-stream/-/pull-stream-3.6.7.tgz", + "integrity": "sha512-XdE2/o1I2lK7A+sbbA/HjYnd5Xk7wL5CwAKzqHIgcBsluDb0LiKHNTl1K0it3/RKPshQljLf4kl1aJ12YsCCGQ==", "dev": true }, "pull-stream-to-stream": { @@ -9567,7 +9566,7 @@ "requires": { "looper": "4.0.0", "pull-cat": "1.1.11", - "pull-stream": "3.6.3" + "pull-stream": "3.6.7" }, "dependencies": { "looper": { @@ -10493,27 +10492,17 @@ } }, "socket.io": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.0.4.tgz", - "integrity": "sha1-waRZDO/4fs8TxyZS8Eb3FrKeYBQ=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.1.0.tgz", + "integrity": "sha512-KS+3CNWWNtLbVN5j0/B+1hjxRzey+oTK6ejpAOoxMZis6aXeB8cUtfuvjHl97tuZx+t/qD/VyqFMjuzu2Js6uQ==", "dev": true, "requires": { - "debug": "2.6.9", - "engine.io": "3.1.5", + "debug": "3.1.0", + "engine.io": "3.2.0", + "has-binary2": "1.0.2", "socket.io-adapter": "1.1.1", - "socket.io-client": "2.0.4", - "socket.io-parser": "3.1.3" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } + "socket.io-client": "2.1.0", + "socket.io-parser": "3.2.0" } }, "socket.io-adapter": { @@ -10523,46 +10512,35 @@ "dev": true }, "socket.io-client": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.0.4.tgz", - "integrity": "sha1-CRilUkBtxeVAs4Dc2Xr8SmQzL44=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.1.0.tgz", + "integrity": "sha512-TvKPpL0cBON5LduQfR8Rxrr+ktj70bLXGvqHCL3er5avBXruB3gpnbaud5ikFYVfANH1gCABAvo0qN8Axpg2ew==", "dev": true, "requires": { "backo2": "1.0.2", "base64-arraybuffer": "0.1.5", "component-bind": "1.0.0", "component-emitter": "1.2.1", - "debug": "2.6.9", - "engine.io-client": "3.1.6", + "debug": "3.1.0", + "engine.io-client": "3.2.1", + "has-binary2": "1.0.2", "has-cors": "1.1.0", "indexof": "0.0.1", "object-component": "0.0.3", "parseqs": "0.0.5", "parseuri": "0.0.5", - "socket.io-parser": "3.1.3", + "socket.io-parser": "3.2.0", "to-array": "0.1.4" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } } }, "socket.io-parser": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.1.3.tgz", - "integrity": "sha512-g0a2HPqLguqAczs3dMECuA1RgoGFPyvDqcbaDEdCWY9g59kdUAz3YRmaJBNKXflrHNwB7Q12Gkf/0CZXfdHR7g==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.2.0.tgz", + "integrity": "sha512-FYiBx7rc/KORMJlgsXysflWx/RIvtqZbyGLlHZvjfmPTPeuD/I8MaW7cfFrj5tRltICJdgwflhfZ3NVVbVLFQA==", "dev": true, "requires": { "component-emitter": "1.2.1", "debug": "3.1.0", - "has-binary2": "1.0.2", "isarray": "2.0.1" }, "dependencies": { @@ -10582,7 +10560,7 @@ "requires": { "data-queue": "0.0.3", "debug": "3.1.0", - "pull-stream": "3.6.3", + "pull-stream": "3.6.7", "uuid": "3.2.1" } }, @@ -10604,7 +10582,7 @@ "integrity": "sha512-0KW2wvzfxm8NCTb30z0LMNyPqWCdDGE2viwzUaucqJdkTRXtZiSY3I+2A6nVAjmdOy0I4gU8DwnVVGsk9jvP2A==", "dev": true, "requires": { - "atob": "2.0.3", + "atob": "2.1.0", "decode-uri-component": "0.2.0", "resolve-url": "0.2.1", "source-map-url": "0.4.0", @@ -10897,7 +10875,7 @@ "dev": true, "requires": { "looper": "3.0.0", - "pull-stream": "3.6.3" + "pull-stream": "3.6.7" } }, "streamifier": { @@ -11668,13 +11646,6 @@ "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, - "uws": { - "version": "9.14.0", - "resolved": "https://registry.npmjs.org/uws/-/uws-9.14.0.tgz", - "integrity": "sha512-HNMztPP5A1sKuVFmdZ6BPVpBQd5bUjNC8EFMFiICK+oho/OQsAJy5hnIx4btMHiOk8j04f/DbIlqnEZ9d72dqg==", - "dev": true, - "optional": true - }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", diff --git a/package.json b/package.json index 7e014b9..815e3da 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,12 @@ "logplease": "^1.2.14", "multihashes": "^0.4.12", "orbit-db-cache": "~0.2.2", - "orbit-db-counterstore": "~1.3.0", - "orbit-db-docstore": "~1.3.0", - "orbit-db-eventstore": "~1.3.0", - "orbit-db-feedstore": "~1.3.0", + "orbit-db-counterstore": "~1.3.1", + "orbit-db-docstore": "~1.3.1", + "orbit-db-eventstore": "~1.3.1", + "orbit-db-feedstore": "~1.3.1", "orbit-db-keystore": "~0.1.0", - "orbit-db-kvstore": "~1.3.0", + "orbit-db-kvstore": "~1.3.1", "orbit-db-pubsub": "~0.5.1" }, "devDependencies": { @@ -32,7 +32,7 @@ "babel-polyfill": "^6.26.0", "babel-preset-es2015": "^6.24.1", "datastore-level": "~0.7.0", - "go-ipfs-dep": "^0.4.13", + "go-ipfs-dep": "~0.4.13", "ipfs": "~0.28.2", "ipfs-repo": "~0.18.7", "ipfsd-ctl": "~0.30.3", diff --git a/test/persistency.js b/test/persistency.js index db9d39a..3b5be95 100644 --- a/test/persistency.js +++ b/test/persistency.js @@ -132,14 +132,18 @@ Object.keys(testAPIs).forEach(API => { db = await orbitdb1.eventlog(address) return new Promise(async (resolve, reject) => { let count = 0 - db.events.on('load.progress', (address, hash, entry, progress, total) => { + db.events.on('load.progress', (address, hash, entry) => { count ++ try { assert.equal(address, db.address.toString()) - assert.equal(total, entryCount) + + const { progress, max } = db.replicationStatus + assert.equal(max, entryCount) assert.equal(progress, count) + assert.notEqual(hash, null) assert.notEqual(entry, null) + if (progress === entryCount && count === entryCount) { setTimeout(() => { resolve() @@ -246,12 +250,15 @@ Object.keys(testAPIs).forEach(API => { db = await orbitdb1.eventlog(address) return new Promise(async (resolve, reject) => { let count = 0 - db.events.on('load.progress', (address, hash, entry, progress, total) => { + db.events.on('load.progress', (address, hash, entry) => { count ++ try { assert.equal(address, db.address.toString()) - assert.equal(total, entryCount) + + const { progress, max } = db.replicationStatus + assert.equal(max, entryCount) assert.equal(progress, count) + assert.notEqual(hash, null) assert.notEqual(entry, null) if (progress === entryCount && count === entryCount) { diff --git a/test/replicate.test.js b/test/replicate.test.js index 739b9b0..ce62585 100644 --- a/test/replicate.test.js +++ b/test/replicate.test.js @@ -172,9 +172,9 @@ Object.keys(testAPIs).forEach(API => { count: eventCount['replicate.progress'], entry: entry , replicationInfo: { - max: db2._replicationInfo.max, - progress: db2._replicationInfo.progress, - have: db2._replicationInfo.have, + max: db2.replicationStatus.max, + progress: db2.replicationStatus.progress, + have: db2.replicationStatus.have, }, }) }) @@ -185,9 +185,9 @@ Object.keys(testAPIs).forEach(API => { event: 'replicated', count: eventCount['replicate'], replicationInfo: { - max: db2._replicationInfo.max, - progress: db2._replicationInfo.progress, - have: db2._replicationInfo.have, + max: db2.replicationStatus.max, + progress: db2.replicationStatus.progress, + have: db2.replicationStatus.have, }, }) // Resolve with a little timeout to make sure we @@ -279,7 +279,7 @@ Object.keys(testAPIs).forEach(API => { db2.events.on('replicate', (address, entry) => { eventCount['replicate'] ++ - total = db2._replicationInfo.max + total = db2.replicationStatus.max // console.log("[replicate] ", '#' + eventCount['replicate'] + ':', current, '/', total, '| Tasks (in/queued/running/out):', db2._loader.tasksRequested, '/', db2._loader.tasksQueued, '/', db2._loader.tasksRunning, '/', db2._loader.tasksFinished) events.push({ event: 'replicate', @@ -290,24 +290,24 @@ Object.keys(testAPIs).forEach(API => { db2.events.on('replicate.progress', (address, hash, entry) => { eventCount['replicate.progress'] ++ - current = db2._replicationInfo.progress + current = db2.replicationStatus.progress // console.log("[progress] ", '#' + eventCount['replicate.progress'] + ':', current, '/', total, '| Tasks (in/queued/running/out):', db2._loader.tasksRequested, '/', db2._loader.tasksQueued, '/', db2._loader.tasksRunning, '/', db2._loader.tasksFinished) - // assert.equal(db2._replicationInfo.progress, eventCount['replicate.progress']) + // assert.equal(db2.replicationStatus.progress, eventCount['replicate.progress']) events.push({ event: 'replicate.progress', count: eventCount['replicate.progress'], entry: entry , replicationInfo: { - max: db2._replicationInfo.max, - progress: db2._replicationInfo.progress, - have: db2._replicationInfo.have, + max: db2.replicationStatus.max, + progress: db2.replicationStatus.progress, + have: db2.replicationStatus.have, }, }) }) db2.events.on('replicated', (address, length) => { eventCount['replicated'] += length - current = db2._replicationInfo.progress + current = db2.replicationStatus.progress // console.log("[replicated]", '#' + eventCount['replicated'] + ':', current, '/', total, '| Tasks (in/queued/running/out):', db2._loader.tasksRequested, '/', db2._loader.tasksQueued, '/', db2._loader.tasksRunning, '/', db2._loader.tasksFinished, "|", db2._loader._stats.a, db2._loader._stats.b, db2._loader._stats.c, db2._loader._stats.d) assert.equal(current, eventCount['replicated']) assert.equal(total, expectedEventCount) @@ -323,9 +323,9 @@ Object.keys(testAPIs).forEach(API => { event: 'replicated', count: eventCount['replicate'], replicationInfo: { - max: db2._replicationInfo.max, - progress: db2._replicationInfo.progress, - have: db2._replicationInfo.have, + max: db2.replicationStatus.max, + progress: db2.replicationStatus.progress, + have: db2.replicationStatus.have, }, }) // Resolve with a little timeout to make sure we @@ -419,8 +419,8 @@ Object.keys(testAPIs).forEach(API => { db2.events.on('replicate', (address, entry) => { eventCount['replicate'] ++ - current = db2._replicationInfo.progress - total = db2._replicationInfo.max + current = db2.replicationStatus.progress + total = db2.replicationStatus.max // console.log("[replicate] ", '#' + eventCount['replicate'] + ':', current, '/', total, '| Tasks (in/queued/running/out):', db2._loader.tasksRequested, '/', db2._loader.tasksQueued, '/', db2._loader.tasksRunning, '/', db2._loader.tasksFinished) events.push({ event: 'replicate', @@ -432,8 +432,8 @@ Object.keys(testAPIs).forEach(API => { let prevProgress = 0 db2.events.on('replicate.progress', (address, hash, entry) => { eventCount['replicate.progress'] ++ - current = db2._replicationInfo.progress - total = db2._replicationInfo.max + current = db2.replicationStatus.progress + total = db2.replicationStatus.max // console.log("[progress] ", '#' + eventCount['replicate.progress'] + ':', current, '/', total, '| Tasks (in/queued/running/out):', db2._loader.tasksRequested, '/', db2._loader.tasksQueued, '/', db2._loader.tasksRunning, '/', db2._loader.tasksFinished) // assert.equal(current, total) events.push({ @@ -441,17 +441,17 @@ Object.keys(testAPIs).forEach(API => { count: eventCount['replicate.progress'], entry: entry , replicationInfo: { - max: db2._replicationInfo.max, - progress: db2._replicationInfo.progress, - have: db2._replicationInfo.have, + max: db2.replicationStatus.max, + progress: db2.replicationStatus.progress, + have: db2.replicationStatus.have, }, }) }) db2.events.on('replicated', (address, length) => { eventCount['replicated'] += length - current = db2._replicationInfo.progress - total = db2._replicationInfo.max + current = db2.replicationStatus.progress + total = db2.replicationStatus.max const values = db2.iterator({limit: -1}).collect() // console.log(current, "/", total, "/", values.length) // console.log("[replicated]", '#' + eventCount['replicated'] + ':', current, '/', total, '| Tasks (in/queued/running/out):', db2._loader.tasksRequested, '/', db2._loader.tasksQueued, '/', db2._loader.tasksRunning, '/', db2._loader.tasksFinished, "|", db2._loader._stats.a, db2._loader._stats.b, db2._loader._stats.c, db2._loader._stats.d) @@ -460,14 +460,14 @@ Object.keys(testAPIs).forEach(API => { event: 'replicated', count: eventCount['replicate'], replicationInfo: { - max: db2._replicationInfo.max, - progress: db2._replicationInfo.progress, - have: db2._replicationInfo.have, + max: db2.replicationStatus.max, + progress: db2.replicationStatus.progress, + have: db2.replicationStatus.have, }, }) - if (db2._replicationInfo.max >= expectedEventCount * 2 - && db2._replicationInfo.progress >= expectedEventCount * 2) + if (db2.replicationStatus.max >= expectedEventCount * 2 + && db2.replicationStatus.progress >= expectedEventCount * 2) finished = true }) diff --git a/test/replication-status.test.js b/test/replication-status.test.js new file mode 100644 index 0000000..8fde424 --- /dev/null +++ b/test/replication-status.test.js @@ -0,0 +1,103 @@ +'use strict' + +const assert = require('assert') +const mapSeries = require('p-map-series') +const fs = require('fs') +const path = require('path') +const rmrf = require('rimraf') +const levelup = require('levelup') +const leveldown = require('leveldown') +const OrbitDB = require('../src/OrbitDB') +const OrbitDBAddress = require('../src/orbit-db-address') + +// Include test utilities +const { + config, + startIpfs, + stopIpfs, + testAPIs, +} = require('./utils') + +const dbPath1 = './orbitdb/tests/create-open/1' +const dbPath2 = './orbitdb/tests/create-open/2' +const ipfsPath = './orbitdb/tests/create-open/ipfs' + +Object.keys(testAPIs).forEach(API => { + describe(`orbit-db - Load (${API})`, function() { + this.timeout(config.timeout) + + let ipfsd, ipfs, orbitdb1, orbitdb2, db, address + let localDataPath + + before(async () => { + config.daemon1.repo = ipfsPath + rmrf.sync(config.daemon1.repo) + rmrf.sync(dbPath1) + rmrf.sync(dbPath2) + ipfsd = await startIpfs(API, config.daemon1) + ipfs = ipfsd.api + orbitdb1 = new OrbitDB(ipfs, dbPath1) + orbitdb2 = new OrbitDB(ipfs, dbPath2) + }) + + after(async () => { + if(orbitdb1) + await orbitdb1.stop() + + if(orbitdb2) + await orbitdb2.stop() + + if (ipfsd) + await stopIpfs(ipfsd) + }) + + describe('Replication Status', function() { + before(async () => { + db = await orbitdb1.log('replication status tests') + }) + + it('has correct initial state', async () => { + assert.deepEqual(db.replicationStatus, { buffered: 0, queued: 0, progress: 0, max: 0 }) + }) + + it('has correct replication info after load', async () => { + await db.add('hello') + await db.close() + await db.load() + assert.deepEqual(db.replicationStatus, { buffered: 0, queued: 0, progress: 1, max: 1 }) + }) + + it('has correct replication info after close', async () => { + await db.close() + assert.deepEqual(db.replicationStatus, { buffered: 0, queued: 0, progress: 0, max: 0 }) + }) + + it('has correct replication info after sync', async () => { + await db.load() + await db.add('hello2') + assert.deepEqual(db.replicationStatus, { buffered: 0, queued: 0, progress: 2, max: 2 }) + + const db2 = await orbitdb2.log(db.address.toString(), { create: false, sync: false }) + await db2.sync(db._oplog.heads) + + return new Promise((resolve, reject) => { + setTimeout(() => { + try { + assert.deepEqual(db2.replicationStatus, { buffered: 0, queued: 0, progress: 2, max: 2 }) + resolve() + } catch (e) { + reject(e) + } + }, 100) + }) + }) + + it('has correct replication info after loading from snapshot', async () => { + await db.saveSnapshot() + await db.close() + await db.loadFromSnapshot() + assert.deepEqual(db.replicationStatus, { buffered: 0, queued: 0, progress: 2, max: 2 }) + }) + }) + }) +})