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"`
// TestViewMethods dictates whether constant/pure/view methods should be tested.
TestViewMethods bool `json:"testViewMethods"`
// 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 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"`
// 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 not flush to disk.
CorpusDirectory string `json:"corpusDirectory"`
// CoverageEnabled describes whether to use coverage-guided fuzzing
CoverageEnabled bool `json:"coverageEnabled"`
// 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 []*big.Int `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"`
// BlockGasLimit describes the maximum amount of gas that can be used in a block by transactions. This defines
// limits for how many transactions can be included per block.
BlockGasLimit uint64 `json:"blockGasLimit"`
// 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.
func (FuzzingConfig) MarshalJSON ¶ added in v0.1.3
func (f FuzzingConfig) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON.
func (*FuzzingConfig) UnmarshalJSON ¶ added in v0.1.3
func (f *FuzzingConfig) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
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"`
// 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"`
// TraceAll describes whether a trace should be attached to each element of a finalized shrunken call sequence,
// e.g. when a call sequence triggers a test failure. Test providers may attach execution traces by default,
// even if this option is not enabled.
TraceAll bool `json:"traceAll"`
// 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 function signatures call 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.