Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/d2ts/src/version-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class Index<K, V> implements IndexType<K, V> {

append(other: Index<K, V>): void {
for (const [key, versions] of other.entries()) {
const thisVersions = this.get(key)
const thisVersions = this.#inner.get(key)
for (const [version, data] of versions) {
thisVersions.update(version, (values) => {
chunkedArrayPush(values, data)
Expand Down
31 changes: 31 additions & 0 deletions packages/d2ts/tests/version-index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,37 @@ function createIndexTests<
index.compact(frontier2)
}).toThrow('Invalid compaction frontier')
})

test('should append after compact', () => {
const version1 = v([1])
const version2 = v([2])
const version3 = v([3])
const frontier = new Antichain([version2])

index.addValue('key1', version1, [10, 1])

expect(index.reconstructAt('key1', version1)).toEqual([[10, 1]])

index.compact(frontier)

const other = createIndex('other')
other.addValue('key1', version2, [20, 1])

// @ts-expect-error
index.append(other)

const other2 = createIndex('other2')
other2.addValue('key1', version3, [30, 1])

// @ts-expect-error
index.append(other2)

expect(index.reconstructAt('key1', version3)).toEqual([
[10, 1],
[20, 1],
[30, 1],
])
})
})

describe('validation', () => {
Expand Down