.agents/skills/testing/SKILL.md
Run and write unit tests for libatbus using the private test framework, including Windows DLL/PATH setup, test groups, encryption/compression tests, multi-node patterns, and shared memory notes.
npx skillsauth add owent/libatbus testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This repo uses a private unit testing framework (not GoogleTest).
The test executable is atbus_unit_test.
Common commands:
./atbus_unit_test./atbus_unit_test -l / ./atbus_unit_test --list-tests./atbus_unit_test -r <group> or ./atbus_unit_test -r <group>.<case>./atbus_unit_test -f "pattern*" / ./atbus_unit_test --filter "pattern*"./atbus_unit_test -h, ./atbus_unit_test -vOn Windows, atbus_unit_test.exe (and samples) may fail to start if dependent DLLs cannot be found.
Preferred approach: prepend DLL directories to PATH for the current run/debug session.
Typical DLL directories in the monorepo/toolset layout:
<BUILD_DIR>\\publish\\bin\\<Config><REPO_ROOT>\\third_party\\install\\windows-amd64-msvc-19\\binExample (PowerShell):
$buildDir = "<BUILD_DIR>"$cfg = "Debug"$env:PATH = "$buildDir\\publish\\bin\\$cfg;$buildDir\\publish\\bin;${PWD}\\third_party\\install\\windows-amd64-msvc-19\\bin;" + $env:PATHSet-Location "$buildDir\\_deps\\atbus\\test\\$cfg"./atbus_unit_test.exe -latbus_node_msg) — 24 testsCore message delivery, crypto configuration, and multi-hop routing:
ping_pong — Heartbeat exchange with timing validationcustom_cmd / custom_cmd_by_temp_node / send_cmd_to_self — Custom command round-tripreset_and_send — Direct self-send via callbackupstream_and_downstream — Tree topology message deliverytransfer_and_connect / transfer_only — Proxy forwardingsend_failed / transfer_failed / transfer_failed_cross_upstreams — Error handlingsend_msg_to_self_and_need_rsp — Response flag (REQUIRE_RSP) and response callbacktopology_registry_multi_level_route / ..._reverse — Multi-hop routing through 3-level hierarchymsg_handler_get_body_name — Body type name resolutioncrypto_config_key_exchange_algorithms — Tests X25519, SECP256R1, SECP384R1crypto_config_cipher_algorithms — Tests AES-128/192/256 CBC/GCM, XXTEA, ChaCha20crypto_config_comprehensive_matrix — All crypto combination matrixcrypto_config_multiple_algorithms — Multiple algorithms at oncecrypto_config_upstream_downstream — Crypto across topologycrypto_config_disabled — Plaintext operationcrypto_list_available_algorithms — Algorithm enumerationatbus_node_reg) — 22 testsRegistration flow, timeout, access tokens, channel types:
reset_and_send_tcp — Basic TCP registration handshaketimeout — Registration timeout and recoverymessage_size_limit — Large message handlingreg_pc_success / reg_pc_success_cross_subnet / reg_pc_failed_with_subnet_mismatch — Point-to-point registrationreg_bro_success — Broadcast discoveryreg_failed_with_mismatch_access_token / reg_failed_with_missing_access_token — Token validationconflict / destruct / reconnect_upstream_failed — Lifecycle edge caseson_close_connection_normal / on_close_connection_by_peer — Connection close callbacksmem_and_send / shm_and_send — Memory/shared memory channel testson_topology_upstream_set / on_topology_upstream_clear / on_topology_upstream_change_id — Topology eventsset_hostname — Hostname configurationatbus_connection_context) — 37 testsEncryption/compression handshake, pack/unpack, all algorithm combinations:
padding_* (9 tests) — Buffer allocation alignment and overhead validationcreate_* (4 tests) — Context creation with various key exchange typesget_* / is_* (3 tests) — Property getters and algorithm support checksupdate_compression_algorithm_* (2 tests) — Compression config updateshandshake_* (7 tests) — Key generation, public key exchange, complete flowpack_unpack_* (5 tests) — Message round-trip with/without encryption/compressionall_*_algorithms_* / comprehensive_crypto_matrix — Full algorithm combination coverageaead_ciphers_verification / non_aead_ciphers_verification — AEAD vs non-AEAD validationkey_renegotiation_flow — Key refresh scenariosbidirectional_encrypted_communication — Full duplex encrypted channelatbus_message_handler) — 16 testsAccess data plaintext format, HMAC-SHA256 signatures:
make_access_data_plaintext_crypto_* — Plaintext format: timestamp:nonce1-nonce2:bus_id[:type:hash]make_access_data_plaintext_custom_command_* — Command hash inclusioncalculate_access_data_signature_* — HMAC-SHA256 computation with various inputsgenerate_access_data_* — Full access_data generation with tokensintegration_* — Plaintext-signature consistency and determinismatbus_topology) — 9 teststopology_peer_basic / topology_peer_downstream_iteration — Peer creation and iterationtopology_registry_relations — Self/upstream/downstream relation typestopology_registry_update_and_remove — Peer lifecycletopology_registry_*_auto_removed_* — Proactive vs passive peer removaltopology_registry_foreach_and_policy — Iteration and policiestopology_registry_update_peer_cycle_detection — Loop preventionchannel_io_stream_tcp) — 8 testsio_stream_tcp_basic / io_stream_tcp_reset_by_client / io_stream_tcp_reset_by_serverio_stream_tcp_size_extended (>64KB) / io_stream_tcp_connect_failedchannel_io_stream_unix) — 5 tests (non-Windows)io_stream_unix_basic / io_stream_unix_reset_* / io_stream_unix_size_extendedchannel_mem) — 5 testsmem_attach_with_invalid_* — Magic/version/alignment validationmem_siso / mem_miso — Single/multi-input-single-output ring bufferchannel_shm) — 6 testsshm_attach_with_invalid_* — Validation checksshm_siso — SHM ring buffer round-tripbuffer (11 tests) — Varint encoding, static/dynamic buffer manager modesatbus_endpoint (5 tests) — Connection retrieval, address type parsingatbus_node_relationship (3 tests) — FlatBuffers message, conf copy, endpoint opsatbus_node_setup (3 tests) — Listen override, algorithm enumerationlibatbus_error (6 tests) — Error code to string mappingatbus_connection_context_crosslang (10 tests) — Binary enc/dec test vector generationatbus_access_data_crosslang (9 tests) — Auth signature test vector generationTest files are under test/case/.
#include <frame/test_macros.h>
#include "atbus_node.h"
CASE_TEST(my_group, my_test) {
CASE_EXPECT_EQ(1, 1);
}
CASE_TEST(atbus_node_msg, my_multi_node_test) {
// 1. Setup libuv event loop
uv_loop_t ev_loop;
uv_loop_init(&ev_loop);
// 2. Configure nodes
atbus::node::conf_t conf;
atbus::node::default_conf(&conf);
conf.ev_loop = &ev_loop;
conf.receive_buffer_size = 64 * 1024;
conf.ping_interval = std::chrono::seconds{8};
// 3. Create and initialize nodes
auto node1 = atbus::node::create();
auto node2 = atbus::node::create();
node1->init(0x12345678, &conf);
node2->init(0x12356789, &conf);
// 4. Listen on addresses
node1->listen("ipv4://127.0.0.1:16387");
node2->listen("ipv4://127.0.0.1:16388");
// 5. Start nodes
atbus::node::start_conf_t start_conf;
start_conf.timer_timepoint = unit_test_make_timepoint(0, 0);
node1->start(start_conf);
node2->start(start_conf);
// 6. Connect and wait
node2->connect("ipv4://127.0.0.1:16387");
time_t proc_usec = 0;
UNITTEST_WAIT_UNTIL(ev_loop,
node1->is_endpoint_available(0x12356789), 8000, 8) {
++proc_usec;
node1->proc(unit_test_make_timepoint(0, proc_usec));
node2->proc(unit_test_make_timepoint(0, proc_usec));
}
CASE_EXPECT_TRUE(node1->is_endpoint_available(0x12356789));
// 7. Send and verify
// ... setup callbacks, send data, verify receipt ...
// 8. Cleanup
unit_test_setup_exit(&ev_loop);
}
CASE_TEST(atbus_connection_context, my_crypto_test) {
// 1. Init crypto globally
atfw::util::crypto::cipher::init_global_algorithm();
// 2. Create DH shared context
auto dh_ctx = atfw::util::crypto::dh::shared_context::create("x25519");
// 3. Create client/server connection contexts
auto client_ctx = atbus::connection_context::create(
protocol::ATBUS_CRYPTO_KEY_EXCHANGE_X25519, dh_ctx);
auto server_ctx = atbus::connection_context::create(
protocol::ATBUS_CRYPTO_KEY_EXCHANGE_X25519, dh_ctx);
// 4. Perform handshake (see libatbus-protocol-crypto skill for full flow)
// ...
// 5. Pack encrypted message
atbus::random_engine_t rng;
auto packed = client_ctx->pack_message(msg, 3, rng, 65536);
CASE_EXPECT_TRUE(packed.is_success());
// 6. Unpack and verify
atbus::message recv_msg;
CASE_EXPECT_EQ(EN_ATBUS_ERR_SUCCESS,
server_ctx->unpack_message(recv_msg, packed.get_success().as_span(), 65536));
// 7. Cleanup
atfw::util::crypto::cipher::cleanup_global_algorithm();
}
// Wait until condition is true (or timeout in ms)
UNITTEST_WAIT_UNTIL(uv_loop, condition, timeout_ms, tick_ms) {
// Body executed each tick
node->proc(timepoint);
}
// Wait while condition is true
UNITTEST_WAIT_IF(uv_loop, condition, timeout_ms, tick_ms) { ... }
// Wait fixed duration
UNITTEST_WAIT_MS(uv_loop, timeout_ms, tick_ms) { ... }
// Time point helper
auto tp = unit_test_make_timepoint(seconds, microseconds);
ipv4://127.0.0.1:PORT or ipv6://[::1]:PORTunix:///tmp/path.sock (3 slashes)mem://0xADDRESS (single process, pointer-based)shm://NAME (cross-process)pipe:///pathdevelopment
libatbus protocol transport, ECDH key exchange, encryption/compression algorithm negotiation, message pack/unpack, and access token authentication. Use when working with connection_context, handshake flow, cipher algorithms, compression, message framing, or writing crypto-related tests.
development
Configure and build libatbus with CMake, including key options for shared libs and bus ID type.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.