/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import type { ClusterBehavior } from "#behavior/cluster/ClusterBehavior.js"; import { ClientNode, Endpoint, InteractionServer, ServerNode } from "#index.js"; import { ClientStructure } from "#node/client/ClientStructure.js"; import { type Environment, type LogLevel } from "@matter/general"; import { Fabric, InteractionServerMessenger, InvokeResponseForSend, Message, ProtocolMocks, Val } from "@matter/protocol"; import { DelayReportData, NodeId, Status, TlvInvokeRequest, TlvInvokeResponseData, TlvReadRequest, TlvSubscribeRequest, TlvWriteRequest, TypeFromSchema } from "@matter/types"; import { MockServerNode } from "./mock-server-node.js"; /** * Wait until the given nodes have no activity in flight. * * Work a node performs in reaction to an event registers as activity only once the reactor runs, so a node can look * idle with work imminent. This yields task turns until every node reports itself idle, and never advances mock time * — a test that needs a timer to fire advances the clock itself, and doing so here would change what it observes. */ export declare function settled(...nodes: Array<{ env: Environment; }>): Promise; /** * Fail-safe length in seconds that {@link CommissioningHelper} arms during commissioning. */ export declare const FAILSAFE_LENGTH_S = 60; /** * Runs a factory reset on a node and checks the outcome with `expect`: previous online state resumed, basic information * present, unique id regenerated, pairing codes available, and the expected online/offline transitions seen. Closes the * node at the end. `mode` sets the starting state: `online` and `offline-after-commission` commission a node first; * `offline` uses an uncommissioned node that is never started; `offline-during-reset` stops the node while erase runs. */ export declare function testFactoryReset(mode: "online" | "offline-after-commission" | "offline" | "offline-during-reset"): Promise; /** * Returns helpers that commission a {@link MockServerNode} by invoking the commissioning commands directly on it, without a * real controller. `fabricNumber` holds the fabric index last used. */ export declare function CommissioningHelper(): { fabricNumber: number | undefined; /** * Runs the commissioning sequence up to and including AddNOC, leaving the fail-safe armed. Creates the node with * {@link MockServerNode.createOnline} if none is given. Returns the node, the exchange context used and the controller's * fabric. `index` selects the fabric index and the test authority. `exchange` continues a session that already * exists, such as one that armed the fail-safe; by default a new one is created. */ almostCommission(node?: MockServerNode, index?: number, exchange?: ProtocolMocks.Exchange): Promise<{ node: MockServerNode; context: { exchange: ProtocolMocks.Exchange; command: boolean; }; controllerFabric: Fabric; }>; /** * Runs {@link almostCommission}, then sends CommissioningComplete on a new session in the new fabric and waits until the node * is commissioned. `exchange` is passed to {@link almostCommission}. Returns the node, the context options for further calls * and the device's fabric. */ commission(existingNode?: MockServerNode, index?: number, exchange?: ProtocolMocks.Exchange): Promise<{ node: MockServerNode; contextOptions: { exchange: ProtocolMocks.Exchange; command: boolean; }; fabric: Fabric; }>; }; export declare namespace interaction { /** * Creates a mock messenger that captures the invoke response. */ /** * Creates a stub messenger that records the invoke response sent through it. `getResponse` returns it, or `undefined` if none was sent. */ function createInvokeMessenger(): { messenger: InteractionServerMessenger; getResponse: () => InvokeResponseForSend | undefined; }; /** * Minimal unicast message, enough for the interaction server handlers. */ const BarelyMockedMessage: Message; /** * Minimal group message, enough for the interaction server handlers. */ const BarelyMockedGroupMessage: Message; /** * Creates a mock secure session on the node in the given fabric. Returns its exchange and the node's interaction server. */ function connect(node: MockServerNode, fabric: Fabric): Promise<{ exchange: ProtocolMocks.Exchange; interactionServer: InteractionServer; }>; /** * Sends a single-item write request through the node's interaction server and discards the response. */ function write(node: MockServerNode, fabric: Fabric, request: TypeFromSchema["writeRequests"][number]): Promise; /** * Sends a single attribute read request. Returns the payload of the first attribute data of the response, or `undefined` if the first response item is not attribute data. */ function read(node: MockServerNode, fabric: Fabric, isFabricFiltered: boolean, request: Exclude["attributeRequests"], undefined>[number]): Promise; /** * Sends a single-item invoke request and calls `responder` with the first decoded invoke response, if any. `options.timed` runs it as a timed interaction. */ function invoke(node: MockServerNode, fabric: Fabric, request: TypeFromSchema["invokeRequests"][number], responder: (value: TypeFromSchema) => void, options?: { timed?: boolean; delayReportData?: DelayReportData; }): Promise; /** * Sends a subscribe request through the node's interaction server. The response is not captured. */ function subscribe(node: MockServerNode, fabric: Fabric, request: TypeFromSchema): Promise; /** * Waits for the node to initiate an exchange, expects a ReportData message, acknowledges it with a status response and returns the decoded report. */ function receiveDataReport(node: MockServerNode): Promise; attributeReports: import("@matter/types").OptionalFieldType; nodeId: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; attributeId: import("@matter/types").OptionalFieldType; listIndex: import("@matter/types").OptionalFieldType; wildcardPathFlags: import("@matter/types").OptionalFieldType>; wildcardFilterConfigurationVersion: import("@matter/types").OptionalFieldType; }>>; status: import("@matter/types").FieldType; clusterStatus: import("@matter/types").OptionalFieldType; }>>; }>>; attributeData: import("@matter/types").OptionalFieldType; path: import("@matter/types").FieldType; nodeId: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; attributeId: import("@matter/types").OptionalFieldType; listIndex: import("@matter/types").OptionalFieldType; wildcardPathFlags: import("@matter/types").OptionalFieldType>; wildcardFilterConfigurationVersion: import("@matter/types").OptionalFieldType; }>>; data: import("@matter/types").FieldType; }>>; }>[]>; eventReports: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; eventId: import("@matter/types").OptionalFieldType; isUrgent: import("@matter/types").OptionalFieldType; }>>; status: import("@matter/types").FieldType; clusterStatus: import("@matter/types").OptionalFieldType; }>>; }>>; eventData: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; eventId: import("@matter/types").OptionalFieldType; isUrgent: import("@matter/types").OptionalFieldType; }>>; eventNumber: import("@matter/types").FieldType; priority: import("@matter/types").FieldType; epochTimestamp: import("@matter/types").OptionalFieldType; systemTimestamp: import("@matter/types").OptionalFieldType; deltaEpochTimestamp: import("@matter/types").OptionalFieldType; deltaSystemTimestamp: import("@matter/types").OptionalFieldType; data: import("@matter/types").OptionalFieldType; }>>; }>[]>; moreChunkedMessages: import("@matter/types").OptionalFieldType; suppressResponse: import("@matter/types").OptionalFieldType; interactionModelRevision: import("@matter/types").OptionalFieldType; }>>; /** * Collects data reports from {@link receiveDataReport} until at least the given number of attribute reports and event reports arrived. A minimum of 0 means that kind is not waited for. */ function receiveData(node: MockServerNode, minAttributeCount: number, minEventCount: number): Promise<{ attributes: import("@matter/types").TypeFromFields<{ attributeStatus: import("@matter/types").OptionalFieldType; nodeId: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; attributeId: import("@matter/types").OptionalFieldType; listIndex: import("@matter/types").OptionalFieldType; wildcardPathFlags: import("@matter/types").OptionalFieldType>; wildcardFilterConfigurationVersion: import("@matter/types").OptionalFieldType; }>>; status: import("@matter/types").FieldType; clusterStatus: import("@matter/types").OptionalFieldType; }>>; }>>; attributeData: import("@matter/types").OptionalFieldType; path: import("@matter/types").FieldType; nodeId: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; attributeId: import("@matter/types").OptionalFieldType; listIndex: import("@matter/types").OptionalFieldType; wildcardPathFlags: import("@matter/types").OptionalFieldType>; wildcardFilterConfigurationVersion: import("@matter/types").OptionalFieldType; }>>; data: import("@matter/types").FieldType; }>>; }>[]; events: import("@matter/types").TypeFromFields<{ eventStatus: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; eventId: import("@matter/types").OptionalFieldType; isUrgent: import("@matter/types").OptionalFieldType; }>>; status: import("@matter/types").FieldType; clusterStatus: import("@matter/types").OptionalFieldType; }>>; }>>; eventData: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; eventId: import("@matter/types").OptionalFieldType; isUrgent: import("@matter/types").OptionalFieldType; }>>; eventNumber: import("@matter/types").FieldType; priority: import("@matter/types").FieldType; epochTimestamp: import("@matter/types").OptionalFieldType; systemTimestamp: import("@matter/types").OptionalFieldType; deltaEpochTimestamp: import("@matter/types").OptionalFieldType; deltaSystemTimestamp: import("@matter/types").OptionalFieldType; data: import("@matter/types").OptionalFieldType; }>>; }>[]; }>; } /** * Seed a peer's local cache as if the device had reported {@link values}, keyed by attribute ID. * * This is the only way for a test to install cached values a write cannot produce, such as a stale value for a * read-only attribute. */ export declare function seedPeerCache(peer: ClientNode, endpoint: Endpoint, type: ClusterBehavior.Type, values: Val.StructMap): Promise; /** * The client structure of a client node, for tests that feed it reports directly. */ export declare function clientStructureOf(peer: ClientNode): ClientStructure; /** * Waits, advancing mock time, until the controller's peer `id` has an active subscription, and returns the peer. Fails an * `expect` if the peer does not exist or has no subscription after about 10 s of mock time. */ export declare function subscribedPeer(controller: ServerNode, id: string): Promise; /** * The messages of the error a promise rejects with and of all of its causes, including aggregated ones. Endpoint * construction reports behavior failures as an aggregate. */ export declare function causeMessagesOf(promise: Promise): Promise; /** * Collects the text of log messages at or above {@link level} until disposed. */ export declare function captureLog(level: LogLevel): { messages: string[]; [Symbol.dispose](): void; }; //# sourceMappingURL=node-helpers.d.ts.map