test that threads with reactions can sync too

This commit is contained in:
Andre Staltz 2023-04-21 13:56:16 +03:00
parent 2f4c07d505
commit fb95886055
1 changed files with 73 additions and 0 deletions

View File

@ -297,3 +297,76 @@ test('sync a thread where receiver does not have the root', async (t) => {
await p(alice.close)(true)
await p(bob.close)(true)
})
test('sync a thread with reactions too', async (t) => {
rimraf.sync(ALICE_DIR)
rimraf.sync(BOB_DIR)
const alice = createSSB({
keys: aliceKeys,
path: ALICE_DIR,
})
const bob = createSSB({
keys: bobKeys,
path: BOB_DIR,
})
await alice.db.loaded()
await bob.db.loaded()
const rootA = await p(alice.db.create)({
type: 'post',
content: { text: 'A' },
keys: aliceKeys,
})
const replyA1 = await p(alice.db.create)({
type: 'post',
content: { text: 'A1' },
tangles: [rootA.hash],
keys: aliceKeys,
})
const replyA2 = await p(alice.db.create)({
type: 'post',
content: { text: 'A2' },
tangles: [rootA.hash],
keys: aliceKeys,
})
const reactionA3 = await p(alice.db.create)({
type: 'reaction',
content: {text: 'yes', link: replyA1.hash},
tangles: [rootA.hash, replyA1.hash],
keys: aliceKeys,
})
t.deepEquals(
getTexts(alice.db.msgs()),
['A', 'A1', 'A2', 'yes'],
'alice has the full thread'
)
t.deepEquals(getTexts(bob.db.msgs()), [], 'bob has nothing')
bob.tangleSync.setGoal(rootA.hash, 'all')
alice.tangleSync.setGoal(rootA.hash, 'all')
const remoteBob = await p(alice.connect)(bob.getAddress())
t.pass('alice connected to bob')
alice.tangleSync.initiate()
await p(setTimeout)(1000)
t.pass('tangleSync!')
t.deepEquals(
getTexts(bob.db.msgs()),
['A', 'A1', 'A2', 'yes'],
'bob has the full thread'
)
await p(remoteBob.close)(true)
await p(alice.close)(true)
await p(bob.close)(true)
})