717ae1031e
Zanzibar-style authorization graph engine (direct/chain/TTU/defeasible/ binary modes, condensed snapshots, value relations) with 39 rigor test campaigns. Includes fixes for snapshot binary writer/reader format mismatch (snapshot-of-snapshot corruption), possibility write-boundary validation, empty-graph snapshot serialization, relation lookup cache direction collision, config-redefinition cache invalidation, binary threshold semantics, defeasible compiled routing, and comparator reason whitelisting.
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
import { describe, test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { Arbiter } from '../../src/core/Arbiter.js';
|
|
|
|
describe('Traversal edge cases', () => {
|
|
test('shortestPathLength returns Infinity for missing nodes', () => {
|
|
const arbiter = new Arbiter();
|
|
arbiter.addNode('a', 'node');
|
|
assert.strictEqual(arbiter.traversal.shortestPathLength('a', 'missing'), Infinity);
|
|
});
|
|
|
|
test('shortestPathLength finds a two-hop path', () => {
|
|
const arbiter = new Arbiter();
|
|
arbiter.addNode('a', 'node');
|
|
arbiter.addNode('b', 'node');
|
|
arbiter.addNode('c', 'node');
|
|
arbiter.addRelation('a', 'links', 'b');
|
|
arbiter.addRelation('b', 'links', 'c');
|
|
|
|
assert.strictEqual(arbiter.traversal.shortestPathLength('a', 'c'), 2);
|
|
});
|
|
|
|
test('walk returns empty path for unknown start', () => {
|
|
const arbiter = new Arbiter();
|
|
assert.deepStrictEqual(arbiter.traversal.walk('missing', 3), []);
|
|
});
|
|
|
|
test('walk stops when no neighbors are present', () => {
|
|
const arbiter = new Arbiter();
|
|
arbiter.addNode('solo', 'node');
|
|
const path = arbiter.traversal.walk('solo', 5);
|
|
assert.deepStrictEqual(path, ['solo']);
|
|
});
|
|
});
|