Skip to content

Commit 7f1df37

Browse files
committed
test(golang): the untyped-field checker test skips with no guest, and shares Check's engine call
TestCheckerRefusesAnIndexedUntypedField handed NewChecker's error to t.Fatal, so `go test ./...` without the gitignored guest builds reported it as the module's one failure, where every other guest test skips. It calls guestOrSkip first now, and still runs through NewChecker, the constructor stashgen uses. Its "past Validate" half copied the engine part of Checker.Check, so the two could drift: a change to what Check sends se_plan_check would leave the test sending the old encoding and passing. That part of Check is now engineCheck, which Check and the test both call, and the test no longer imports vcffi. Addresses PR #1096 review comments 4203316804 and 4203316856.
1 parent 1acd6f7 commit 7f1df37

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

‎languages/golang/encrypt/checker.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ func (k *Checker) Check(ctx context.Context, plan *record.Plan) error {
4646
if err := plan.Validate(); err != nil {
4747
return fmt.Errorf("%w: %v", ErrEncoding, err)
4848
}
49+
return k.engineCheck(ctx, plan)
50+
}
51+
52+
// engineCheck asks se_plan_check alone, with no host rule first: the half
53+
// of Check that reaches the engine.
54+
func (k *Checker) engineCheck(ctx context.Context, plan *record.Plan) error {
4955
encoded, err := vcffi.Marshal(plan.Wire())
5056
if err != nil {
5157
return fmt.Errorf("%w: %v", ErrEncoding, err)

‎languages/golang/encrypt/guest_test.go‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/cipherstash/stack/languages/golang/auth"
2121
"github.com/cipherstash/stack/languages/golang/internal/guest"
2222
"github.com/cipherstash/stack/languages/golang/internal/record"
23-
"github.com/cipherstash/vitaminc/bindings/go/vcffi"
2423
"github.com/tetratelabs/wazero"
2524
"github.com/tetratelabs/wazero/sys"
2625
)
@@ -738,6 +737,7 @@ func TestGuestRefusesMalformedInputsBeforeState(t *testing.T) {
738737
// generator never emits such a declaration, so only a plan built by hand
739738
// reaches this. A sealed-only untyped field passes.
740739
func TestCheckerRefusesAnIndexedUntypedField(t *testing.T) {
740+
guestOrSkip(t)
741741
ctx := context.Background()
742742
checker, err := NewChecker(ctx)
743743
if err != nil {
@@ -760,14 +760,7 @@ func TestCheckerRefusesAnIndexedUntypedField(t *testing.T) {
760760
// stack-encrypt) and the guest reports it as the caller's input. The
761761
// ABI carries a status word and no message, so the field's name is
762762
// the Go rule's to give; this asserts the two rules agree.
763-
encoded, err := vcffi.Marshal(p.Wire())
764-
if err != nil {
765-
t.Fatal(err)
766-
}
767-
_, err = checker.c.call(ctx, func(inst *instance) ([]byte, error) {
768-
return inst.call(ctx, inst.planCheck, buf(encoded))
769-
})
770-
if !errors.Is(err, ErrEncoding) {
763+
if err := checker.engineCheck(ctx, p); !errors.Is(err, ErrEncoding) {
771764
t.Errorf("%s past Validate: err = %v, want ErrEncoding from the engine", name, err)
772765
}
773766
}

0 commit comments

Comments
 (0)