From 936a7ad3b5b370154e20b8b952fa59d0d3258127 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Fri, 7 Oct 2022 16:52:31 +0200 Subject: [PATCH 1/6] Import tangle-prune test --- test/tangle-prune.test.js | 117 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 test/tangle-prune.test.js diff --git a/test/tangle-prune.test.js b/test/tangle-prune.test.js new file mode 100644 index 0000000..16b50ed --- /dev/null +++ b/test/tangle-prune.test.js @@ -0,0 +1,117 @@ +const test = require('tape') +const { promisify: p } = require('util') +const { Server } = require('../helpers') +const { tanglePrune } = require('../../lib') + +const chars = 'abcABC123=+? '.split('') +const randomChar = () => chars.sort(() => (Math.random() < 0.5 ? -1 : +1))[0] +const randomText = (length) => { + let output = '' + while (output.length < length) output += randomChar() + return output +} + +test('lib/tangle-prune', async (t) => { + const ssb = Server() + + const { groupId } = await p(ssb.tribes.create)({}) + + const publishSize = async (size, recpCount = 1) => { + const content = { + type: 'post', + text: randomText(size), + recps: [groupId, ...new Array(recpCount - 1).fill(ssb.id)], + } + + return new Promise((resolve, reject) => { + ssb.publish(content, (err, msg) => { + if (err) return resolve(false) + + ssb.get({ id: msg.key, private: true }, (err, msgVal) => { + if (err) return reject(err) + const plainLength = JSON.stringify(msgVal.content).length + resolve(plainLength) + }) + }) + }) + } + + async function findMaxSize(numberRecps = 1) { + // Apply bisection method to find max size of a message which can be published + + let lower = 4000 + let mid + let upper = 8000 + + const results = new Map([]) + + // let i = 0 + while (upper - lower > 1) { + mid = Math.ceil((lower + upper) / 2) + + if (!results.has(lower)) { + const res = + results.get(lower) || (await publishSize(lower, numberRecps)) + results.set(lower, res) + } + + if (!results.has(mid)) { + const res = results.get(mid) || (await publishSize(mid, numberRecps)) + results.set(mid, res) + } + if (!results.has(upper)) { + const res = + results.get(upper) || (await publishSize(upper, numberRecps)) + results.set(upper, res) + } + + // console.log(i++, { + // [lower]: results.get(lower), + // [mid]: results.get(mid), + // [upper]: results.get(upper) + // }) + + if (Boolean(results.get(lower)) !== Boolean(results.get(mid))) upper = mid + else if (Boolean(results.get(mid)) !== Boolean(results.get(upper))) + lower = mid + else throw new Error('bisection fail') + } + + const result = results.get(upper) || results.get(mid) || results.get(lower) + t.pass(`max stringied content size for ${numberRecps} recps: ${result}`) + } + // 16 recps: 5318 + // 1 recps: 5799 + await findMaxSize(16) // 5320 + await findMaxSize(1) // 5800 + ssb.close() + + const msgId = '%RDORgMCjmL6vs51nR4bn0LWNe6wkBfbRJulSdOJsmwg=.sha256' + const content = (prevCount) => ({ + type: 'post', + text: 'hello!', + recps: ['A'], + tangles: { + group: { + root: msgId, + previous: new Array(prevCount).fill(msgId), + }, + }, + }) + + // console.time('prune') + let result = tanglePrune(content(4000), 'group', 5320) + // console.timeEnd('prune') + t.true( + JSON.stringify(result).length <= 5320, + `pruned ${4000 - result.tangles.group.previous.length}` + ) + + result = tanglePrune(content(4000)) + t.true( + JSON.stringify(result).length <= 5800, + `pruned ${4000 - result.tangles.group.previous.length}` + ) + + t.end() +}) From 921d0d8556ed1cd5ba7f7006e95f05c92840fde7 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Fri, 7 Oct 2022 17:01:46 +0200 Subject: [PATCH 2/6] Move tanglePrune to own file --- lib/add-group-tangle.js | 29 ----------------------------- lib/tangle-prune.js | 32 ++++++++++++++++++++++++++++++++ test/tangle-prune.test.js | 12 ++++++++---- 3 files changed, 40 insertions(+), 33 deletions(-) create mode 100644 lib/tangle-prune.js diff --git a/lib/add-group-tangle.js b/lib/add-group-tangle.js index 35c00a1..b3e50a3 100644 --- a/lib/add-group-tangle.js +++ b/lib/add-group-tangle.js @@ -33,32 +33,3 @@ module.exports = function AddGroupTangle(server) { }) } } - -/* eslint-disable camelcase */ -const MAX_SIZE_16_recps = 5320 -const MAX_SIZE_1_recps = 5800 - -function tanglePrune(content, tangle = 'group', maxSize) { - maxSize = - maxSize || (content.recps > 1 ? MAX_SIZE_16_recps : MAX_SIZE_1_recps) - if (getLength(content) <= maxSize) return content - - content.tangles[tangle].previous = content.tangles[tangle].previous.sort(() => - Math.random() < 0.5 ? -1 : +1 - ) - // we shuffle so that if multiple peers are also trying to converge, - // we hopefully tangle differently and converge faster - - while ( - content.tangles[tangle].previous.length && - getLength(content) > maxSize - ) { - content.tangles[tangle].previous.pop() - } - - return content -} - -function getLength(obj) { - return JSON.stringify(obj).length -} diff --git a/lib/tangle-prune.js b/lib/tangle-prune.js new file mode 100644 index 0000000..8cbcccf --- /dev/null +++ b/lib/tangle-prune.js @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: 2022 Mix Irving +// +// SPDX-License-Identifier: LGPL-3.0-only + +/* eslint-disable camelcase */ +const MAX_SIZE_16_recps = 5320 +const MAX_SIZE_1_recps = 5800 + +module.exports = function tanglePrune(content, tangle = 'group', maxSize) { + maxSize = + maxSize || (content.recps > 1 ? MAX_SIZE_16_recps : MAX_SIZE_1_recps) + if (getLength(content) <= maxSize) return content + + content.tangles[tangle].previous = content.tangles[tangle].previous.sort(() => + Math.random() < 0.5 ? -1 : +1 + ) + // we shuffle so that if multiple peers are also trying to converge, + // we hopefully tangle differently and converge faster + + while ( + content.tangles[tangle].previous.length && + getLength(content) > maxSize + ) { + content.tangles[tangle].previous.pop() + } + + return content +} + +function getLength(obj) { + return JSON.stringify(obj).length +} diff --git a/test/tangle-prune.test.js b/test/tangle-prune.test.js index 16b50ed..276ccb7 100644 --- a/test/tangle-prune.test.js +++ b/test/tangle-prune.test.js @@ -1,7 +1,11 @@ +// SPDX-FileCopyrightText: 2022 Mix Irving +// +// SPDX-License-Identifier: LGPL-3.0-only + const test = require('tape') const { promisify: p } = require('util') -const { Server } = require('../helpers') -const { tanglePrune } = require('../../lib') +const Testbot = require('./helpers/testbot') +const tanglePrune = require('../lib/tangle-prune') const chars = 'abcABC123=+? '.split('') const randomChar = () => chars.sort(() => (Math.random() < 0.5 ? -1 : +1))[0] @@ -11,8 +15,8 @@ const randomText = (length) => { return output } -test('lib/tangle-prune', async (t) => { - const ssb = Server() +test.only('lib/tangle-prune', async (t) => { + const ssb = Testbot() const { groupId } = await p(ssb.tribes.create)({}) From 5aad75d6dcb05bfbe34a8910b24bd5338455118e Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Sun, 9 Oct 2022 22:42:39 +0200 Subject: [PATCH 3/6] The tangle prune is broken --- .eslintrc.js | 2 +- lib/tangle-prune.js | 2 ++ test/tangle-prune.test.js | 51 ++++++++++++++++++++++++--------------- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9de9007..ea72eac 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,7 +13,7 @@ module.exports = { SharedArrayBuffer: 'readonly', }, parserOptions: { - ecmaVersion: 2018, + ecmaVersion: 2019, sourceType: 'module', }, rules: {}, diff --git a/lib/tangle-prune.js b/lib/tangle-prune.js index 8cbcccf..e49accd 100644 --- a/lib/tangle-prune.js +++ b/lib/tangle-prune.js @@ -28,5 +28,7 @@ module.exports = function tanglePrune(content, tangle = 'group', maxSize) { } function getLength(obj) { + //TODO: adapt depending on feed encoding. classic is json.stringify. buttwoo might be + // https://github.com/ssbc/bipf#encodinglengthvalue--length return JSON.stringify(obj).length } diff --git a/test/tangle-prune.test.js b/test/tangle-prune.test.js index 276ccb7..41b3435 100644 --- a/test/tangle-prune.test.js +++ b/test/tangle-prune.test.js @@ -15,28 +15,35 @@ const randomText = (length) => { return output } -test.only('lib/tangle-prune', async (t) => { +test.only('tangle prune', async (t) => { const ssb = Testbot() - const { groupId } = await p(ssb.tribes.create)({}) + const group = await ssb.tribes2.create() const publishSize = async (size, recpCount = 1) => { const content = { type: 'post', text: randomText(size), - recps: [groupId, ...new Array(recpCount - 1).fill(ssb.id)], + recps: [group.id, ...new Array(recpCount - 1).fill(ssb.id)], } return new Promise((resolve, reject) => { - ssb.publish(content, (err, msg) => { - if (err) return resolve(false) - - ssb.get({ id: msg.key, private: true }, (err, msgVal) => { - if (err) return reject(err) - const plainLength = JSON.stringify(msgVal.content).length - resolve(plainLength) + try { + console.log('about to publish size', size) + ssb.tribes2.publish(content, (err, msg) => { + console.log('after publish') + if (err) return resolve(false) + + ssb.db.get(msg.key, (err, msgVal) => { + if (err) return reject(err) + const plainLength = JSON.stringify(msgVal.content).length + resolve(plainLength) + }) }) - }) + } catch { + console.log('caught crash') + return resolve(false) + } }) } @@ -45,13 +52,14 @@ test.only('lib/tangle-prune', async (t) => { let lower = 4000 let mid - let upper = 8000 + let upper = 10000 //8000 const results = new Map([]) - // let i = 0 + let i = 0 while (upper - lower > 1) { mid = Math.ceil((lower + upper) / 2) + console.log({ i, lower, upper }) if (!results.has(lower)) { const res = @@ -69,11 +77,11 @@ test.only('lib/tangle-prune', async (t) => { results.set(upper, res) } - // console.log(i++, { - // [lower]: results.get(lower), - // [mid]: results.get(mid), - // [upper]: results.get(upper) - // }) + console.log(i++, { + [lower]: results.get(lower), + [mid]: results.get(mid), + [upper]: results.get(upper), + }) if (Boolean(results.get(lower)) !== Boolean(results.get(mid))) upper = mid else if (Boolean(results.get(mid)) !== Boolean(results.get(upper))) @@ -84,12 +92,15 @@ test.only('lib/tangle-prune', async (t) => { const result = results.get(upper) || results.get(mid) || results.get(lower) t.pass(`max stringied content size for ${numberRecps} recps: ${result}`) } + console.log('about to find max size') // 16 recps: 5318 // 1 recps: 5799 - await findMaxSize(16) // 5320 - await findMaxSize(1) // 5800 + await findMaxSize(16).catch(t.error) // 5320 + await findMaxSize(1).catch(t.error) // 5800 ssb.close() + console.log('found max size') + const msgId = '%RDORgMCjmL6vs51nR4bn0LWNe6wkBfbRJulSdOJsmwg=.sha256' const content = (prevCount) => ({ type: 'post', From ff6905b7638220073f8c292cee648d8e99cc8a49 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Tue, 11 Oct 2022 15:26:34 +0200 Subject: [PATCH 4/6] Use bipf instead of json.stringify --- lib/tangle-prune.js | 13 ++++++++----- package.json | 1 + test/tangle-prune.test.js | 9 ++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/tangle-prune.js b/lib/tangle-prune.js index e49accd..2925ea6 100644 --- a/lib/tangle-prune.js +++ b/lib/tangle-prune.js @@ -2,9 +2,12 @@ // // SPDX-License-Identifier: LGPL-3.0-only +const bipf = require('bipf') + /* eslint-disable camelcase */ -const MAX_SIZE_16_recps = 5320 -const MAX_SIZE_1_recps = 5800 +// classic +//const MAX_SIZE_16_recps = 5320 +//const MAX_SIZE_1_recps = 5800 module.exports = function tanglePrune(content, tangle = 'group', maxSize) { maxSize = @@ -28,7 +31,7 @@ module.exports = function tanglePrune(content, tangle = 'group', maxSize) { } function getLength(obj) { - //TODO: adapt depending on feed encoding. classic is json.stringify. buttwoo might be - // https://github.com/ssbc/bipf#encodinglengthvalue--length - return JSON.stringify(obj).length + // stringify if on classic + //return JSON.stringify(obj).length + return bipf.encodingLength(obj) } diff --git a/package.json b/package.json index e59ccbf..2a064d9 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "*.js" ], "dependencies": { + "bipf": "^1.9.0", "envelope-js": "^1.3.2", "envelope-spec": "^1.1.0", "lodash.get": "^4.4.2", diff --git a/test/tangle-prune.test.js b/test/tangle-prune.test.js index 41b3435..9d0880b 100644 --- a/test/tangle-prune.test.js +++ b/test/tangle-prune.test.js @@ -4,10 +4,13 @@ const test = require('tape') const { promisify: p } = require('util') +const bipf = require('bipf') const Testbot = require('./helpers/testbot') const tanglePrune = require('../lib/tangle-prune') const chars = 'abcABC123=+? '.split('') +//const encodedLength = (obj) => JSON.stringify(msgVal.content).length +const encodedLength = (obj) => bipf.encodingLength(obj) const randomChar = () => chars.sort(() => (Math.random() < 0.5 ? -1 : +1))[0] const randomText = (length) => { let output = '' @@ -36,7 +39,7 @@ test.only('tangle prune', async (t) => { ssb.db.get(msg.key, (err, msgVal) => { if (err) return reject(err) - const plainLength = JSON.stringify(msgVal.content).length + const plainLength = encodedLength(msgVal.content) resolve(plainLength) }) }) @@ -118,13 +121,13 @@ test.only('tangle prune', async (t) => { let result = tanglePrune(content(4000), 'group', 5320) // console.timeEnd('prune') t.true( - JSON.stringify(result).length <= 5320, + encodedLength(result) <= 5320, `pruned ${4000 - result.tangles.group.previous.length}` ) result = tanglePrune(content(4000)) t.true( - JSON.stringify(result).length <= 5800, + encodedLength(result) <= 5800, `pruned ${4000 - result.tangles.group.previous.length}` ) From b618a948c3859d732c21e6f80f629378e13c3019 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Wed, 12 Oct 2022 14:33:53 +0200 Subject: [PATCH 5/6] Get content size calculation to work --- lib/tangle-prune.js | 17 ++++++---- package.json | 2 +- test/tangle-prune.test.js | 66 ++++++++++++++++----------------------- 3 files changed, 39 insertions(+), 46 deletions(-) diff --git a/lib/tangle-prune.js b/lib/tangle-prune.js index 2925ea6..aed2d03 100644 --- a/lib/tangle-prune.js +++ b/lib/tangle-prune.js @@ -5,13 +5,18 @@ const bipf = require('bipf') /* eslint-disable camelcase */ -// classic -//const MAX_SIZE_16_recps = 5320 -//const MAX_SIZE_1_recps = 5800 +// these variables are calculated in +// test/tangle-prune.test.js +// if these variables are out of date and +// * smaller than supposed to: we'll prune a bit much, tangles will converge a bit slower +// * bigger than supposed to: we'll prune less than we can. users might run into 'the message you want to publish is too big' more often +// but either way no catastrophe +const MAX_SIZE_16_recps = 5546 +const MAX_SIZE_1_recps = 6041 -module.exports = function tanglePrune(content, tangle = 'group', maxSize) { - maxSize = - maxSize || (content.recps > 1 ? MAX_SIZE_16_recps : MAX_SIZE_1_recps) +module.exports = function tanglePrune(content) { + const tangle = 'group' + const maxSize = content.recps > 1 ? MAX_SIZE_16_recps : MAX_SIZE_1_recps if (getLength(content) <= maxSize) return content content.tangles[tangle].previous = content.tangles[tangle].previous.sort(() => diff --git a/package.json b/package.json index 2a064d9..31ba8c0 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "pretty-quick": "^3.1.3", "secret-stack": "^6.4.1", "ssb-caps": "^1.1.0", - "ssb-db2": "^6.2.0", + "ssb-db2": "^6.2.3", "ssb-ebt": "^9.1.0", "tap-arc": "^0.3.4", "tape": "^5.5.3" diff --git a/test/tangle-prune.test.js b/test/tangle-prune.test.js index 9d0880b..6e0c876 100644 --- a/test/tangle-prune.test.js +++ b/test/tangle-prune.test.js @@ -20,6 +20,7 @@ const randomText = (length) => { test.only('tangle prune', async (t) => { const ssb = Testbot() + const ssbId = ssb.id const group = await ssb.tribes2.create() @@ -27,26 +28,19 @@ test.only('tangle prune', async (t) => { const content = { type: 'post', text: randomText(size), - recps: [group.id, ...new Array(recpCount - 1).fill(ssb.id)], + recps: [group.id, ...new Array(recpCount - 1).fill(ssbId)], } return new Promise((resolve, reject) => { - try { - console.log('about to publish size', size) - ssb.tribes2.publish(content, (err, msg) => { - console.log('after publish') - if (err) return resolve(false) - - ssb.db.get(msg.key, (err, msgVal) => { - if (err) return reject(err) - const plainLength = encodedLength(msgVal.content) - resolve(plainLength) - }) + ssb.tribes2.publish(content, (err, msg) => { + if (err) return resolve(false) + + ssb.db.get(msg.key, (err, msgVal) => { + if (err) return reject(err) + const plainLength = encodedLength(msgVal.content) + resolve(plainLength) }) - } catch { - console.log('caught crash') - return resolve(false) - } + }) }) } @@ -55,14 +49,13 @@ test.only('tangle prune', async (t) => { let lower = 4000 let mid - let upper = 10000 //8000 + let upper = 8000 const results = new Map([]) - let i = 0 + //let i = 0 while (upper - lower > 1) { mid = Math.ceil((lower + upper) / 2) - console.log({ i, lower, upper }) if (!results.has(lower)) { const res = @@ -80,11 +73,11 @@ test.only('tangle prune', async (t) => { results.set(upper, res) } - console.log(i++, { - [lower]: results.get(lower), - [mid]: results.get(mid), - [upper]: results.get(upper), - }) + //console.log(i++, { + // [lower]: results.get(lower), + // [mid]: results.get(mid), + // [upper]: results.get(upper), + //}) if (Boolean(results.get(lower)) !== Boolean(results.get(mid))) upper = mid else if (Boolean(results.get(mid)) !== Boolean(results.get(upper))) @@ -95,20 +88,15 @@ test.only('tangle prune', async (t) => { const result = results.get(upper) || results.get(mid) || results.get(lower) t.pass(`max stringied content size for ${numberRecps} recps: ${result}`) } - console.log('about to find max size') - // 16 recps: 5318 - // 1 recps: 5799 - await findMaxSize(16).catch(t.error) // 5320 - await findMaxSize(1).catch(t.error) // 5800 + const max16recps = await findMaxSize(16).catch(t.error) // 5546 + const max1recp = await findMaxSize(1).catch(t.error) // 6041 ssb.close() - console.log('found max size') - const msgId = '%RDORgMCjmL6vs51nR4bn0LWNe6wkBfbRJulSdOJsmwg=.sha256' - const content = (prevCount) => ({ + const content = (prevCount, numRecps) => ({ type: 'post', text: 'hello!', - recps: ['A'], + recps: [...new Array(numRecps).fill(ssbId)], tangles: { group: { root: msgId, @@ -118,17 +106,17 @@ test.only('tangle prune', async (t) => { }) // console.time('prune') - let result = tanglePrune(content(4000), 'group', 5320) + const result16 = tanglePrune(content(4000, 16), 'group') // console.timeEnd('prune') t.true( - encodedLength(result) <= 5320, - `pruned ${4000 - result.tangles.group.previous.length}` + encodedLength(result16) <= max16recps, + `pruned ${4000 - result16.tangles.group.previous.length}` ) - result = tanglePrune(content(4000)) + const result1 = tanglePrune(content(4000, 1)) t.true( - encodedLength(result) <= 5800, - `pruned ${4000 - result.tangles.group.previous.length}` + encodedLength(result1) <= max1recp, + `pruned ${4000 - result1.tangles.group.previous.length}` ) t.end() From 8077af0f4003fd6bb435754df646063a5d6e755a Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Wed, 12 Oct 2022 15:44:53 +0200 Subject: [PATCH 6/6] Make tanglePrune work --- lib/add-group-tangle.js | 4 ++-- lib/tangle-prune.js | 5 ++--- test/tangle-prune.test.js | 13 ++++++------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/add-group-tangle.js b/lib/add-group-tangle.js index b3e50a3..cdb36fb 100644 --- a/lib/add-group-tangle.js +++ b/lib/add-group-tangle.js @@ -5,6 +5,7 @@ const { isCloakedMsg } = require('ssb-ref') const set = require('lodash.set') const GetGroupTangle = require('./get-group-tangle') +const tanglePrune = require('./tangle-prune') module.exports = function AddGroupTangle(server) { const getGroupTangle = GetGroupTangle(server) @@ -26,8 +27,7 @@ module.exports = function AddGroupTangle(server) { if (err) return cb(null, content) set(content, 'tangles.group', tangle) - //TODO: uncomment - //tanglePrune(content) // prune the group tangle down if needed + tanglePrune(content) // prune the group tangle down if needed cb(null, content) }) diff --git a/lib/tangle-prune.js b/lib/tangle-prune.js index aed2d03..d183c99 100644 --- a/lib/tangle-prune.js +++ b/lib/tangle-prune.js @@ -16,7 +16,8 @@ const MAX_SIZE_1_recps = 6041 module.exports = function tanglePrune(content) { const tangle = 'group' - const maxSize = content.recps > 1 ? MAX_SIZE_16_recps : MAX_SIZE_1_recps + const maxSize = + content.recps.length > 1 ? MAX_SIZE_16_recps : MAX_SIZE_1_recps if (getLength(content) <= maxSize) return content content.tangles[tangle].previous = content.tangles[tangle].previous.sort(() => @@ -36,7 +37,5 @@ module.exports = function tanglePrune(content) { } function getLength(obj) { - // stringify if on classic - //return JSON.stringify(obj).length return bipf.encodingLength(obj) } diff --git a/test/tangle-prune.test.js b/test/tangle-prune.test.js index 6e0c876..4d51601 100644 --- a/test/tangle-prune.test.js +++ b/test/tangle-prune.test.js @@ -3,13 +3,11 @@ // SPDX-License-Identifier: LGPL-3.0-only const test = require('tape') -const { promisify: p } = require('util') const bipf = require('bipf') const Testbot = require('./helpers/testbot') const tanglePrune = require('../lib/tangle-prune') const chars = 'abcABC123=+? '.split('') -//const encodedLength = (obj) => JSON.stringify(msgVal.content).length const encodedLength = (obj) => bipf.encodingLength(obj) const randomChar = () => chars.sort(() => (Math.random() < 0.5 ? -1 : +1))[0] const randomText = (length) => { @@ -18,7 +16,7 @@ const randomText = (length) => { return output } -test.only('tangle prune', async (t) => { +test('tangle prune', async (t) => { const ssb = Testbot() const ssbId = ssb.id @@ -87,6 +85,7 @@ test.only('tangle prune', async (t) => { const result = results.get(upper) || results.get(mid) || results.get(lower) t.pass(`max stringied content size for ${numberRecps} recps: ${result}`) + return result } const max16recps = await findMaxSize(16).catch(t.error) // 5546 const max1recp = await findMaxSize(1).catch(t.error) // 6041 @@ -96,7 +95,7 @@ test.only('tangle prune', async (t) => { const content = (prevCount, numRecps) => ({ type: 'post', text: 'hello!', - recps: [...new Array(numRecps).fill(ssbId)], + recps: new Array(numRecps).fill(ssbId), tangles: { group: { root: msgId, @@ -105,9 +104,9 @@ test.only('tangle prune', async (t) => { }, }) - // console.time('prune') - const result16 = tanglePrune(content(4000, 16), 'group') - // console.timeEnd('prune') + //console.time('prune') + const result16 = tanglePrune(content(4000, 16)) + //console.timeEnd('prune') t.true( encodedLength(result16) <= max16recps, `pruned ${4000 - result16.tangles.group.previous.length}`