import assert from "node:assert/strict"
import { isNonPublicIp, pickInternetPeer } from "./traffic-flow-ip.js"

assert.equal(isNonPublicIp("10.200.100.53"), true)
assert.equal(isNonPublicIp("173.194.151.65"), false)

assert.equal(
  pickInternetPeer("173.194.151.65", "10.200.100.53", 443, 57182),
  "173.194.151.65",
  "reverse IPFIX: Google:443 → RFC1918",
)
assert.equal(
  pickInternetPeer("10.200.100.53", "104.18.35.51", 53880, 443),
  "104.18.35.51",
  "client → Cloudflare:443",
)
assert.equal(pickInternetPeer("10.100.1.17", "8.8.8.8", 51234, 443), "8.8.8.8")
assert.equal(
  pickInternetPeer("1.1.1.1", "8.8.8.8", 443, 51234),
  "1.1.1.1",
  "оба публичные — сторона с well-known портом",
)
assert.equal(pickInternetPeer("10.1.1.1", "10.2.2.2", 443, 80), "10.2.2.2")

console.log("traffic-flow-ip.test.ts: ok")
