-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: refactor: nip module refactor: thin core
- Loading branch information
Showing
40 changed files
with
509 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,11 @@ | |
"./clients": "./clients.ts", | ||
"./protocol": "./protocol.ts", | ||
"./relays": "./relays.ts" | ||
}, | ||
"imports": { | ||
"@lophus/lib": "jsr:@lophus/[email protected]" | ||
}, | ||
"publish": { | ||
"exclude": ["*_test.ts"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from "./clients.ts"; | ||
export * from "./protocol.ts"; | ||
export * from "./relays.ts"; | ||
export * from "./clients.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,27 @@ | ||
import { assertEquals } from "@std/assert"; | ||
import { afterAll, beforeAll, describe, it } from "@std/testing/bdd"; | ||
import { describe, it } from "@std/testing/bdd"; | ||
import { MockWebSocket } from "@lophus/lib/testing"; | ||
import { NostrNode, NostrNodeBase } from "./nodes.ts"; | ||
import { Node } from "./nodes.ts"; | ||
|
||
describe("NostrNodeBase", () => { | ||
let node: NostrNode; | ||
let writer: WritableStreamDefaultWriter; | ||
describe("NostrNode", () => { | ||
describe("writable", () => { | ||
const node = new Node(new MockWebSocket()); | ||
let writer: WritableStreamDefaultWriter; | ||
|
||
beforeAll(() => { | ||
node = new NostrNodeBase(new MockWebSocket()); | ||
}); | ||
|
||
afterAll(async () => { | ||
await node.close().catch((err) => { | ||
if (err.message !== "Writable stream is closed or errored.") { | ||
throw err; | ||
} | ||
it("should open the WebSocket connection", async () => { | ||
writer = node.writable.getWriter(); | ||
await writer.write(["NOTICE", "test"]); | ||
writer.releaseLock(); | ||
assertEquals(node.status, WebSocket.OPEN); | ||
}); | ||
}); | ||
|
||
it("should be connected to the WebSocket after a message is sent", async () => { | ||
writer = node.writable.getWriter(); | ||
await writer.write(["NOTICE", "test"]); | ||
writer.releaseLock(); | ||
assertEquals(node.status, WebSocket.OPEN); | ||
}); | ||
describe("close", () => { | ||
const node = new Node(new MockWebSocket()); | ||
|
||
it("should close the WebSocket when the node is closed", async () => { | ||
await node.close(); | ||
assertEquals(node.status, WebSocket.CLOSED); | ||
it("should close the WebSocket connection", async () => { | ||
await node.close(); | ||
assertEquals(node.status, WebSocket.CLOSED); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.