forked from Kieran/snort
fix the test
This commit is contained in:
parent
c20dea1dba
commit
6daa75b21c
@ -1,6 +1,5 @@
|
|||||||
import Base from "events"
|
import Base from "events"
|
||||||
import { Nostr, SubscriptionId } from "."
|
import { EventParams, Nostr } from "."
|
||||||
import { RawEvent, SignedEvent } from "../event"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides providing better types for EventEmitter methods.
|
* Overrides providing better types for EventEmitter methods.
|
||||||
@ -144,9 +143,3 @@ type Listener =
|
|||||||
| EventListener
|
| EventListener
|
||||||
| NoticeListener
|
| NoticeListener
|
||||||
| ErrorListener
|
| ErrorListener
|
||||||
|
|
||||||
interface EventParams {
|
|
||||||
signed: SignedEvent
|
|
||||||
subscriptionId: SubscriptionId
|
|
||||||
raw: RawEvent
|
|
||||||
}
|
|
||||||
|
@ -295,3 +295,10 @@ export interface Filters {
|
|||||||
until?: Date
|
until?: Date
|
||||||
limit?: number
|
limit?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Document this
|
||||||
|
export interface EventParams {
|
||||||
|
signed: SignedEvent
|
||||||
|
subscriptionId: SubscriptionId
|
||||||
|
raw: RawEvent
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Nostr } from "../src/client"
|
import { EventParams, Nostr } from "../src/client"
|
||||||
import { EventKind } from "../src/event"
|
import { EventKind } from "../src/event"
|
||||||
import { PrivateKey } from "../src/keypair"
|
import { PrivateKey } from "../src/keypair"
|
||||||
import assert from "assert"
|
import assert from "assert"
|
||||||
@ -20,7 +20,7 @@ describe("single event communication", function () {
|
|||||||
const subscriber = new Nostr()
|
const subscriber = new Nostr()
|
||||||
subscriber.open("ws://localhost:12648")
|
subscriber.open("ws://localhost:12648")
|
||||||
|
|
||||||
subscriber.on("event", ({ signed: { event } }) => {
|
function listener({ signed: { event } }: EventParams) {
|
||||||
assert.equal(event.kind, EventKind.TextNote)
|
assert.equal(event.kind, EventKind.TextNote)
|
||||||
assert.equal(event.pubkey.toString(), pubkey.toString())
|
assert.equal(event.pubkey.toString(), pubkey.toString())
|
||||||
assert.equal(event.createdAt.toString(), timestamp.toString())
|
assert.equal(event.createdAt.toString(), timestamp.toString())
|
||||||
@ -32,13 +32,15 @@ describe("single event communication", function () {
|
|||||||
// subscribe happen at the same time, the same event might end up being broadcast twice.
|
// subscribe happen at the same time, the same event might end up being broadcast twice.
|
||||||
// To prevent reacting to the same event and calling done() twice, remove the callback
|
// To prevent reacting to the same event and calling done() twice, remove the callback
|
||||||
// for future events.
|
// for future events.
|
||||||
subscriber.on("event", null)
|
subscriber.off("event", listener)
|
||||||
|
|
||||||
publisher.close()
|
publisher.close()
|
||||||
subscriber.close()
|
subscriber.close()
|
||||||
|
|
||||||
done()
|
done()
|
||||||
})
|
}
|
||||||
|
|
||||||
|
subscriber.on("event", listener)
|
||||||
|
|
||||||
subscriber.subscribe([])
|
subscriber.subscribe([])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user