typegen

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package typegen generates random SSZ-compatible Go struct definitions for fuzz testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	NumTypes     int  // Number of top-level types to generate
	MaxFields    int  // Maximum fields per struct
	MaxDepth     int  // Maximum nesting depth
	MaxArrayLen  int  // Maximum fixed array length
	MaxListLimit int  // Maximum list ssz-max value
	Extended     bool // Generate extended types (signed ints, floats, big.Int, optional)
	Seed         int64
}

Config controls the type generation parameters.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a reasonable default configuration.

type FieldDef

type FieldDef struct {
	Name    string
	GoType  string
	Tags    string
	Imports []string // package import paths needed
}

FieldDef represents a single field in a generated struct.

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator generates random SSZ-compatible Go struct types.

func NewGenerator

func NewGenerator(cfg Config) *Generator

NewGenerator creates a new type generator.

func (*Generator) Generate

func (g *Generator) Generate() []TypeDef

Generate creates the configured number of random types. Returns the generated type definitions.

func (*Generator) WriteGoSource

func (g *Generator) WriteGoSource(packageName string) string

WriteGoSource writes all generated types as valid Go source code.

func (*Generator) WriteRegistry

func (g *Generator) WriteRegistry(packageName string) string

WriteRegistry generates a registry_gen.go that populates corpus.Registry.

type TypeDef

type TypeDef struct {
	Name     string
	Fields   []FieldDef
	Extended bool // whether this type uses extended types
}

TypeDef represents a generated struct definition.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL