Skip to content

Commit

Permalink
call useWebSocketImplementation() on relay and pool tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Feb 14, 2024
1 parent 01f1329 commit 62e5730
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion pool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { afterEach, beforeEach, expect, test } from 'bun:test'

import { SimplePool } from './pool.ts'
import { finalizeEvent, generateSecretKey, getPublicKey, type Event } from './pure.ts'
import { MockRelay } from './test-helpers.ts'
import { useWebSocketImplementation } from './relay.ts'
import { MockRelay, MockWebSocketClient } from './test-helpers.ts'

useWebSocketImplementation(MockWebSocketClient)

let pool: SimplePool
let mockRelays: MockRelay[]
Expand Down
6 changes: 4 additions & 2 deletions relay.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { expect, test } from 'bun:test'

import { finalizeEvent, generateSecretKey, getPublicKey } from './pure.ts'
import { Relay } from './relay.ts'
import { MockRelay } from './test-helpers.ts'
import { Relay, useWebSocketImplementation } from './relay.ts'
import { MockRelay, MockWebSocketClient } from './test-helpers.ts'

useWebSocketImplementation(MockWebSocketClient)

test('connectivity', async () => {
const mockRelay = new MockRelay()
Expand Down
4 changes: 3 additions & 1 deletion test-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Server } from 'mock-socket'
import { Server, WebSocket } from 'mock-socket'

import { finalizeEvent, type Event, getPublicKey, generateSecretKey } from './pure.ts'
import { matchFilters, type Filter } from './filter.ts'

export const MockWebSocketClient = WebSocket

export function buildEvent(params: Partial<Event>): Event {
return {
id: '',
Expand Down

0 comments on commit 62e5730

Please sign in to comment.