Fix write-check by disabling verification by default, since it isn't working yet. Also add tests
This commit is contained in:
+19
-7
@@ -3,15 +3,14 @@ import assert from "node:assert/strict";
|
||||
|
||||
import { loadConfig } from "../src/config.js";
|
||||
|
||||
test("loadConfig parses valid relays and ignores invalid entries", () => {
|
||||
test("loadConfig parses relay input and ignores invalid entries", () => {
|
||||
const config = loadConfig({
|
||||
RELAYS: "wss://relay.damus.io,not-a-url,wss://nos.lol",
|
||||
RELAYS: "wss://offchain.pub,not-a-url,wss://offchain.pub",
|
||||
WRITE_CHECK_ENABLED: "false",
|
||||
});
|
||||
|
||||
assert.equal(config.relays.length, 2);
|
||||
assert.equal(config.relays[0]?.relay, "wss://relay.damus.io/");
|
||||
assert.equal(config.relays[1]?.relay, "wss://nos.lol/");
|
||||
assert.equal(config.relays.length, 1);
|
||||
assert.equal(config.relays[0]?.relay, "wss://offchain.pub/");
|
||||
assert.equal(config.writeCheck.enabled, false);
|
||||
assert.equal(config.probeIntervalMs, 0);
|
||||
assert.ok(config.warnings.some((w) => w.includes("Ignoring invalid relay URL")));
|
||||
@@ -19,7 +18,7 @@ test("loadConfig parses valid relays and ignores invalid entries", () => {
|
||||
|
||||
test("loadConfig generates write-check private key when missing", () => {
|
||||
const config = loadConfig({
|
||||
RELAYS: "wss://relay.damus.io",
|
||||
RELAYS: "wss://offchain.pub",
|
||||
WRITE_CHECK_ENABLED: "true",
|
||||
});
|
||||
|
||||
@@ -33,7 +32,7 @@ test("loadConfig generates write-check private key when missing", () => {
|
||||
|
||||
test("loadConfig generates write-check private key when configured key is invalid", () => {
|
||||
const config = loadConfig({
|
||||
RELAYS: "wss://relay.damus.io",
|
||||
RELAYS: "wss://offchain.pub",
|
||||
WRITE_CHECK_ENABLED: "true",
|
||||
WRITE_CHECK_PRIVKEY: "not-a-valid-key",
|
||||
});
|
||||
@@ -46,3 +45,16 @@ test("loadConfig generates write-check private key when configured key is invali
|
||||
"expected warning about invalid configured key",
|
||||
);
|
||||
});
|
||||
|
||||
test("loadConfig sets write-check read verification flag", () => {
|
||||
const defaultConfig = loadConfig({
|
||||
RELAYS: "wss://offchain.pub",
|
||||
});
|
||||
assert.equal(defaultConfig.writeCheck.verifyRead, false);
|
||||
|
||||
const verifyConfig = loadConfig({
|
||||
RELAYS: "wss://offchain.pub",
|
||||
WRITE_CHECK_VERIFY_READ: "true",
|
||||
});
|
||||
assert.equal(verifyConfig.writeCheck.verifyRead, true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user