diff --git a/test/delete-feed.js b/test/delete-feed.js index acaf5905..9c5c485d 100644 --- a/test/delete-feed.js +++ b/test/delete-feed.js @@ -13,7 +13,8 @@ const SecretStack = require('secret-stack') const caps = require('ssb-caps') const generateFixture = require('ssb-fixtures') const fs = require('fs') -const { where, author, toPromise } = require('../operators') +const { where, live, author, toPromise, toPullStream } = require('../operators') +const mentions = require('../operators/full-mentions') const dir = '/tmp/ssb-db2-delete-feed-compact' @@ -43,6 +44,7 @@ test('delete a feed and then compact', async (t) => { const keys = ssbKeys.loadOrCreateSync(path.join(dir, 'secret')) const sbot = SecretStack({ appKey: caps.shs }) .use(require('../')) + .use(require('../full-mentions')) .call(null, { keys, path: dir, @@ -61,6 +63,22 @@ test('delete a feed and then compact', async (t) => { ) }) + let gotSpecialMention = false + pull( + sbot.db.query(where(mentions(sbot.id)), live(), toPullStream()), + pull.drain((msg) => { + if (msg.value.content.special) { + if (gotSpecialMention) { + t.fail('got more than one special mention') + } else { + gotSpecialMention = true + } + } else { + t.fail('should not get any live mentions during reindexing') + } + }) + ) + const badPerson = '@a5URnr0bEtVFmNxQu/JwQ5JsfEl+HAPz5ethL+I1CCA=.ed25519' t.notEqual(sbot.id, badPerson, 'I am not the bad person') @@ -96,6 +114,17 @@ test('delete a feed and then compact', async (t) => { const msgsBad2 = await sbot.db.query(where(author(badPerson)), toPromise()) t.equals(msgsBad2.length, 0, 'zero messages by bad person') + await pify(sbot.db.publishAs)(ssbKeys.generate(), { + type: 'post', + text: 'Hi', + special: 'yes', + mentions: [{ link: sbot.id }], + }) + t.pass('published new mention') + + await pify(setTimeout)(1000) + t.true(gotSpecialMention, 'got special mention') + await pify(sbot.close)(true) t.end() })