mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 00:28:51 +00:00
use mock relay in nip42 tests
This commit is contained in:
@@ -1,14 +1,16 @@
|
|||||||
import { test, expect } from 'bun:test'
|
import { expect, test } from 'bun:test'
|
||||||
|
|
||||||
import { makeAuthEvent } from './nip42.ts'
|
import { makeAuthEvent } from './nip42.ts'
|
||||||
import { Relay } from './relay.ts'
|
import { Relay } from './relay.ts'
|
||||||
|
import { newMockRelay } from './test-helpers.ts'
|
||||||
|
|
||||||
test('auth flow', async () => {
|
test('auth flow', async () => {
|
||||||
const relay = await Relay.connect('wss://nostr.wine')
|
const { url } = newMockRelay()
|
||||||
|
const relay = await Relay.connect(url)
|
||||||
const auth = makeAuthEvent(relay.url, 'chachacha')
|
const auth = makeAuthEvent(relay.url, 'chachacha')
|
||||||
|
|
||||||
expect(auth.tags).toHaveLength(2)
|
expect(auth.tags).toHaveLength(2)
|
||||||
expect(auth.tags[0]).toEqual(['relay', 'wss://nostr.wine/'])
|
expect(auth.tags[0]).toEqual(['relay', url])
|
||||||
expect(auth.tags[1]).toEqual(['challenge', 'chachacha'])
|
expect(auth.tags[1]).toEqual(['challenge', 'chachacha'])
|
||||||
expect(auth.kind).toEqual(22242)
|
expect(auth.kind).toEqual(22242)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user