Tests

How the Deva Core is tested, what each test suite proves, and the edge cases the suite found and fixed.

The Deva Core test suite has 11 suites and 101 tests. It uses Node’s built-in node:test runner with node:assert/strict, so it adds no dependencies.

How to run it

Run the tests on Node.js 24 or later:

npm test

The suites

Each suite builds on the one before it, from building a Deva through to shutting it down.

Suite Tests What it proves
Build
00-build.test.js
1 build() makes a Deva that reaches ready.
Init
01-init.test.js
5 init() resolves with the ready data, waits for onReady, and a failing step or onError reject stops the chain.
Feature Getters
02-getters.test.js
31 Each feature getter returns exactly its own _key data as a copy, carries the client and its concerns, and answers offline after stop().
Hash
03-hash.test.js
10 The md5, sha256 and sha512 tiers match node:crypto, every hashing site carries all three, the uid fingerprint holds, and one changed field breaks every tier.
License
04-license.test.js
6 A matching VLA activates the Deva with stamped hashes; a changed, missing or absent VLA answers its message and stays inactive.
Messaging
05-messaging.test.js
13 question() runs local /commands and #ask calls to child Devas, child errors reach the asker right away, and missing or silent targets answer not found or timeout.
Shutdown
06-shutdown.test.js
11 stop() stops child Devas first, runs the full chain in order to onShutdown, clears features, answers pending asks offline and leaves nothing on the event bus.
Help
07-help.test.js
10 help() returns the right feecting section by file and part, answers help not found for a missing file or section as invalid and bad without an error or a good intent, and answers offline before init and after stop.
Error
08-error.test.js
10 err() rejects or hands off to onError without calling context(), talks one stamped error packet, and context() and contexts() read each Deva’s own vars.context, falling back safely when it is missing. A local method that rejects or throws rejects question() with one error packet, a child ask error is logged by both Devas, and an unknown feature is rejected.
Ready Hash
09-ready-hash.test.js
3 The ready hash is stable across Devas with identical functions, a func or method source change before ready changes the hash, and a listener added after ready with listen() does not change the stored ready hash.
Vocabulary
10-vocabulary.test.js
1 Two Devas in one process each keep their own agent zones, actions, states, intents, beliefs and messages, and neither mutates the shared base config.

Edge cases found and fixed

The suite found 6 edge cases. Each looks small on its own, but in a system of thousands of Devas any one of them becomes a real problem. All of them are fixed and covered by the tests.

Child errors reach the asker

A failing or throwing child Deva method now rejects the asker right away instead of waiting for the ask timeout. Fixed in version 1.64.7, tested in 05-messaging.test.js.

Pending asks at shutdown

A question still waiting on an answer when the Deva stops now resolves offline instead of hanging. Fixed in version 1.64.8, tested in 06-shutdown.test.js.

Parent stop reaches its children

A parent’s stop() now stops each child Deva through its full chain before the parent closes. Fixed in version 1.64.9, tested in 06-shutdown.test.js.

Missing help section

A missing section resolved help not found but kept going, threw, logged an error, and the finally block logged valid and good on both not-found paths. Fixed in version 1.64.25, tested in 07-help.test.js.

Ready hash covers _binding source strings

The ready hash is taken from the _binding source strings for func, methods, utils and listeners. It stays the same for identical functions, changes when a func or method source changes before ready, and a listener added after ready with listen() is left out of the stored hash. Fixed in version 1.64.46, tested in 09-ready-hash.test.js.

Vocabulary isolation

Each Deva shallow-copies config zones, actions, states, intents, beliefs and messages so custom agent entries stay on that Deva and the shared base config is not mutated. Fixed in version 1.64.52, tested in 10-vocabulary.test.js.