Skip to content

Commit

Permalink
Manifest length is unbounded (#18)
Browse files Browse the repository at this point in the history
* add test for large manifest

* manifest length is unbounded
  • Loading branch information
chm-diederichs authored Jul 31, 2024
1 parent ab0460a commit a9c485c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class WriteBatch {
}

setCoreAuth ({ key, manifest }) {
this.write.tryPut(encodeCoreIndex(this.storage.corePointer, CORE.MANIFEST), encode(m.CoreAuth, { key, manifest }))
this.write.tryPut(encodeCoreIndex(this.storage.corePointer, CORE.MANIFEST), c.encode(m.CoreAuth, { key, manifest }))
}

setLocalKeyPair (keyPair) {
Expand Down
32 changes: 32 additions & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,38 @@ test('reopen default core', async function (t) {
t.alike(c2.discoveryKey, DK_0)
})

test('large manifest', async function (t) {
const dir = await tmp(t)

const manifest = Buffer.alloc(1000, 0xff)
const keyPair = {
publicKey: Buffer.alloc(32, 2),
secretKey: Buffer.alloc(32, 3)
}
const encryptionKey = Buffer.alloc(32, 4)

const s1 = await getStorage(t, dir)
const c1 = s1.get(DK_0)
if (!(await c1.open())) await c1.create({ key: DK_1, manifest, keyPair, encryptionKey })

await s1.close()

const s2 = await getStorage(t, dir)
const c2 = s2.get()

t.alike(await c2.open(), {
auth: {
key: DK_1,
manifest
},
localKeyPair: keyPair,
encryptionKey,
head: null
})

t.alike(c2.discoveryKey, DK_0)
})

async function getStorage (t, dir) {
if (!dir) dir = await tmp(t)
const s = new CoreStorage(dir)
Expand Down

0 comments on commit a9c485c

Please sign in to comment.