diff --git a/tests/rigor/ttl-expiry-parity.test.js b/tests/rigor/ttl-expiry-parity.test.js index aa69e55..933bfea 100644 --- a/tests/rigor/ttl-expiry-parity.test.js +++ b/tests/rigor/ttl-expiry-parity.test.js @@ -23,9 +23,7 @@ const TTL = 5000; const DOCS = 2; const docKey = (i) => `doc:${i}`; -const realNow = Date.now; let engineNow = 1_000_000_000_000; -Date.now = () => engineNow; function makeWrapper(disableCaching) { const arbiter = new Arbiter(disableCaching ? { disableCaching: true } : {}); @@ -69,7 +67,7 @@ function makeWrapper(disableCaching) { return { ok: true, now: engineNow }; }, check(doc) { - const result = arbiter.check('user:alice', 'premium', docKey(doc)); + const result = arbiter.check('user:alice', 'premium', docKey(doc), { now: engineNow }); const b = balance.get(doc); const p = price.get(doc); const bFresh = b !== undefined && engineNow - b.ts <= TTL; diff --git a/tests/rules/relational-comparator.test.js b/tests/rules/relational-comparator.test.js index 9cca6f8..7a8e0ad 100644 --- a/tests/rules/relational-comparator.test.js +++ b/tests/rules/relational-comparator.test.js @@ -294,8 +294,6 @@ describe('RelationalComparatorRule Tests', () => { describe('Time-Based Decay', () => { it('ignores stale timestamps when no decay is applied', () => { const now = 1_000_000_000_000; - const originalDateNow = Date.now; - Date.now = () => now; const arbiter = setupRelationalComparatorTestGraph(); arbiter.addNode('user:decay-test', 'user'); @@ -334,16 +332,12 @@ describe('RelationalComparatorRule Tests', () => { marginOfSafety: 1.0, fallbackBehavior: 'deny' }); - const result = arbiter.check('user:decay-test', 'can_access_decay_test', 'feature:decay-test'); + const result = arbiter.check('user:decay-test', 'can_access_decay_test', 'feature:decay-test', { now }); assert.equal(result.possibility, 1); - - Date.now = originalDateNow; }); it('keeps comparison crisp even for older timestamps', () => { const arbiter = setupRelationalComparatorTestGraph(); const now = 1_000_000_000_000; - const originalDateNow = Date.now; - Date.now = () => now; arbiter.addNode('user:usage-test', 'user'); arbiter.addNode('service:limited', 'service'); @@ -383,10 +377,8 @@ describe('RelationalComparatorRule Tests', () => { comparator: '<=', fallbackBehavior: 'deny' }); - const result = arbiter.check('user:usage-test', 'within_quota', 'service:limited'); + const result = arbiter.check('user:usage-test', 'within_quota', 'service:limited', { now }); assert.equal(result.possibility, 1); - - Date.now = originalDateNow; }); });