Skip to content

Commit

Permalink
Skeleton removal of server peer
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn committed Oct 21, 2024
1 parent 1c025a1 commit b9dd1c0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/member-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ export class MemberApi extends TypedEmitter {
}
}

/**
* @param {string} serverDeviceId
* @returns {Promise<void>}
*/
async removeServerPeer(serverDeviceId) {
// TODO
console.log({ serverDeviceId })
}

/**
* @param {object} options
* @param {string} options.baseUrl
Expand Down
26 changes: 25 additions & 1 deletion test-e2e/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import createFastify from 'fastify'
import assert from 'node:assert/strict'
import test from 'node:test'
import { pEvent } from 'p-event'
import { MEMBER_ROLE_ID } from '../src/roles.js'
import { LEFT_ROLE_ID, MEMBER_ROLE_ID } from '../src/roles.js'
import createServer from '../src/server/app.js'
import {
connectPeers,
Expand Down Expand Up @@ -221,6 +221,30 @@ test('adding a server peer', async (t) => {
)
})

test.skip('removing a server peer', async (t) => {
const manager = createManager('device0', t)
const projectId = await manager.createProject()
const project = await manager.getProject(projectId)

const serverBaseUrl = await createTestServer(t)

await project.$member.addServerPeer(serverBaseUrl, {
dangerouslyAllowInsecureConnections: true,
})

const serverPeer = await findServerPeer(project)
assert(serverPeer, 'server peer should be added')
await project.$member.removeServerPeer(serverPeer.deviceId)

assert.equal(
(await findServerPeer(project))?.role.roleId,
LEFT_ROLE_ID,
'we should believe the server is gone'
)

// TODO: ensure no connections are made
})

test("can't add a server to two different projects", async (t) => {
const [managerA, managerB] = await createManagers(2, t, 'mobile')
const projectIdA = await managerA.createProject()
Expand Down

0 comments on commit b9dd1c0

Please sign in to comment.