Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Jan 23, 2025
1 parent db08ab3 commit 65a9d8e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
41 changes: 22 additions & 19 deletions packages/pds/src/actor-store/repo/transactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,29 +104,32 @@ export class RepoTransactor extends RepoReader {
if (action !== WriteOpAction.Create) {
delAndUpdateUris.push(uri)
}
if (swapCid === undefined) {
continue
}
const record = await this.record.getRecord(uri, null, true)
const currRecord = record && CID.parse(record.cid)
if (action === WriteOpAction.Create && swapCid !== null) {
throw new BadRecordSwapError(currRecord) // There should be no current record for a create
}
if (action === WriteOpAction.Update && swapCid === null) {
throw new BadRecordSwapError(currRecord) // There should be a current record for an update
}
if (action === WriteOpAction.Delete && swapCid === null) {
throw new BadRecordSwapError(currRecord) // There should be a current record for a delete
}
if ((currRecord || swapCid) && !currRecord?.equals(swapCid)) {
throw new BadRecordSwapError(currRecord)
}
commitOps.push({
const currRecord = record ? CID.parse(record.cid) : null

const op: CommitOp = {
action,
path: formatDataKey(uri.collection, uri.rkey),
cid: write.action === WriteOpAction.Delete ? null : write.cid,
prev: currRecord ?? undefined,
})
}
if (currRecord) {
op.prev = currRecord
}
commitOps.push(op)
if (swapCid !== undefined) {
if (action === WriteOpAction.Create && swapCid !== null) {
throw new BadRecordSwapError(currRecord) // There should be no current record for a create
}
if (action === WriteOpAction.Update && swapCid === null) {
throw new BadRecordSwapError(currRecord) // There should be a current record for an update
}
if (action === WriteOpAction.Delete && swapCid === null) {
throw new BadRecordSwapError(currRecord) // There should be a current record for a delete
}
if ((currRecord || swapCid) && !currRecord?.equals(swapCid)) {
throw new BadRecordSwapError(currRecord)
}
}
}

const repo = await Repo.load(this.storage, currRoot.cid)
Expand Down
1 change: 0 additions & 1 deletion packages/pds/src/sequencer/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { AccountStatus } from '../account-manager'
export const formatSeqCommit = async (
did: string,
commitData: CommitDataWithOps,
// writes: PreparedWrite[],
): Promise<RepoSeqInsert> => {
const blocksToSend = new BlockMap()
blocksToSend.addMap(commitData.newBlocks)
Expand Down
6 changes: 1 addition & 5 deletions packages/pds/tests/sequencer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,7 @@ describe('sequencer', () => {
(store) => store.repo.formatCommit(writes),
)

const repoSeqInsert = await formatSeqCommit(
sc.dids.alice,
writeCommit,
writes,
)
const repoSeqInsert = await formatSeqCommit(sc.dids.alice, writeCommit)

const evt = cborDecode<sequencer.CommitEvt>(repoSeqInsert.event)
expect(evt.tooBig).toBe(true)
Expand Down

0 comments on commit 65a9d8e

Please sign in to comment.