Files
youle_cocos/cocoscreator_projects/framework-tests/protocol/first-slice-routes.test.ts
T
joywayer 35216f75e7 feat: integrate room framework and isolated subgame bundles
Complete room UI and protocol integration, move game definitions and resources behind bundle entries, publish authoritative version XML, and document single-game builds. Include all current resource changes and experiment artifacts.
2026-09-09 03:13:18 +08:00

54 lines
1.9 KiB
TypeScript

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, {
broadcast: 'agent',
beanroom_surrender:'room',send_text:'room',send_voice:'room',send_phiz:'room',self_break_room:'room',other_break_room:'room',change_room:'room',change_seat:'room',
self_apply_free_room:'room',other_apply_free_room:'room',
self_agree_free_room:'room',other_agree_free_room:'room',
self_refuse_free_room:'room',other_refuse_free_room:'room',free_room:'room',
getVipRankList: 'agent',
get_treasurelist: 'agent',
topup_card: 'agent',
update_bean: 'agent',
get_player_invitecode: 'agent',
binding_invitecode: 'agent',
getInfoByShortCode: 'agent',
get_player_task: 'agent',
get_task_award: 'agent',
update_roomcard: 'agent',
player_finish_task: 'agent',
player_login: 'agent',
create_room: 'agent',
self_join_room: 'agent',
player_prepare: 'room',
// docs/protocol/03-协议-room路由.md; legacy Net → Desk → StartWar receives the full packet.
self_makewar: 'room',
other_makewar: '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',
kick_offline: 'agent',
show_message: '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/,
);
});