Skip to content

Commit

Permalink
refactor: move __internalIsMockNode to CCParsingContext
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Oct 14, 2024
1 parent b3981fa commit c08f8de
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/cc/src/cc/Security2CC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,7 @@ export class Security2CCMessageEncapsulation extends Security2CC {
&& prevSequenceNumber != undefined
&& this["_sequenceNumber"] === ((prevSequenceNumber + 1) & 0xff)
// And in case of a mock-based test, do this only on the controller
&& !this.host.__internalIsMockNode
&& !ctx.__internalIsMockNode
) {
const nonce = spanState.currentSPAN.nonce;
spanState.currentSPAN = undefined;
Expand Down
3 changes: 1 addition & 2 deletions packages/host/src/ZWaveHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface CCParsingContext
extends Readonly<SecurityManagers>, GetDeviceConfig, HostIDs
{
sourceNodeId: number;
__internalIsMockNode?: boolean;

/** If known, the frame type of the containing message */
frameType?: FrameType;
Expand Down Expand Up @@ -112,8 +113,6 @@ export interface ZWaveHost {
nodeId: number,
endpointIndex?: number,
): boolean;

__internalIsMockNode?: boolean;
}

/** Host application abstractions that provide support for reading and writing values to a database */
Expand Down
5 changes: 1 addition & 4 deletions packages/host/src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ export type BaseTestNode =
export type TestingHost<
TNode extends BaseTestNode,
> =
& Omit<
ZWaveApplicationHost<TNode>,
"__internalIsMockNode"
>
& ZWaveApplicationHost<TNode>
& {
setNode(nodeId: number, node: TNode): void;
};
Expand Down
1 change: 0 additions & 1 deletion packages/testing/src/MockNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export class MockNode {
// A node's host is a bit more specialized than the controller's host.
this.host = {
...this.controller.host,
__internalIsMockNode: true,
// // Mimic the behavior of ZWaveNode, but for arbitrary node IDs
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function createLazySendDataPayload(
origin: MessageOrigin.Host,
context: {
sourceNodeId: node.id,
__internalIsMockNode: true,
...node.encodingContext,
...node.securityManagers,
},
Expand Down

0 comments on commit c08f8de

Please sign in to comment.