diff options
Diffstat (limited to 'jest/test-pds.ts')
-rw-r--r-- | jest/test-pds.ts | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/jest/test-pds.ts b/jest/test-pds.ts index 31dcb3cb8..32f3bc9b0 100644 --- a/jest/test-pds.ts +++ b/jest/test-pds.ts @@ -8,7 +8,7 @@ import PDSServer, { ServerConfig as PDSServerConfig, } from '@atproto/pds' import * as plc from '@atproto/plc' -import AtpApi, {ServiceClient} from '@atproto/api' +import AtpAgent from '@atproto/api' export interface TestUser { email: string @@ -16,7 +16,7 @@ export interface TestUser { declarationCid: string handle: string password: string - api: ServiceClient + agent: AtpAgent } export interface TestUsers { @@ -87,6 +87,8 @@ export async function createServer(): Promise<TestPDS> { dbPostgresUrl: process.env.DB_POSTGRES_URL, blobstoreLocation: `${blobstoreLoc}/blobs`, blobstoreTmp: `${blobstoreLoc}/tmp`, + maxSubscriptionBuffer: 200, + repoBackfillLimitMs: 1e3 * 60 * 60, }) const db = PDSDatabase.memory() @@ -112,11 +114,11 @@ export async function createServer(): Promise<TestPDS> { async function genMockData(pdsUrl: string): Promise<TestUsers> { const date = dateGen() - const clients = { - loggedout: AtpApi.service(pdsUrl), - alice: AtpApi.service(pdsUrl), - bob: AtpApi.service(pdsUrl), - carla: AtpApi.service(pdsUrl), + const agents = { + loggedout: new AtpAgent({service: pdsUrl}), + alice: new AtpAgent({service: pdsUrl}), + bob: new AtpAgent({service: pdsUrl}), + carla: new AtpAgent({service: pdsUrl}), } const users: TestUser[] = [ { @@ -125,7 +127,7 @@ async function genMockData(pdsUrl: string): Promise<TestUsers> { declarationCid: '', handle: 'alice.test', password: 'hunter2', - api: clients.alice, + agent: agents.alice, }, { email: 'bob@test.com', @@ -133,7 +135,7 @@ async function genMockData(pdsUrl: string): Promise<TestUsers> { declarationCid: '', handle: 'bob.test', password: 'hunter2', - api: clients.bob, + agent: agents.bob, }, { email: 'carla@test.com', @@ -141,7 +143,7 @@ async function genMockData(pdsUrl: string): Promise<TestUsers> { declarationCid: '', handle: 'carla.test', password: 'hunter2', - api: clients.carla, + agent: agents.carla, }, ] const alice = users[0] @@ -150,18 +152,18 @@ async function genMockData(pdsUrl: string): Promise<TestUsers> { let _i = 1 for (const user of users) { - const res = await clients.loggedout.com.atproto.account.create({ + const res = await agents.loggedout.api.com.atproto.account.create({ email: user.email, handle: user.handle, password: user.password, }) - user.api.setHeader('Authorization', `Bearer ${res.data.accessJwt}`) - const {data: profile} = await user.api.app.bsky.actor.getProfile({ + user.agent.api.setHeader('Authorization', `Bearer ${res.data.accessJwt}`) + const {data: profile} = await user.agent.api.app.bsky.actor.getProfile({ actor: user.handle, }) user.did = res.data.did user.declarationCid = profile.declaration.cid - await user.api.app.bsky.actor.profile.create( + await user.agent.api.app.bsky.actor.profile.create( {did: user.did}, { displayName: ucfirst(user.handle).slice(0, -5), @@ -172,7 +174,7 @@ async function genMockData(pdsUrl: string): Promise<TestUsers> { // everybody follows everybody const follow = async (author: TestUser, subject: TestUser) => { - await author.api.app.bsky.graph.follow.create( + await author.agent.api.app.bsky.graph.follow.create( {did: author.did}, { subject: { |