feat(protocol): define strict first-slice wire contracts
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
FIRST_SLICE_RPC_ROUTE,
|
||||
routeForFirstSlice,
|
||||
} from '../../YouleNexus/assets/framework/protocol/first-slice-routes.ts';
|
||||
|
||||
test('FIRST_SLICE_RPC_ROUTE 是第一纵向切片唯一且精确的 rpc route 表', () => {
|
||||
assert.deepEqual(FIRST_SLICE_RPC_ROUTE, {
|
||||
player_login: 'agent',
|
||||
self_join_room: 'agent',
|
||||
player_prepare: 'room',
|
||||
self_exit_room: 'room',
|
||||
other_join_room: 'room',
|
||||
other_exit_room: 'room',
|
||||
other_offline: 'room',
|
||||
other_online: 'room',
|
||||
connect_roomserver: 'room',
|
||||
connect_agentserver: 'agent',
|
||||
kick_server: 'agent',
|
||||
});
|
||||
});
|
||||
|
||||
test('routeForFirstSlice 从单源映射取 route,未知 rpc 显式失败', () => {
|
||||
assert.equal(routeForFirstSlice('self_join_room'), 'agent');
|
||||
assert.equal(routeForFirstSlice('connect_roomserver'), 'room');
|
||||
assert.throws(
|
||||
() => routeForFirstSlice('unknown_rpc' as never),
|
||||
/unknown_rpc/,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user