mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5345] [MERGED] Test-quality audit: fix 2 prod bugs, strengthen weak tests, add mutation/fuzz/CI tooling #5852
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5852
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5345
Author: @MHSanaei
Created: 6/15/2026
Status: ✅ Merged
Merged: 6/15/2026
Merged by: @MHSanaei
Base:
main← Head:chore/test-audit📝 Commits (10+)
a10cb76test(audit): add gremlins/rapid/coverage tooling + AUDIT.md scaffold06ec03etest(audit): hygiene sweep (race-clean except logger global; Finding #2) + smell inventory9d4062btest(audit): cover untested error/edge branches (TLS proxy+pin, migration tag cleanup=Finding #1)90d2a57test(audit): strengthen internal/sub link tests (dedup key, TLS/Reality mapping, clash well-formedness)3df4b7atest(audit): property (rapid) + fuzz tests for joinHostPort/userinfo/pin/ParseLink35a52d9test(audit): tighten frontend subSortIndex rejection assertions + wire coverage144b7b2ci(audit): add shuffle gate + non-blocking race job (Finding #2) + fuzz-smoke; document mutation policyc40bb92chore(audit): gitignore frontend coverage outputc216cbetest(audit): exhaustive whole-repo pass — strengthen 5 weak/fake tests (netproxy, CSP, modal per-protocol loops, schema coercions)0803f81docs(contributing): add Testing section (conventions, race/shuffle, fuzz, mutation policy); drop AUDIT.md ledger📊 Changes
37 files changed (+2580 additions, -330 deletions)
View changed files
📝
.github/workflows/ci.yml(+34 -1)➕
.github/workflows/mutation.yml(+62 -0)📝
CONTRIBUTING.md(+43 -0)📝
frontend/.gitignore(+1 -0)📝
frontend/package-lock.json(+171 -0)📝
frontend/package.json(+2 -1)➖
frontend/src/test/__snapshots__/inbound-form-modal.test.tsx.snap(+0 -161)➖
frontend/src/test/__snapshots__/outbound-form-modal.test.tsx.snap(+0 -141)📝
frontend/src/test/inbound-form-adapter.test.ts(+12 -2)📝
frontend/src/test/inbound-form-modal.test.tsx(+19 -4)📝
frontend/src/test/outbound-form-modal.test.tsx(+21 -3)📝
frontend/src/test/protocols.test.ts(+32 -0)📝
go.mod(+1 -0)📝
go.sum(+2 -0)➕
internal/config/config_mutation_test.go(+75 -0)📝
internal/logger/logger.go(+22 -5)➕
internal/logger/logger_test.go(+30 -0)➕
internal/mtproto/manager_mutation_test.go(+99 -0)📝
internal/sub/clash_service_test.go(+72 -0)➕
internal/sub/mutation_audit_test.go(+484 -0)...and 17 more files
📄 Description
Summary
A test-quality audit of the existing suites: hunt for "fake green" tests (pass but don't guard behavior), strengthen them, and back it with objective mutation testing (gremlins). The deliverable is stronger tests — every strengthening was verified by mutating the production line and confirming the test fails.
No production logic was changed to satisfy a test. The only non-test prod changes are 2 genuine bug fixes (below) and one redundant dead-branch removal.
Production bug fixes (found by the audit)
internal/logger: the in-memorylogBuffer(written byaddToBuffer, read byGetLogs) had no synchronization, so concurrent logging (cron jobs, the websocket hub, HTTP handlers) raced. Guarded with async.Mutex. The whole repo is now clean undergo test -race -shuffle.internal/web/service/inbound_migration.go: the legacy0.0.0.0:tag cleanup usedtx.Raw(...), which builds but never executes a non-SELECT statement, so the prefix was never stripped. Changed totx.Exec(...).Test strengthening (mutation efficacy, before → after, gremlins)
internal/util/commoninternal/util/netsafeinternal/web/middlewareinternal/web/runtimeinternal/xrayinternal/mtprotointernal/subinternal/util/linkinternal/databaseHighlights: share-link field mapping (TLS/Reality), the dedup key, clash reality/tcp config, JSON-subscription mux/finalmask, node
baseURLscheme/port-bounds + egress/content-type, xray hot-diff/process branches, link parser helpers. Remaining survivors are a documented long tail + equivalent mutants (e.g. timeout constants) that shouldn't be chased.New tests & tooling
pgregory.net/rapid):joinHostPortbracketing,encodeUserinforound-trip,DecodeCertPinformat-agnosticism,splitLinkLines.FuzzParseLink(share-link parser) andFuzzDecodeCertPin— seed corpora run under plaingo test; timed exploration runs as a CI smoke step.@vitest/coverage-v8.CI
go-testnow runs-shuffle=on -count=1.racejob (-race -shuffle -count=1) — a hard gate (the repo is race-clean after the logger fix).fuzz-smokejob on the critical parsers.mutation.yml— nightly/on-demand scoped gremlins, results uploaded as artifacts (informational, not a gate).Docs
CONTRIBUTING.mdgains a Testing section: conventions, how to run race/shuffle/coverage/fuzz, and the scoped mutation-testing policy.Verification
go build ./...✅ ·go test -race -shuffle=on -count=1 ./...→ 0 FAIL ✅ ·go vet✅test(537) +typecheck+lint✅golang:1.26runs).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.