修复构建阻塞与过期测试,补 npm test 入口 (WORK-20) - #2
Open
lbtsm wants to merge 3 commits into
Open
Conversation
The old test read src/chain/sol/handler.ts as a string and asserted that 13 exact source lines appeared in it. handler.ts has since moved 'from' to publicKeyToBytes() and the numeric fields to normalizeEventNumberHex(), so every one of those assertions was stale and the test failed on main. Rather than refresh the string literals — which would only buy time until the next refactor — the test now drives SolEventHandler.crossOut / crossIn and asserts the mos row that actually gets persisted: base58 vs raw-bytes shape for user/from, even-length unprefixed hex for chain ids and amounts, the '00' defaults when optional CrossIn fields are absent, the RefundEvent flag, the unsupported-bridgeMint alarm path, and the bridge api query. It survives a rename and it fails when the mapping is wrong, which the text version could not distinguish. Stubs replace the module exports (insertMos / requestBridgeData / alarm), the same technique mysql_duplicate_test.js already uses, so no network or database is touched. No business code was changed — the assertions were brought up to the source, not the reverse. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
test/ held 7 standalone Node assert scripts with no way to run them as a set:
package.json had no test script, and most of them require('../app/...') so they
silently fail unless the tree is built first.
scripts/run-tests.sh builds, then runs each script as its own process, prints
PASS/FAIL per file plus a total, and exits non-zero if any failed — so it can
gate CI. Output of passing tests is swallowed and only failures are echoed,
because these scripts are very chatty on stdout.
No test framework: the scripts are top-level asserts, not node:test cases, so
'exit 0 means pass' is the whole contract and jest/mocha/vitest would each
require rewriting all 7. SKIP_BUILD=1 reuses an existing app/ build.
Co-Authored-By: Claude Opus 5 (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.
修复 compass-ts 构建阻塞与过期测试,补
npm test入口(WORK-20)。内容与 #1 完全相同(两者 tree 逐字节一致),但历史已重写:#1 的基线提交里误入了一个硬编码的 XRP 钱包 seed,本分支直接从不含该文件的干净基线上重放了测试提交,seed 不在本分支任何一个提交中。
改动
test/sol_handler_saved_fields_test.js— 原测试把handler.ts当纯文本读、断言 13 行源码原文,且这 13 条全部过期。改成行为断言:直接驱动SolEventHandler.crossOut/crossIn,断言真正落库的 mos 记录,8 个用例。没有改任何业务代码。scripts/run-tests.sh+package.json的"test"script — 一次跑完test/下 7 个脚本,给出 PASS/FAIL 汇总和正确退出码。没引入 jest / mocha / vitest,也没改用node --test。package-lock.json未修改,npm audit的漏洞面原样不动。src/chain/sol/sync.ts、src/utils/time.ts、test/sol_sync_retry_test.js三个文件来自 runtime 固化的本地未提交改动,不是本单的工作,合并前请确认是否本来就该进 main。验收
npm run typecheck/npm run build/npm test三条均退出码 0,7 个测试全 PASS。验证入口:
npm ci && npm run typecheck && npm run build && npm test