Skip to content

Commit

Permalink
refactor: Refactor create community and store more data in backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Leblow committed Feb 23, 2024
1 parent 6322613 commit 5d86954
Show file tree
Hide file tree
Showing 28 changed files with 466 additions and 361 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,11 @@ describe('ConnectionsManagerService', () => {
'QmZoiJNAvCffeEHBjk766nLuKVdkxkAT7wfFJDPPLsbKSE'
)
const launchCommunityPayload: InitCommunityPayload = {
id: community.id,
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
certs: {
// @ts-expect-error
certificate: userIdentity.userCertificate,
// @ts-expect-error
key: userIdentity.userCsr?.userKey,
CA: [communityRootCa],
network: {
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
},
peers: [remotePeer],
community,
}

await localDbService.put(LocalDBKeys.COMMUNITY, launchCommunityPayload)
Expand All @@ -132,17 +126,11 @@ describe('ConnectionsManagerService', () => {
// At this moment, that test have to be skipped, because checking statues is called before launchCommunity method
it.skip('community is only launched once', async () => {
const launchCommunityPayload: InitCommunityPayload = {
id: community.id,
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
certs: {
// @ts-expect-error
certificate: userIdentity.userCertificate,
// @ts-expect-error
key: userIdentity.userCsr?.userKey,
CA: [communityRootCa],
network: {
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
},
peers: community.peerList,
community,
}

//@ts-ignore
Expand All @@ -158,17 +146,11 @@ describe('ConnectionsManagerService', () => {

it('Bug reproduction - Error on startup - Error: TOR: Connection already established - Trigger launchCommunity from backend and state manager', async () => {
const launchCommunityPayload: InitCommunityPayload = {
id: community.id,
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
certs: {
// @ts-expect-error
certificate: userIdentity.userCertificate,
// @ts-expect-error
key: userIdentity.userCsr?.userKey,
CA: [communityRootCa],
network: {
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
},
peers: community.peerList,
community,
}

// await connectionsManager.init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,11 @@ describe('Connections manager', () => {
const emitSpy = jest.spyOn(libp2pService, 'emit')

const launchCommunityPayload: InitCommunityPayload = {
id: community.id,
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
certs: {
// @ts-expect-error
certificate: userIdentity.userCertificate,
// @ts-expect-error
key: userIdentity.userCsr?.userKey,
CA: [communityRootCa],
network: {
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
},
peers: community.peerList,
community,
}

await localDbService.put(LocalDBKeys.COMMUNITY, launchCommunityPayload)
Expand Down Expand Up @@ -207,18 +201,11 @@ describe('Connections manager', () => {
}

const launchCommunityPayload: InitCommunityPayload = {
id: community.id,
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
certs: {
// @ts-expect-error Identity.userCertificate can be null
certificate: userIdentity.userCertificate,
// @ts-expect-error Identity.userCertificate userCsr.userKey can be undefined
key: userIdentity.userCsr?.userKey,
// @ts-expect-error
CA: [community.rootCa],
network: {
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
},
peers: peerList,
community,
}
await connectionsManagerService.init()
await connectionsManagerService.launchCommunity(launchCommunityPayload)
Expand Down Expand Up @@ -249,18 +236,11 @@ describe('Connections manager', () => {
}

const launchCommunityPayload: InitCommunityPayload = {
id: community.id,
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
certs: {
// @ts-expect-error Identity.userCertificate can be null
certificate: userIdentity.userCertificate,
// @ts-expect-error
key: userIdentity.userCsr?.userKey,
// @ts-expect-error
CA: [community.rootCa],
network: {
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
},
peers: peerList,
community,
}

await connectionsManagerService.launchCommunity(launchCommunityPayload)
Expand Down
Loading

0 comments on commit 5d86954

Please sign in to comment.