Skip to content

Commit

Permalink
Update CSRs test since the order that orbitdb returns events in changed
Browse files Browse the repository at this point in the history
  • Loading branch information
islathehut committed Nov 5, 2024
1 parent 9e50e2c commit 4615671
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import { IpfsModule } from '../../ipfs/ipfs.module'
import { IpfsService } from '../../ipfs/ipfs.service'
import { Libp2pService } from '../../libp2p/libp2p.service'
import { libp2pInstanceParams } from '../../common/utils'
import { sleep } from '../../common/sleep'

const updateEvent = async (certificatesRequestsStore: any) => {
certificatesRequestsStore.events.emit('update')
await new Promise<void>(resolve => setTimeout(() => resolve(), 2000))
await sleep(2000)
}

describe('CertificatesRequestsStore', () => {
Expand Down Expand Up @@ -72,26 +73,24 @@ describe('CertificatesRequestsStore', () => {

it('getCsrs - remove old csrs and replace with new for each pubkey', async () => {
const allCsrs = [
'MIIDITCCAsYCAQAwSTFHMEUGA1UEAxM+anR3c3hxMnZ1dWthY3JodWhvdnAzd2JxbzRxNXc0d2s3Nm1qbWJ3cXk3eGNma2FsdmRxb3hhYWQub25pb24wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQE2q6iS+WCmIVCSFI2AjHrW6ujUdrceD5T2xkcTJBTn0y50WphcupUajCRgkXaTBkTsGNJ3qWRZAKX7CiuehBJoIICGTAuBgkqhkiG9w0BCQ4xITAfMB0GA1UdDgQWBBQuE5JgPY/BYBpgG5pnjMkEEIkrGjCCAUcGCSqGSIb3DQEJDDGCATgEggE0BDlx84glBl72q82F2a+y8iTVKM8IMiXYYrmNyhFPj6XsfVQpvLhNviZ5zHdMBWbFj44vTSUIasNP9I9eCWSEAaEJqjngEh18WCRS/XbvQxI/8qB5pzcfghvM8BCgSLbSEjK2GMYVhCXmRH1YGHIZu0+Ii9pe5nwG154JlPUsmIRgu6ruY6PQk65Aoo4OyhPn5CCUFInptHcz1JpAiCRe0Z6wuQHud03VY50fx4ETdmUNJBEIPOyd/Xn6l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mRdoHJAEt6kPLhGIYGyduNT/8cGoe2xKyQDvNoTr4dqqRZ2HgZ18nicsTHswpGqAlUnZXaA3V85Qu1cvaMAqEoPOUlGP9AriIVwtIZM0hdWHqKHgBCZrKfHb5oLxt6ourQ3+q19tvx+u6UwFAYKKwYBBAGDjBsCATEGEwRlbGxvMD0GCSsGAQIBDwMBATEwEy5RbVVvNXN0NXNqR3RFMUtQeXhOVW5pTWhnQXduV0JVNXk3TnpoMlpRRkdacVdiMEcGA1UdETFAEz5qdHdzeHEydnV1a2Fjcmh1aG92cDN3YnFvNHE1dzR3azc2bWptYndxeTd4Y2ZrYWx2ZHFveGFhZC5vbmlvbjAKBggqhkjOPQQDAgNJADBGAiEAt9udw7B7vnjJyWvkkRLb7DImFXwsrSxirqbmhIH+1rUCIQD86GWyfAE2d8gCNAn4h1t9B+mAx33ZdPLgFssHl1i3pA==',
]

for (const csr of allCsrs) {
await certificatesRequestsStore.addEntry(csr)
// This should not be there, there's bug in orbitdb, it breaks if we add entries without artificial sleep, tho it's awaited.
// https://github.com/TryQuiet/quiet/issues/2121
await new Promise<void>(resolve => setTimeout(() => resolve(), 500))
await sleep(500)
}

await certificatesRequestsStore.getEntries()

const filteredCsrs = await certificatesRequestsStore.getEntries()

expect(filteredCsrs.length).toEqual(allCsrs.length - 1)
Expand Down

0 comments on commit 4615671

Please sign in to comment.