• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rustymotors / server / 27998838094

23 Jun 2026 02:51AM UTC coverage: 45.083% (+0.8%) from 44.3%
27998838094

push

github

drazisil
Add handler-level tests for relay routing and start broadcast

Tests use vi.hoisted + vi.mock('rusty-motors-shared', importOriginal) to
intercept getSocketQueue/getChannelMembers/getConnectionIdByUserId/databaseProvider
without disrupting real ChannelMembership state or other shared utilities.

Covers:
- handleSendSingleLong: delivers rewritten 16-byte envelope to target, skips self/unknown
- handleSendBuddyLong: same routing contract verified independently (opcode 0x93)
- handleSendNotSingleLong: broadcasts to all members except sender and excluded user
- handleStartGameServer: returns 3 packets to host, pushes all 3 to peers via queue,
  throws on missing userId

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

703 of 1760 branches covered (39.94%)

Branch coverage included in aggregate %.

4184 of 9080 relevant lines covered (46.08%)

133.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/packages/shared/src/SubThread.ts
1
/**
2
 * @module SubThread
3
 */
4

5
import { EventEmitter } from "node:events";
6
import { type ServerLogger, getServerLogger } from "rusty-motors-shared";
7

8

9
export class SubThread extends EventEmitter {
10
        name: string;
11
        log: ServerLogger;
12
        loopInterval: number;
13
        timer: NodeJS.Timeout | null;
14
        /**
15
         * @param {string} name
16
         * @param {erverLogger} log
17
         * @param {number} [loopInterval=100]
18
         */
19
        constructor(
20
                name: string,
21
                log: ServerLogger = getServerLogger( "SubThread"),
2✔
22
                loopInterval: number = 100,
2✔
23
        ) {
24
                super();
2✔
25
                this.name = name;
2✔
26
                this.log = log;
2✔
27
                this.loopInterval = loopInterval;
2✔
28
                this.timer = null;
2✔
29
                this.init();
2✔
30
        }
31

32
        init() {
33
                this.emit("initialized");
2✔
34
                // @ts-ignore
35
                this.timer = setInterval(this.run.bind(this), this.loopInterval);
2✔
36
        }
37

38
        run() {
39
                // Intentionally left blank
40
        }
41

42
        shutdown() {
43
                if (this.timer) {
×
44
                        clearInterval(this.timer);
×
45
                }
46
                this.emit("shutdownComplete");
×
47
        }
48
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc