-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.test.js
37 lines (34 loc) · 880 Bytes
/
main.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const IsTorExit = require(require("path").join(__dirname, "main.js"));
describe("Not exit nodes", () => {
test("google", async (done) => {
const result = await IsTorExit("216.58.206.110");
expect(result).toBe(false);
done();
});
test("facebook", async (done) => {
const result = await IsTorExit("185.60.216.35");
expect(result).toBe(false);
done();
});
});
describe("Exit nodes", () => {
const ips = require("fs")
.readFileSync(require("path").join(__dirname, "ips.txt"), {
encoding: "utf8",
})
.split("\n")
.map((line) => line.replace(/\r/g, "").trim())
.filter((line) => line[0] != "#" && line)
.slice(0, 100);
for (const ip of ips) {
test(
ip,
(done) => {
IsTorExit(ip)
.then((result) => expect(result).toBe(true))
.then(done);
},
15000
);
}
});