Skip to content

Commit

Permalink
Fix getRepo since (#1579)
Browse files Browse the repository at this point in the history
* fix schemas

* test

* format
  • Loading branch information
dholms authored Sep 12, 2023
1 parent 1053c6f commit 3cdc72a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
1 change: 0 additions & 1 deletion lexicons/com/atproto/sync/getRepo.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
},
"since": {
"type": "string",
"format": "cid",
"description": "The revision of the repo to catch up from."
}
}
Expand Down
1 change: 0 additions & 1 deletion lexicons/com/atproto/sync/listBlobs.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
},
"since": {
"type": "string",
"format": "cid",
"description": "Optional revision of the repo to list blobs since"
},
"limit": {
Expand Down
2 changes: 0 additions & 2 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,6 @@ export const schemaDict = {
},
since: {
type: 'string',
format: 'cid',
description: 'The revision of the repo to catch up from.',
},
},
Expand Down Expand Up @@ -3178,7 +3177,6 @@ export const schemaDict = {
},
since: {
type: 'string',
format: 'cid',
description: 'Optional revision of the repo to list blobs since',
},
limit: {
Expand Down
2 changes: 0 additions & 2 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,6 @@ export const schemaDict = {
},
since: {
type: 'string',
format: 'cid',
description: 'The revision of the repo to catch up from.',
},
},
Expand Down Expand Up @@ -3178,7 +3177,6 @@ export const schemaDict = {
},
since: {
type: 'string',
format: 'cid',
description: 'Optional revision of the repo to list blobs since',
},
limit: {
Expand Down
2 changes: 0 additions & 2 deletions packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,6 @@ export const schemaDict = {
},
since: {
type: 'string',
format: 'cid',
description: 'The revision of the repo to catch up from.',
},
},
Expand Down Expand Up @@ -3178,7 +3177,6 @@ export const schemaDict = {
},
since: {
type: 'string',
format: 'cid',
description: 'Optional revision of the repo to list blobs since',
},
limit: {
Expand Down
33 changes: 33 additions & 0 deletions packages/pds/tests/sync/sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,39 @@ describe('repo sync', () => {
expect(commit.data.cid).toEqual(currRoot?.toString())
})

it('syncs `since` a given rev', async () => {
const repoBefore = await repo.Repo.load(storage, currRoot)

// add a post
const { obj, uri } = await makePost(sc, did)
if (!repoData[uri.collection]) {
repoData[uri.collection] = {}
}
repoData[uri.collection][uri.rkey] = obj
uris.push(uri)

const carRes = await agent.api.com.atproto.sync.getRepo({
did,
since: repoBefore.commit.rev,
})
const car = await repo.readCarWithRoot(carRes.data)
expect(car.blocks.size).toBeLessThan(10) // should only contain new blocks
const synced = await repo.verifyDiff(
repoBefore,
car.blocks,
car.root,
did,
ctx.repoSigningKey.did(),
)
expect(synced.writes.length).toBe(1)
await storage.applyCommit(synced.commit)
const loaded = await repo.Repo.load(storage, car.root)
const contents = await loaded.getContents()
expect(contents).toEqual(repoData)

currRoot = car.root
})

it('sync a record proof', async () => {
const collection = Object.keys(repoData)[0]
const rkey = Object.keys(repoData[collection])[0]
Expand Down

0 comments on commit 3cdc72a

Please sign in to comment.