From afffe98839db7ccbfa9fb8b7d1413b97900fdc73 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Nov 2017 11:35:10 +0100 Subject: Speed up activity pub http requests --- server/tests/utils/follows.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'server/tests/utils/follows.ts') diff --git a/server/tests/utils/follows.ts b/server/tests/utils/follows.ts index 9ad1ca7f4..b454fe2f8 100644 --- a/server/tests/utils/follows.ts +++ b/server/tests/utils/follows.ts @@ -1,9 +1,9 @@ import * as request from 'supertest' - import { wait } from './miscs' +import { ServerInfo } from './servers' function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) { - const path = '/api/v1/servers/followers' + const path = '/api/v1/server/followers' return request(url) .get(path) @@ -16,7 +16,7 @@ function getFollowersListPaginationAndSort (url: string, start: number, count: n } function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string) { - const path = '/api/v1/servers/following' + const path = '/api/v1/server/following' return request(url) .get(path) @@ -29,25 +29,36 @@ function getFollowingListPaginationAndSort (url: string, start: number, count: n } async function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) { - const path = '/api/v1/servers/follow' + const path = '/api/v1/server/follow' + const followingHosts = following.map(f => f.replace(/^http:\/\//, '')) const res = await request(follower) .post(path) .set('Accept', 'application/json') .set('Authorization', 'Bearer ' + accessToken) - .send({ 'hosts': following }) + .send({ 'hosts': followingHosts }) .expect(expectedStatus) // Wait request propagation - await wait(1000) + await wait(20000) return res } +async function doubleFollow (server1: ServerInfo, server2: ServerInfo) { + await Promise.all([ + follow(server1.url, [ server2.url ], server1.accessToken), + follow(server2.url, [ server1.url ], server2.accessToken) + ]) + + return true +} + // --------------------------------------------------------------------------- export { getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, - follow + follow, + doubleFollow } -- cgit v1.2.3