Skip to content

Commit

Permalink
+
Browse files Browse the repository at this point in the history
  • Loading branch information
BlowaterNostr committed Apr 29, 2024
1 parent 85ed4dc commit 8791ccb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"deno.enable": true,
"editor.indentSize": "tabSize"
"editor.indentSize": "tabSize",
"deno.lint": false
}
3 changes: 1 addition & 2 deletions queries/setRelayInformation.gql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
mutation setRelayInformation($pubkey: String, $contact: String, $name: String, $description: String, $icon: String) {
mutation setRelayInformation($contact: String, $name: String, $description: String, $icon: String) {
set_relay_information(
pubkey: $pubkey
contact: $contact
name: $name
description: $description
Expand Down
2 changes: 1 addition & 1 deletion resolvers/nip11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class RelayInformationStore {

const new_information = { ...old_information, ...args };
await this.kv.set(["relay_information"], new_information);
return { ...new_information, ...not_modifiable_information };
return { ...new_information, ...not_modifiable_information, pubkey: this.default_information.pubkey };
};
}

Expand Down
14 changes: 10 additions & 4 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Deno.test("main", async (t) => {
const relay = await run({
port: 8080,
default_information: {
pubkey: test_ctx.publicKey,
pubkey: test_ctx.publicKey.hex,
},
default_policy: {
allowed_kinds: [NostrKind.Long_Form, NostrKind.Encrypted_Custom_App_Data],
Expand Down Expand Up @@ -174,7 +174,7 @@ Deno.test("NIP-11: Relay Information Document", async (t) => {
},
default_information: {
name: "Nostr Relay",
pubkey: test_ctx.publicKey,
pubkey: test_ctx.publicKey.hex,
},
kv: await test_kv(),
}) as Relay;
Expand All @@ -188,18 +188,24 @@ Deno.test("NIP-11: Relay Information Document", async (t) => {
});
});

await t.step("set relay information", async () => {
const ok = await t.step("set relay information", async () => {
await relay.set_relay_information({
name: "Nostr Relay2",
});

const information2 = await relay.get_relay_information();
assertEquals(information2, {
name: "Nostr Relay2",
pubkey: test_ctx.publicKey,
// @ts-ignore
pubkey: {
hex: test_ctx.publicKey.hex,
},
...not_modifiable_information,
});
});
if (!ok) {
fail();
}

await t.step("graphql get relay information", async () => {
const query = await Deno.readTextFile("./queries/getRelayInformation.gql");
Expand Down

0 comments on commit 8791ccb

Please sign in to comment.