Skip to content

[v0.2.0] Property tests for AnvilBuilder.validate #67

Description

@neverDefined

Problem

Builder validation has reasonable manual cases in anvil_unit_test.go (TestAnvilBuilder_validate) but doesn't catch regressions when ranges change. A property-based pass would harden it.

Proposal

Use testing/quick (stdlib, no new deps) to fuzz the builder:

func TestAnvilBuilder_validate_property(t *testing.T) {
    f := func(chainID uint64, gasLimit uint64, port uint16) bool {
        b := NewAnvilBuilder().WithChainID(chainID).WithGasLimit(gasLimit).WithPort(int(port))
        _, err := b.Build()
        // ... assert validate's contract holds for the input ranges ...
    }
    require.NoError(t, quick.Check(f, &quick.Config{MaxCount: 1000}))
}

Goal: cover combinations the manual cases miss (e.g. WithBlockTime(0) + WithFork, port boundaries, gas limit overflow).

Acceptance criteria

  • One *_property test per builder method that has a non-trivial validation rule.
  • 1000+ runs in CI; should complete in <2s.
  • Any failure surfaces a counterexample via t.Errorf.

Out of scope

Don't replace the manual cases — they document intent. Property tests complement them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:testsTest coverage, benchmarks, error pathstype:choreHousekeeping, no user-visible change

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions