From 029e893a4e799c6fa8565ce89d3fa2d247ed5bc7 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Fri, 28 Apr 2023 15:22:25 +0300 Subject: [PATCH] make initializeFeed an internal API --- lib/index.js | 1 - test/initializeFeed.test.js | 40 ------------------------------------- 2 files changed, 41 deletions(-) delete mode 100644 test/initializeFeed.test.js diff --git a/lib/index.js b/lib/index.js index c30e1cd..f1ad76d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -365,7 +365,6 @@ exports.init = function initDB(peer, config) { installEncryptionFormat, loaded, add, - initializeFeed, create, getFeedRoot, getRecord, diff --git a/test/initializeFeed.test.js b/test/initializeFeed.test.js deleted file mode 100644 index bf3c959..0000000 --- a/test/initializeFeed.test.js +++ /dev/null @@ -1,40 +0,0 @@ -const test = require('tape') -const path = require('path') -const os = require('os') -const rimraf = require('rimraf') -const SecretStack = require('secret-stack') -const caps = require('ssb-caps') -const p = require('util').promisify -const FeedV1 = require('../lib/feed-v1') -const { generateKeypair } = require('./util') - -const DIR = path.join(os.tmpdir(), 'ppppp-db-initializeFeed') -rimraf.sync(DIR) - -test('initializeFeed()', async (t) => { - const keys = generateKeypair('alice') - const peer = SecretStack({ appKey: caps.shs }) - .use(require('../lib')) - .use(require('ssb-box')) - .call(null, { keys, path: DIR }) - - await peer.db.loaded() - - t.notOk(peer.db.getFeedRoot(keys.id, 'profile'), 'no profile feed') - const rootHash = await p(peer.db.initializeFeed)({ type: 'profile' }) - t.pass('initialized feed') - - const rootMsg = FeedV1.createRoot(keys, 'profile') - t.equals(rootHash, FeedV1.getMsgHash(rootMsg), 'root hash is consistent') - - t.ok(peer.db.getFeedRoot(keys.id, 'profile'), 'has profile feed') - - const rootHash2 = await p(peer.db.initializeFeed)({ type: 'profile' }) - t.pass('initialized feed is idempotent') - - t.equals(rootHash2, FeedV1.getMsgHash(rootMsg), 'root hash is consistent') - - t.ok(peer.db.getFeedRoot(keys.id, 'profile'), 'still has profile feed') - - await p(peer.close)(true) -})