Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssertionTestingConfig ¶
type AssertionTestingConfig struct {
// Enabled describes whether testing is enabled.
Enabled bool `json:"enabled"`
// PanicCodeConfig describes the various panic codes that can be enabled and be treated as a "failing case"
PanicCodeConfig PanicCodeConfig `json:"panicCodeConfig"`
}
AssertionTestingConfig describes the configuration options used for assertion testing
type ConsoleLoggingConfig ¶ added in v0.1.1
type ConsoleLoggingConfig struct {
// Enabled describes whether console logging is enabled.
Enabled bool `json:"enabled"`
}
ConsoleLoggingConfig describes the configuration options for logging to console. Note that this not being used right now but will be added to LoggingConfig down the line TODO: Update when implementing a structured logging solution
type ContractBalance ¶ added in v1.2.0
ContractBalance wraps big.Int to provide custom JSON marshaling/unmarshaling for contract balance values in different numeric formats
func (ContractBalance) MarshalJSON ¶ added in v1.2.0
func (cb ContractBalance) MarshalJSON() ([]byte, error)
MarshalJSON marshals a ContractBalance to JSON.
func (*ContractBalance) UnmarshalJSON ¶ added in v1.2.0
func (cb *ContractBalance) UnmarshalJSON(data []byte) error
UnmarshalJSON parses JSON data into big.Int from empty strings, hex ("0x"), scientific notation (e/E), and base-10 formats
type FileLoggingConfig ¶ added in v0.1.1
type FileLoggingConfig struct {
// LogDirectory describes what directory log files should be outputted in. LogDirectory being a non-empty string
// is equivalent to enabling file logging.
LogDirectory bool `json:"logDirectory"`
}
FileLoggingConfig describes the configuration options for logging to file. Note that this not being used right now but will be added to LoggingConfig down the line TODO: Update when implementing a structured logging solution
type FuzzingConfig ¶
type FuzzingConfig struct {
// Workers describes the amount of threads to use in fuzzing campaigns.
Workers int `json:"workers"`
// WorkerResetLimit describes how many call sequences a worker should test before it is destroyed and recreated
// so that memory from its underlying chain is freed.
WorkerResetLimit int `json:"workerResetLimit"`
// Timeout describes a time threshold in seconds for which the fuzzing operation should run. Providing negative or
// zero value will result in no timeout.
Timeout int `json:"timeout"`
// TestLimit describes a threshold for the number of transactions to test, after which it will exit. This number
// must be non-negative. A zero value indicates the test limit should not be enforced.
TestLimit uint64 `json:"testLimit"`
// ShrinkLimit describes a threshold for the iterations (call sequence tests) which shrinking should perform.
ShrinkLimit uint64 `json:"shrinkLimit"`
// CallSequenceLength describes the maximum length a transaction sequence can be generated as.
CallSequenceLength int `json:"callSequenceLength"`
// PruneFrequency determines how often, in minutes, the corpus should be pruned to remove unnecessary members.
// Setting PruneFrequency to 0 disables pruning.
// PruneFrequency only matters if CoverageEnabled is set to true; otherwise, no pruning will occur.
PruneFrequency uint64 `json:"pruneFrequency"`
// CorpusDirectory describes the name for the folder that will hold the corpus and the coverage files. If empty,
// the in-memory corpus will be used, but will not be flushed to disk.
CorpusDirectory string `json:"corpusDirectory"`
// CoverageEnabled describes whether to use coverage-guided fuzzing
CoverageEnabled bool `json:"coverageEnabled"`
// CoverageFormats indicate which reports to generate: "lcov" and "html" are supported.
CoverageFormats []string `json:"coverageFormats"`
// CoverageExclusions defines file/directory patterns to exclude from coverage reports.
// Supports glob patterns like "lib/**", "test/helpers/**", "*.generated.sol"
CoverageExclusions []string `json:"coverageExclusions"`
// RevertReporterEnabled determines whether revert metrics should be collected and reported.
RevertReporterEnabled bool `json:"revertReporterEnabled"`
// TargetContracts are the target contracts for fuzz testing
TargetContracts []string `json:"targetContracts"`
// PredeployedContracts are contracts that can be deterministically deployed at a specific address. It maps the
// contract name to the deployment address
PredeployedContracts map[string]string `json:"predeployedContracts"`
// TargetContractsBalances holds the amount of wei that should be sent during deployment for one or more contracts in
// TargetContracts
TargetContractsBalances []*ContractBalance `json:"targetContractsBalances"`
// ConstructorArgs holds the constructor arguments for TargetContracts deployments. It is available via the project
// configuration
ConstructorArgs map[string]map[string]any `json:"constructorArgs"`
// DeployerAddress describe the account address to be used to deploy contracts.
DeployerAddress string `json:"deployerAddress"`
// SenderAddresses describe a set of account addresses to be used to send state-changing txs (calls) in fuzzing
// campaigns.
SenderAddresses []string `json:"senderAddresses"`
// MaxBlockNumberDelay describes the maximum distance in block numbers the fuzzer will use when generating blocks
// compared to the previous.
MaxBlockNumberDelay uint64 `json:"blockNumberDelayMax"`
// MaxBlockTimestampDelay describes the maximum distance in timestamps the fuzzer will use when generating blocks
// compared to the previous.
MaxBlockTimestampDelay uint64 `json:"blockTimestampDelayMax"`
// TransactionGasLimit describes the maximum amount of gas that will be used by the fuzzer generated transactions.
TransactionGasLimit uint64 `json:"transactionGasLimit"`
// Testing describes the configuration used for different testing strategies.
Testing TestingConfig `json:"testing"`
// TestChainConfig represents the chain.TestChain config to use when initializing a chain.
TestChainConfig config.TestChainConfig `json:"chainConfig"`
}
FuzzingConfig describes the configuration options used by the fuzzing.Fuzzer.
type LoggingConfig ¶ added in v0.1.1
type LoggingConfig struct {
// Level describes whether logs of certain severity levels (eg info, warning, etc.) will be emitted or discarded.
// Increasing level values represent more severe logs
Level zerolog.Level `json:"level"`
// LogDirectory describes what directory log files should be outputted in/ LogDirectory being a non-empty string is
// equivalent to enabling file logging.
LogDirectory string `json:"logDirectory"`
// NoColor indicates whether log messages should be displayed with colored formatting.
NoColor bool `json:"noColor"`
}
LoggingConfig describes the configuration options for logging to console and file
type OptimizationTestingConfig ¶ added in v0.1.1
type OptimizationTestingConfig struct {
// Enabled describes whether testing is enabled.
Enabled bool `json:"enabled"`
// TestPrefixes dictates what method name prefixes will determine if a contract method is an optimization test.
TestPrefixes []string `json:"testPrefixes"`
}
OptimizationTestingConfig describes the configuration options used for optimization testing
type PanicCodeConfig ¶ added in v0.1.3
type PanicCodeConfig struct {
// FailOnCompilerInsertedPanic describes whether a generic compiler inserted panic should be treated as a failing case
FailOnCompilerInsertedPanic bool `json:"failOnCompilerInsertedPanic"`
// FailOnAssertion describes whether an assertion failure should be treated as a failing case
FailOnAssertion bool `json:"failOnAssertion"`
// FailOnArithmeticUnderflow describes whether an arithmetic underflow should be treated as a failing case
FailOnArithmeticUnderflow bool `json:"failOnArithmeticUnderflow"`
// FailOnDivideByZero describes whether division by zero should be treated as a failing case
FailOnDivideByZero bool `json:"failOnDivideByZero"`
// FailOnEnumTypeConversionOutOfBounds describes whether an out-of-bounds enum access should be treated as a failing case
FailOnEnumTypeConversionOutOfBounds bool `json:"failOnEnumTypeConversionOutOfBounds"`
// FailOnIncorrectStorageAccess describes whether an out-of-bounds storage access should be treated as a failing case
FailOnIncorrectStorageAccess bool `json:"failOnIncorrectStorageAccess"`
// FailOnPopEmptyArray describes whether a pop operation on an empty array should be treated as a failing case
FailOnPopEmptyArray bool `json:"failOnPopEmptyArray"`
// FailOnOutOfBoundsArrayAccess describes whether an out-of-bounds array access should be treated as a failing case
FailOnOutOfBoundsArrayAccess bool `json:"failOnOutOfBoundsArrayAccess"`
// FailOnAllocateTooMuchMemory describes whether excessive memory usage should be treated as a failing case
FailOnAllocateTooMuchMemory bool `json:"failOnAllocateTooMuchMemory"`
// FailOnCallUninitializedVariable describes whether calling an un-initialized variable should be treated as a failing case
FailOnCallUninitializedVariable bool `json:"failOnCallUninitializedVariable"`
}
PanicCodeConfig describes the various panic codes that can be enabled and be treated as a failing assertion test
type ProjectConfig ¶
type ProjectConfig struct {
// Fuzzing describes the configuration used in fuzzing campaigns.
Fuzzing FuzzingConfig `json:"fuzzing"`
// Compilation describes the configuration used to compile the underlying project.
Compilation *compilation.CompilationConfig `json:"compilation"`
// Slither describes the configuration for running slither
Slither *types.SlitherConfig `json:"slither"`
// Logging describes the configuration used for logging to file and console
Logging LoggingConfig `json:"logging"`
}
func GetDefaultProjectConfig ¶
func GetDefaultProjectConfig(platform string) (*ProjectConfig, error)
GetDefaultProjectConfig obtains a default configuration for a project. It populates a default compilation config based on the provided platform, or a nil one if an empty string is provided.
func ReadProjectConfigFromFile ¶
func ReadProjectConfigFromFile(path string, platform string) (*ProjectConfig, error)
ReadProjectConfigFromFile reads a JSON-serialized ProjectConfig from a provided file path. Returns the ProjectConfig if it succeeds, or an error if one occurs.
func (*ProjectConfig) Validate ¶
func (p *ProjectConfig) Validate() error
Validate validates that the ProjectConfig meets certain requirements. Returns an error if one occurs.
func (*ProjectConfig) WriteToFile ¶
func (p *ProjectConfig) WriteToFile(path string) error
WriteToFile writes the ProjectConfig to a provided file path in a JSON-serialized format. Returns an error if one occurs.
type PropertyTestingConfig ¶ added in v0.1.3
type PropertyTestingConfig struct {
// Enabled describes whether testing is enabled.
Enabled bool `json:"enabled"`
// TestPrefixes dictates what method name prefixes will determine if a contract method is a property test.
TestPrefixes []string `json:"testPrefixes"`
}
PropertyTestingConfig describes the configuration options used for property testing
type TestingConfig ¶
type TestingConfig struct {
// StopOnFailedTest describes whether the fuzzing.Fuzzer should stop after detecting the first failed test.
StopOnFailedTest bool `json:"stopOnFailedTest"`
// StopOnFailedContractMatching describes whether the fuzzing.Fuzzer should stop after failing to match bytecode
// to determine which contract a deployed contract is.
StopOnFailedContractMatching bool `json:"stopOnFailedContractMatching"`
// StopOnNoTests describes whether the fuzzing.Fuzzer should stop the fuzzer from starting if no tests (property,
// assertion, optimization, custom) are found.
StopOnNoTests bool `json:"stopOnNoTests"`
// TestAllContracts indicates whether all contracts should be tested (including dynamically deployed ones), rather
// than just the contracts specified in the project configuration's deployment order.
TestAllContracts bool `json:"testAllContracts"`
// TestViewMethods dictates whether constant/pure/view methods should be called and tested.
TestViewMethods bool `json:"testViewMethods"`
// Verbosity controls the level of detail in execution traces:
// - Verbose (0): Only shows top-level transactions; hides nested calls
// - VeryVerbose (1): Shows nested calls with standard detail (default)
// - VeryVeryVerbose (2): Shows all call sequence elements with maximum detail
// CLI flags: -v, -vv, -vvv set levels 0, 1, 2 respectively
Verbosity VerbosityLevel `json:"verbosity"`
// AssertionTesting describes the configuration used for assertion testing.
AssertionTesting AssertionTestingConfig `json:"assertionTesting"`
// PropertyTesting describes the configuration used for property testing.
PropertyTesting PropertyTestingConfig `json:"propertyTesting"`
// OptimizationTesting describes the configuration used for optimization testing.
OptimizationTesting OptimizationTestingConfig `json:"optimizationTesting"`
// TargetFunctionSignatures is a list of function signatures the fuzzer should exclusively target by omitting calls to other signatures.
// The signatures should specify the contract name and signature in the ABI format like `Contract.func(uint256,bytes32)`.
TargetFunctionSignatures []string `json:"targetFunctionSignatures"`
// ExcludeFunctionSignatures is a list of function signatures that will be excluded from call sequences.
// The signatures should specify the contract name and signature in the ABI format like `Contract.func(uint256,bytes32)`.
ExcludeFunctionSignatures []string `json:"excludeFunctionSignatures"`
}
TestingConfig describes the configuration options used for testing
func (*TestingConfig) Validate ¶ added in v0.1.4
func (testCfg *TestingConfig) Validate() error
Validate validates that the TestingConfig meets certain requirements.
type VerbosityLevel ¶ added in v1.2.0
type VerbosityLevel int
VerbosityLevel defines different verbosity levels
const ( // Verbose corresponds to (-v) - Only top-level transactions in the execution trace // Only events in the top-level call frame and return data are handled Verbose VerbosityLevel = 0 // VeryVerbose corresponds to (-vv) - Default behavior, current level of detail VeryVerbose VerbosityLevel = 1 // VeryVeryVerbose corresponds to (-vvv) - Maximum verbosity // Every call sequence element in the call sequence has a trace VeryVeryVerbose VerbosityLevel = 2 )