10 lines
589 B
TypeScript
10 lines
589 B
TypeScript
import { test } from "node:test"
|
|
import assert from "node:assert/strict"
|
|
import { parseWireGuardBytes } from "./wireguard-observed-values.js"
|
|
test("WireGuard byte counters preserve zero and reject partial, negative or unsafe values", () => {
|
|
assert.equal(parseWireGuardBytes("0"), 0)
|
|
assert.equal(parseWireGuardBytes(" 1234 "), 1234)
|
|
assert.equal(parseWireGuardBytes("9007199254740991"), Number.MAX_SAFE_INTEGER)
|
|
for (const raw of [undefined, null, 0, {}, "", " ", "12junk", "1.5", "-1", "Infinity", "1e3", "9007199254740992"]) assert.equal(parseWireGuardBytes(raw), undefined)
|
|
})
|