24 lines
1.2 KiB
TypeScript
24 lines
1.2 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { minerDisplayName } from "../src/datum/display-name.js";
|
|
import { parseClientsHtml } from "../src/datum/parse.js";
|
|
|
|
test("missing user agent never reveals an address or worker login", () => {
|
|
for (const agent of ["", " "]) {
|
|
const cells = ["0", "192.0.2.3", "synthetic-payout-address.worker", "Subscribed", "2 s",
|
|
"16384", "32768 (2)", "0 (0) 0%", "1.2 Th/s (1 s)", "", agent];
|
|
const miners = parseClientsHtml('<table><tr><th>Auth Username</th></tr><tr>' +
|
|
cells.map(value => `<td>${value}</td>`).join("") + '</tr></table>');
|
|
assert.equal(miners[0]?.nickname, "Unknown miner");
|
|
}
|
|
});
|
|
|
|
test("legacy ledger names are replaced without changing accounting fields", () => {
|
|
const legacy = { nickname: "synthetic-payout-address", authUsername: "synthetic-payout-address",
|
|
userAgent: " bitaxe/BM1368 ", contributionAcceptedWork: 123 };
|
|
assert.equal(minerDisplayName(legacy), "bitaxe/BM1368");
|
|
assert.equal(legacy.contributionAcceptedWork, 123);
|
|
assert.equal(legacy.authUsername, "synthetic-payout-address");
|
|
assert.equal(minerDisplayName({}), "Unknown miner");
|
|
});
|