Add realtime test without initial post

This commit is contained in:
Jacob Karlsson 2024-06-28 17:57:54 +02:00
parent f5d6aa7ac0
commit d22a4d106e
1 changed files with 12 additions and 15 deletions

View File

@ -30,8 +30,6 @@ test('create 200 messages that manage to replicate with low "newest" goals', asy
_nonce: 'bob', _nonce: 'bob',
}) })
const bobPostsID = bob.db.feed.getID(bobID, 'post')
{ {
const arr = (await flatten(alice.db.msgs())) const arr = (await flatten(alice.db.msgs()))
.filter((msg) => msg.metadata.account === bobID && msg.data) .filter((msg) => msg.metadata.account === bobID && msg.data)
@ -54,7 +52,6 @@ test('create 200 messages that manage to replicate with low "newest" goals', asy
alice.db.onRecordAdded(rec => { alice.db.onRecordAdded(rec => {
if (rec.msg.data?.text) { if (rec.msg.data?.text) {
//console.log('alice received rec', rec)
const num = Number.parseInt(rec.msg.data.text) const num = Number.parseInt(rec.msg.data.text)
confirmed[num] = true confirmed[num] = true
} }
@ -106,20 +103,15 @@ test('create 100 messages in parallel that still manage to sync realtime (withou
await alice.db.loaded() await alice.db.loaded()
await bob.db.loaded() await bob.db.loaded()
const aliceID = await p(alice.db.account.create)({
subdomain: 'account',
_nonce: 'alice',
})
const bobID = await p(bob.db.account.create)({ const bobID = await p(bob.db.account.create)({
subdomain: 'account', subdomain: 'account',
_nonce: 'bob', _nonce: 'bob',
}) })
const bobPostsID = bob.db.feed.getID(bobID, 'post')
// TODO: remove
//await p(bob.db.feed.publish)({
// account: bobID,
// domain: 'post',
// data: { text: `${n}` },
//})
{ {
const arr = (await flatten(alice.db.msgs())) const arr = (await flatten(alice.db.msgs()))
.filter((msg) => msg.metadata.account === bobID && msg.data) .filter((msg) => msg.metadata.account === bobID && msg.data)
@ -127,13 +119,18 @@ test('create 100 messages in parallel that still manage to sync realtime (withou
assert.deepEqual(arr, [], 'alice has no posts from bob') assert.deepEqual(arr, [], 'alice has no posts from bob')
} }
bob.goals.set(bobPostsID, 'all') await p(alice.set.load)(aliceID)
alice.goals.set(bobPostsID, 'all') await p(bob.set.load)(bobID)
assert(await p(alice.set.add)('follows', bobID), 'alice follows bob')
const goal = 'post@newest-1'
await p(alice.conductor.start)(aliceID, [[goal], [goal]], 64_000_000)
await p(bob.conductor.start)(bobID, [[goal], [goal]], 64_000_000)
const remoteAlice = await p(bob.connect)(alice.getAddress()) const remoteAlice = await p(bob.connect)(alice.getAddress())
assert('alice and bob connected') assert('alice and bob connected')
bob.sync.start()
await p(setTimeout)(1000) await p(setTimeout)(1000)
assert('sync!') assert('sync!')