nostr package: more tests #434

Merged
sistemd merged 4 commits from nostr-package-better-tests into nostr-package-eose 2023-03-27 09:06:17 +00:00
6 changed files with 15 additions and 11 deletions
Showing only changes of commit aa8bc3b598 - Show all commits

View File

@ -1,7 +0,0 @@
Allows the relay to be shut down with an HTTP request, after which
docker-compose will restart it. This allows each test to have a clean
slate. The drawback is that the tests can't run in parallel, so the
test suite is very slow. A better option would be to have this relay
server manage the relay completely: star/stop isolated relay instances
with HTTP requests and allow multiple instances to run at the same
time so that the tests can be parallelized.

View File

@ -1,3 +1,4 @@
[authorization]
nip42_auth = true
# This seems to have no effect.
nip42_dms = true

View File

@ -1,3 +1,13 @@
/**
* Allows the relay to be shut down with an HTTP request, after which
* docker-compose will restart it. This allows each test to have a clean
* slate. The drawback is that the tests can't run in parallel, so the
* test suite is very slow. A better option would be to have this relay
* server manage the relay completely: star/stop isolated relay instances
* with HTTP requests and allow multiple instances to run at the same
* time so that the tests can be parallelized.
*/
import http from "node:http"
import { spawn } from "node:child_process"

View File

@ -161,8 +161,7 @@ export class EventEmitter extends Base {
// emitter[Symbol.for('nodejs.rejection')](err, eventName[, ...args]) shenanigans?
}
// TODO Add an open event
// TODO Refactor the params
// TODO Refactor the params to be a single interface
type EventName =
| "newListener"
| "removeListener"

View File

@ -166,6 +166,7 @@ export function createSetMetadata(
// Perhaps the best option is for all these factory methods to have an overload which also accept a private
// key as last parameter and return the event already signed, whereas for this method that would be
// mandatory
// E.g. opts: { sign?: boolean | HexOrBechPrivateKey } setting sign to true should use nip07
export async function createDirectMessage({
message,
recipient,

View File

@ -6,8 +6,8 @@ import { setup } from "./setup"
describe("text note", async function () {
const note = "hello world"
// Test that a text note can be published by one client and received by the other.
it("publish and receive", (done) => {
// Test that a text note can be published by one client and received by the other.
setup(done).then(
({
publisher,
@ -51,8 +51,8 @@ describe("text note", async function () {
)
})
// Test that a client interprets an "OK" message after publishing a text note.
it("publish and ok", function (done) {
// Test that a client interprets an "OK" message after publishing a text note.
setup(done).then(({ publisher, subscriber, publisherSecret, url }) => {
// TODO No signEvent, have a convenient way to do this
signEvent(createTextNote(note), publisherSecret).then((event) => {