Skip to content

Commit

Permalink
add test for crosslinked non-indexer nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
chm-diederichs committed Jun 13, 2024
1 parent 0c05bc6 commit 07c5a0f
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion test/suspend.js
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ test('suspend - restart with unindexed local nodes', async t => {
t.is(await a.view.get(a.view.length - 1), 'c101')
})

test('suspend - restart with unindexed local nodes', async t => {
test('suspend - restart with indexed and unindexed local nodes', async t => {
const { bases, stores } = await create(3, t, { storage: () => tmpDir(t) })

const [a, b, c] = bases
Expand Down Expand Up @@ -1098,6 +1098,47 @@ test('suspend - restart with unindexed local nodes', async t => {
t.is(await a.view.get(a.view.length - 1), 'c101')
})

test('suspend - restart with crosslinked non-indexer nodes', async t => {
const { bases, stores } = await create(3, t, { storage: () => tmpDir(t) })

const [a, b, c] = bases

await addWriterAndSync(a, b, false)
await addWriterAndSync(a, c, false)

await replicateAndSync([a, b, c])

let n = 0

// writer has indexed nodes
for (let i = 0; i < 100; i++) await c.append('c' + n++)

await confirm([a, b, c])

// bigger than autobase max batch size
for (let i = 0; i < 40; i++) await b.append('b' + n++)
await replicateAndSync([b, c])
for (let i = 0; i < 40; i++) await c.append('c' + n++)
await replicateAndSync([b, c])
for (let i = 0; i < 40; i++) await b.append('b' + n++)
await replicateAndSync([b, c])

await c.close()

const c1 = createBase(stores[2], null, t)

await c1.append('c' + n)

const exp = { key: b.local.key, length: b.local.length }

const last = await c1.local.get(c1.local.length - 1)
t.alike(last.node.heads, [exp])

await replicateAndSync([a, c1])

t.is(await a.view.get(a.view.length - 1), 'c' + n)
})

function openMultiple (store) {
return {
first: store.get('first', { valueEncoding: 'json' }),
Expand Down

0 comments on commit 07c5a0f

Please sign in to comment.