diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 23cdeaa8..f34a0361 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -14,13 +14,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [12.x, 16.x, 18.x] + node-version: [12, 16, 18] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: npm ci @@ -34,13 +34,13 @@ jobs: runs-on: macos-latest strategy: matrix: - node-version: [16.x, 18.x] + node-version: [16, 18] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: npm ci @@ -50,13 +50,13 @@ jobs: runs-on: windows-latest strategy: matrix: - node-version: [16.x, 18.x] + node-version: [16, 18] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: npm ci diff --git a/index.js b/index.js index 56dc3a9e..93c9a50d 100644 --- a/index.js +++ b/index.js @@ -94,23 +94,22 @@ function init (ssb, config) { const processedNewAuthors = {} function processAuthors (groupId, authors, adder, cb) { - if (processedNewAuthors[groupId] === undefined) processedNewAuthors[groupId] = new Set([]) - - const newAuthors = new Set(authors.filter(author => !processedNewAuthors[groupId].has(author))) - - processedNewAuthors[groupId] = new Set([...processedNewAuthors[groupId], ...newAuthors]) - - if ([...newAuthors].length) { - state.newAuthorListeners.forEach(fn => fn({ groupId, newAuthors: [...newAuthors] })) - - // we don't rebuild if we're the person who added them - if (adder !== ssb.id) { - const reason = ['add-member', ...newAuthors].join() - - rebuildManager.rebuild(reason) - } + if (processedNewAuthors[groupId] === undefined) processedNewAuthors[groupId] = new Set() + + const newAuthors = authors.reduce((acc, author) => { + if (!processedNewAuthors[groupId].has(author)) acc.add(author) + return acc + }, new Set()) + if (!newAuthors.size) return cb() + + state.newAuthorListeners.forEach(fn => fn({ groupId, newAuthors: [...newAuthors] })) + // we don't rebuild if we're the person who added them + if (adder !== ssb.id) { + const reason = ['add-member', ...newAuthors].join('+') + rebuildManager.rebuild(reason) } - return cb() + newAuthors.forEach(author => processedNewAuthors[groupId].add(author)) + cb() } pull( diff --git a/package-lock.json b/package-lock.json index 83a525a8..6b524c62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "ssb-query": "^2.4.5", "ssb-replicate": "^1.3.3", "standard": "^17.1.0", - "tap-arc": "^0.3.5", + "tap-arc": "^0.4.0", "tape": "^4.16.2" } }, @@ -5723,16 +5723,16 @@ } }, "node_modules/tap-arc": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/tap-arc/-/tap-arc-0.3.5.tgz", - "integrity": "sha512-uGqN8JM+BmBwJhfDwTtGVGyZ0HLxcoPJMzTqBHJjfKS4M6+CcKHS+PFJBhJoGtpBrpeMPBoLyLaP3zb8vsccOA==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/tap-arc/-/tap-arc-0.4.0.tgz", + "integrity": "sha512-dJhy2/IGl2J2qgDeXBThLVlm9p0aTxShkcnaZ1cWpFMKtXqMDDj3umP+8kNUPb1nfnZ2VaHSIhyo1eF8BfGZcA==", "dev": true, "dependencies": { - "json5": "^2.2.1", - "minimist": "^1.2.6", + "json5": "^2.2.3", + "minimist": "^1.2.8", "picocolors": "^1.0.0", "strip-ansi": "6.0.1", - "tap-parser": "^11.0.1", + "tap-parser": "^11.0.2", "tcompare": "^5.0.7", "through2": "^4.0.2" }, @@ -10928,16 +10928,16 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" }, "tap-arc": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/tap-arc/-/tap-arc-0.3.5.tgz", - "integrity": "sha512-uGqN8JM+BmBwJhfDwTtGVGyZ0HLxcoPJMzTqBHJjfKS4M6+CcKHS+PFJBhJoGtpBrpeMPBoLyLaP3zb8vsccOA==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/tap-arc/-/tap-arc-0.4.0.tgz", + "integrity": "sha512-dJhy2/IGl2J2qgDeXBThLVlm9p0aTxShkcnaZ1cWpFMKtXqMDDj3umP+8kNUPb1nfnZ2VaHSIhyo1eF8BfGZcA==", "dev": true, "requires": { - "json5": "^2.2.1", - "minimist": "^1.2.6", + "json5": "^2.2.3", + "minimist": "^1.2.8", "picocolors": "^1.0.0", "strip-ansi": "6.0.1", - "tap-parser": "^11.0.1", + "tap-parser": "^11.0.2", "tcompare": "^5.0.7", "through2": "^4.0.2" } diff --git a/package.json b/package.json index 4c7fd83d..38a7e78a 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,10 @@ "main": "index.js", "scripts": { "test": "npm run test:js && npm run test:only && npm run lint", - "test:js": "NODE_ENV=test tape 'test/**/*.test.js' | tap-arc --bail", + "test:js": "NODE_ENV=test tape 'test/**/*.test.js' | tap-arc", "test:only": "if grep -r --exclude-dir=node_modules --exclude-dir=.git --color 'test\\.only' ; then exit 1; fi", "lint": "standard --fix", - "test:windows": "cross-env NODE_ENV=test tape test/**/*.test.js | tap-arc --bail", + "test:windows": "cross-env NODE_ENV=test tape test/**/*.test.js | tap-arc", "generate": "rm test/generate/*/* && node test/generate/index.js" }, "homepage": "https://github.com/ssbc/ssb-tribes#readme", @@ -52,7 +52,7 @@ "ssb-query": "^2.4.5", "ssb-replicate": "^1.3.3", "standard": "^17.1.0", - "tap-arc": "^0.3.5", + "tap-arc": "^0.4.0", "tape": "^4.16.2" }, "keywords": [ diff --git a/test/unbox.test.js b/test/unbox.test.js index 395b2ad5..9ebaf0cd 100644 --- a/test/unbox.test.js +++ b/test/unbox.test.js @@ -3,9 +3,10 @@ const test = require('tape') const pull = require('pull-stream') const { promisify: p } = require('util') +const { decodeLeaves, Server, Run } = require('./helpers') +const os = require('os') const envelope = require('../envelope') -const { decodeLeaves, Server, Run } = require('./helpers') const vectors = [ require('private-group-spec/vectors/unbox1.json'), @@ -71,7 +72,7 @@ test('unbox', async t => { t.end() }) -test('unbox - test vectors', async t => { +test('unbox - test vectors', { skip: os.platform() === 'win32' }, async t => { console.log('vectors:', vectors.length) vectors.forEach(vector => {