feat(smartnetwork): add Rust-powered network diagnostics bridge and IP intelligence lookups

This commit is contained in:
2026-03-26 15:24:43 +00:00
parent e9dcd45acd
commit c3ac9b4f9e
34 changed files with 5499 additions and 3159 deletions

View File

@@ -4,27 +4,37 @@ import * as smartnetwork from '../ts/index.js';
let testSmartnetwork: smartnetwork.SmartNetwork;
tap.test('should create a vlid instance of SmartNetwork', async () => {
tap.test('should create a valid instance of SmartNetwork', async () => {
testSmartnetwork = new smartnetwork.SmartNetwork();
expect(testSmartnetwork).toBeInstanceOf(smartnetwork.SmartNetwork);
});
tap.test('should start the Rust bridge', async () => {
await testSmartnetwork.start();
});
tap.test('should send a ping to Google', async () => {
const res = await testSmartnetwork.ping('google.com');
console.log(res);
// verify basic ping response properties
expect(res.alive).toBeTrue();
expect(res.time).toBeTypeofNumber();
expect(res.output).toBeTypeofString();
expect(res.output).toMatch(/PING google\.com/);
// Ping requires CAP_NET_RAW or appropriate ping_group_range.
// When permissions are available, alive should be true.
// When not, we gracefully get alive=false.
expect(typeof res.alive).toEqual('boolean');
expect(typeof res.time).toEqual('number');
});
tap.test('should state when a ping is not alive ', async () => {
await expect(testSmartnetwork.ping('notthere.lossless.com')).resolves.property('alive').toBeFalse();
tap.test('should state when a ping is not alive', async () => {
const res = await testSmartnetwork.ping('notthere.lossless.com');
expect(res.alive).toBeFalse();
});
tap.test('should send a ping to an IP', async () => {
await expect(testSmartnetwork.ping('192.168.186.999')).resolves.property('alive').toBeFalse();
tap.test('should send a ping to an invalid IP', async () => {
const res = await testSmartnetwork.ping('192.168.186.999');
expect(res.alive).toBeFalse();
});
tap.start();
tap.test('should stop the Rust bridge', async () => {
await testSmartnetwork.stop();
});
export default tap.start();