From d22a4d106eefe57861693f55bdf8021a555b433e Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Fri, 28 Jun 2024 17:57:54 +0200 Subject: [PATCH] Add realtime test without initial post --- test/realtime.test.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/test/realtime.test.js b/test/realtime.test.js index 22d3346..8484c08 100644 --- a/test/realtime.test.js +++ b/test/realtime.test.js @@ -30,8 +30,6 @@ test('create 200 messages that manage to replicate with low "newest" goals', asy _nonce: 'bob', }) - const bobPostsID = bob.db.feed.getID(bobID, 'post') - { const arr = (await flatten(alice.db.msgs())) .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 => { if (rec.msg.data?.text) { - //console.log('alice received rec', rec) const num = Number.parseInt(rec.msg.data.text) 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 bob.db.loaded() + const aliceID = await p(alice.db.account.create)({ + subdomain: 'account', + _nonce: 'alice', + }) const bobID = await p(bob.db.account.create)({ subdomain: 'account', _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())) .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') } - bob.goals.set(bobPostsID, 'all') - alice.goals.set(bobPostsID, 'all') + await p(alice.set.load)(aliceID) + 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()) assert('alice and bob connected') - bob.sync.start() await p(setTimeout)(1000) assert('sync!')