test(scratch-vm): 甲子園 実サーバーのゴールデン記録 + 契約テスト基盤#745
Open
takaokouji wants to merge 2 commits into
Open
Conversation
…al server 過去にゲームサーバー再実装が「仕様不明確」で頓挫した反省を踏まえ、実ゲームサーバーの 挙動をゴールデン JSON として記録し、クライアントが従うべき契約をテストで固定する基盤を 追加する (#740)。 - tmp/smalruby-koshien/game_server (Ruby 3.1) の in-process API ドライバ (SpecHelper::Server) を流用した記録ドライバで、決定的シナリオ (SK_RANDOM_SEED=1) を 実行し各 API の返り値を fixture 化: - move_basic: move_to は予約で、座標は turnTransition 後に確定 (before [1,1] → after [2,1]) - get_map_area: getMapArea は 15x15 の自分マップ (未探索 -1) + enemy + other_player を返す - two_actions: 1 ターン 2 行動 (move + getMapArea) - test/unit/extensions/koshien_golden_contract.js (tap): 上記の実挙動を検証し、 将来の RemoteClient (#741) が replay できる契約の基盤とする。 - 記録ドライバ/サーバー起動手順は notes/koshien に整備 (git 管理外)。 Refs #740 / Epic #738 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/feature/issue-740-koshien-golden-contract/ |
10 tasks
…level) test:unit は `tap ./test/unit/*.js`(再帰なし)のため test/unit/extensions/ 配下の テストが CI で実行されていなかった。golden contract テストを top-level へ移動して 確実に走らせる(require パス修正・prettier ホワイトリスト/マーカー更新)。51 assert pass。 Refs #740 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
過去にゲームサーバー再実装が「仕様が不明確」で頓挫した反省を踏まえ、実ゲームサーバーの挙動をゴールデン JSON として記録し、クライアントが従うべき契約をテストで固定する基盤を追加します。Epic #738 / #740。
どうやって記録したか
tmp/smalruby-koshien/game_server(実ゲームサーバー, Ruby)の in-process API ドライバ(サーバー自身の RSpec が使うSpecHelper::Server)を流用し、決定的シナリオ(SK_RANDOM_SEED=1)を実行して各 API の返り値を JSON 化しました。レガシーな Windows 向けコードを Ruby 3.1 で動かすための移植手順・記録ドライバはプロジェクトノート(git 管理外)に整備済みです。Changes Made
test/fixtures/koshien/golden/*.json— 実サーバーのゴールデン記録:move_toは予約で、座標はturnTransition後に確定(before[1,1]→ after[2,1])getMapAreaは 15x15 の自分マップ(未探索-1)+enemy+other_playerを返す(※5x5 ではない、という実挙動を記録)move_to+getMapArea)test/fixtures/koshien/golden/README.md— 出自・再生成方法・実挙動メモtest/unit/extensions/koshien_golden_contract.js(tap)— ゴールデンの実挙動を検証(構造の健全性 + 移動の予約セマンティクス + マップ形状)。将来のRemoteClient(feat(scratch-vm): 甲子園 実ゲームサーバー通信モード(RemoteClient) #741)が replay する契約の基盤。なぜ MockClient と比較しないのか
MockClient(#739)は未接続時用に固定値を返すため、実サーバーのシナリオ応答とは一致しません(意図的)。本 PR は 実挙動を検証済み fixture として固定し、RemoteClient(#741)実装時にそれへの一致を assert できるようにする基盤です。Test Coverage
koshien_golden_contract.js: tap 51 assertions pass。Definition of Done
Related Issues
Refs #740 / Epic #738
🤖 Generated with Claude Code