From f8e3baf43917fc187cade56c5fdac1ca0b6fd3f0 Mon Sep 17 00:00:00 2001 From: PJ Date: Mon, 1 Jun 2026 16:59:18 +0530 Subject: [PATCH] refactor(runner): decode V8 actions via the unified DecodeAction; wire goja runtime --- internal/runner/runner.go | 48 +++---------------------------------- internal/testrun/testrun.go | 4 ++-- 2 files changed, 5 insertions(+), 47 deletions(-) diff --git a/internal/runner/runner.go b/internal/runner/runner.go index f9bd273..2368b85 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -778,51 +778,9 @@ func nextActionFromV8(ctx context.Context, web driver.WebDriver) (verifier.Actio if err != nil { return verifier.Action{}, fmt.Errorf("v8 next action: %w", err) } - if len(raw) == 0 || string(raw) == "null" { - return verifier.Action{}, verifier.ErrNoAction - } - var decoded struct { - Kind string `json:"kind"` - X int `json:"x"` - Y int `json:"y"` - FromX int `json:"from_x"` - FromY int `json:"from_y"` - ToX int `json:"to_x"` - ToY int `json:"to_y"` - Key string `json:"key"` - Text string `json:"text"` - DurationMillis int `json:"duration_millis"` - } - if err := json.Unmarshal(raw, &decoded); err != nil { - return verifier.Action{}, fmt.Errorf("decode v8 action: %w", err) - } - switch decoded.Kind { - case "Tap": - return verifier.Action{Kind: verifier.ActionKindTap, X: decoded.X, Y: decoded.Y}, nil - case "DoubleTap": - return verifier.Action{Kind: verifier.ActionKindDoubleTap, X: decoded.X, Y: decoded.Y}, nil - case "InputText": - return verifier.Action{ - Kind: verifier.ActionKindInputText, - X: decoded.X, Y: decoded.Y, - Text: decoded.Text, - }, nil - case "Swipe": - return verifier.Action{ - Kind: verifier.ActionKindSwipe, - FromX: decoded.FromX, - FromY: decoded.FromY, - ToX: decoded.ToX, - ToY: decoded.ToY, - DurationMillis: decoded.DurationMillis, - }, nil - case "PressKey": - return verifier.Action{Kind: verifier.ActionKindPressKey, Key: decoded.Key}, nil - case "Wait": - return verifier.Action{Kind: verifier.ActionKindWait, DurationMillis: decoded.DurationMillis}, nil - default: - return verifier.Action{}, verifier.ErrNoAction - } + // Both engines emit the unified flat camelCase wire contract; one decoder + // reads it. A null payload means the generator declined to act this tick. + return verifier.DecodeAction(raw) } // collectWitnesses gathers the violation witness for each newly-violated diff --git a/internal/testrun/testrun.go b/internal/testrun/testrun.go index 04eae81..ab01eb7 100644 --- a/internal/testrun/testrun.go +++ b/internal/testrun/testrun.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "math/rand/v2" "os" "path/filepath" "strconv" @@ -110,7 +109,8 @@ func Execute(ctx context.Context, options Options, stdout io.Writer) error { } verifierInstance, err := verifier.New( - verifier.WithRand(rand.New(rand.NewPCG(uint64(seed), 0))), + verifier.WithSeed(uint64(seed)), + verifier.WithPlatform(options.Platform), verifier.WithAppPackage(options.BundleID), ) if err != nil {