Skip to content

Commit

Permalink
test: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EmiM committed Nov 20, 2023
1 parent 108bf30 commit 2a5f801
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/backend/src/nest/local-db/local-db.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,28 @@ describe('LocalDbService', () => {
let module: TestingModule
let localDbService: LocalDbService
let peer1Stats: Record<string, NetworkStats> = {}
let peer1ID: string
let peer2Stats: Record<string, NetworkStats> = {}
let peer2ID: string

beforeAll(async () => {
module = await Test.createTestingModule({
imports: [TestModule, LocalDbModule],
}).compile()

localDbService = await module.resolve(LocalDbService)

peer1ID = 'QmaEvCkpUG7GxhgvMkk8wxurfi1ehjHhSUNRksWTmXN2ix'
peer1Stats = {
['QmaEvCkpUG7GxhgvMkk8wxurfi1ehjHhSUNRksWTmXN2ix']: {
peerId: 'QmaEvCkpUG7GxhgvMkk8wxurfi1ehjHhSUNRksWTmXN2ix',
[peer1ID]: {
peerId: peer1ID,
connectionTime: 50,
lastSeen: 1000,
},
}
peer2ID = 'QmZB6pVafcvAQfy5R5LxvDXvB8xcDifD39Lp3XGDM9XDuQ'
peer2Stats = {
['QmZB6pVafcvAQfy5R5LxvDXvB8xcDifD39Lp3XGDM9XDuQ']: {
peerId: 'QmZB6pVafcvAQfy5R5LxvDXvB8xcDifD39Lp3XGDM9XDuQ',
[peer2ID]: {
peerId: peer2ID,
connectionTime: 500,
lastSeen: 500,
},
Expand Down Expand Up @@ -78,8 +81,8 @@ describe('LocalDbService', () => {

it('get sorted peers', async () => {
const peers = [
createLibp2pAddress('nqnw4kc4c77fb47lk52m5l57h4tcxceo7ymxekfn7yh5m66t4jv2olad.onion', Object.keys(peer2Stats)[0]),
createLibp2pAddress('zl37gnntp64dhnisddftypxbt5cqx6cum65vdv6oeaffrbqmemwc52ad.onion', Object.keys(peer1Stats)[0]),
createLibp2pAddress('nqnw4kc4c77fb47lk52m5l57h4tcxceo7ymxekfn7yh5m66t4jv2olad.onion', peer2ID),
createLibp2pAddress('zl37gnntp64dhnisddftypxbt5cqx6cum65vdv6oeaffrbqmemwc52ad.onion', peer1ID),
]
await localDbService.put(LocalDBKeys.PEERS, {
...peer1Stats,
Expand All @@ -100,7 +103,7 @@ describe('LocalDbService', () => {
})

const peer2StatsUpdated: NetworkStats = {
peerId: 'QmR7Qgd4tg2XrGD3kW647ZnYyazTwHQF3cqRBmSduhhusA',
peerId: peer2ID,
connectionTime: 777,
lastSeen: 678,
}
Expand Down

0 comments on commit 2a5f801

Please sign in to comment.