fuzzing

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const MIN_INT = "-8000000000000000000000000000000000000000000000000000000000000000"

Variables

This section is empty.

Functions

This section is empty.

Types

type AssertionTestCase

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

AssertionTestCase describes a test being run by a AssertionTestCaseProvider.

func (*AssertionTestCase) CallSequence

func (t *AssertionTestCase) CallSequence() *calls.CallSequence

CallSequence describes the types.CallSequence of calls sent to the EVM which resulted in this TestCase result. This should be nil if the result is not related to the CallSequence.

func (*AssertionTestCase) ID

func (t *AssertionTestCase) ID() string

ID obtains a unique identifier for a test result.

func (*AssertionTestCase) LogMessage added in v0.1.1

func (t *AssertionTestCase) LogMessage() *logging.LogBuffer

LogMessage obtains a buffer that represents the result of the AssertionTestCase. This buffer can be passed to a logger for console or file logging.

func (*AssertionTestCase) Message

func (t *AssertionTestCase) Message() string

Message obtains a text-based printable message which describes the result of the AssertionTestCase.

func (*AssertionTestCase) Name

func (t *AssertionTestCase) Name() string

Name describes the name of the test case.

func (*AssertionTestCase) Status

func (t *AssertionTestCase) Status() TestCaseStatus

Status describes the TestCaseStatus used to define the current state of the test.

type AssertionTestCaseProvider

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

AssertionTestCaseProvider is am AssertionTestCase provider which spawns test cases for every contract method and ensures that none of them result in a failed assertion (e.g. use of the solidity `assert(...)` statement, or special events indicating a failed assertion).

type CallSequenceGenerator

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

CallSequenceGenerator generates call sequences iteratively per element, for use in fuzzing campaigns. It is attached to a FuzzerWorker and uses its runtime context

func NewCallSequenceGenerator

func NewCallSequenceGenerator(worker *FuzzerWorker, config *CallSequenceGeneratorConfig) *CallSequenceGenerator

NewCallSequenceGenerator creates a CallSequenceGenerator to generate call sequences for use in fuzzing campaigns.

func (*CallSequenceGenerator) InitializeNextSequence

func (g *CallSequenceGenerator) InitializeNextSequence() (bool, error)

InitializeNextSequence prepares the CallSequenceGenerator for generating a new sequence. Each element can be obtained by calling PopSequenceElement iteratively. Returns a boolean indicating whether the initialized sequence is a newly generated sequence (rather than an unmodified one loaded from the corpus), or an error if one occurred.

func (*CallSequenceGenerator) PopSequenceElement

func (g *CallSequenceGenerator) PopSequenceElement() (*calls.CallSequenceElement, error)

PopSequenceElement obtains the next element for our call sequence requested by InitializeNextSequence. If there are no elements left to return, this method returns nil. If an error occurs, it is returned instead.

type CallSequenceGeneratorConfig

type CallSequenceGeneratorConfig struct {
	// NewSequenceProbability defines the probability that the CallSequenceGenerator should generate an entirely new
	// sequence rather than mutating one from the corpus.
	NewSequenceProbability float32

	// RandomUnmodifiedCorpusHeadWeight defines the weight that the CallSequenceGenerator should use the call sequence
	// generation strategy of taking the head of a corpus sequence (without mutations) and append newly generated calls
	// to the end of it.
	RandomUnmodifiedCorpusHeadWeight uint64

	// RandomUnmodifiedCorpusTailWeight defines the weight that the CallSequenceGenerator should use the call sequence
	// generation strategy of taking the tail of a corpus sequence (without mutations) and prepend newly generated calls
	// to the start of it.
	RandomUnmodifiedCorpusTailWeight uint64

	// RandomUnmodifiedSpliceAtRandomWeight defines the weight that the CallSequenceGenerator should use the call sequence
	// generation strategy of taking two corpus sequences (without mutations) and splicing them before joining them
	// together.
	RandomUnmodifiedSpliceAtRandomWeight uint64

	// RandomUnmodifiedInterleaveAtRandomWeight defines the weight that the CallSequenceGenerator should use the call
	// sequence generation strategy of taking two corpus sequences (without mutations) and interleaving a random
	// number of calls from each.
	RandomUnmodifiedInterleaveAtRandomWeight uint64

	// RandomMutatedCorpusHeadWeight defines the weight that the CallSequenceGenerator should use the call sequence
	// generation strategy of taking the head of a corpus sequence (with mutations) and append newly generated calls
	// to the end of it.
	RandomMutatedCorpusHeadWeight uint64

	// RandomMutatedCorpusTailWeight defines the weight that the CallSequenceGenerator should use the call sequence
	// generation strategy of taking the tao; of a corpus sequence (with mutations) and prepend newly generated calls
	// to the start of it.
	RandomMutatedCorpusTailWeight uint64

	// RandomMutatedSpliceAtRandomWeight defines the weight that the CallSequenceGenerator should use the call sequence
	// generation strategy of taking two corpus sequences (with mutations) and splicing them before joining them
	// together.
	RandomMutatedSpliceAtRandomWeight uint64

	// RandomMutatedInterleaveAtRandomWeight defines the weight that the CallSequenceGenerator should use the call
	// sequence generation strategy of taking two corpus sequences (with mutations) and interleaving a random
	// number of calls from each.
	RandomMutatedInterleaveAtRandomWeight uint64

	// ValueGenerator defines the value provider to use when generating new values for call sequences. This is used both
	// for ABI call data generation, and generation of additional values such as the "value" field of a
	// transaction/call.
	ValueGenerator valuegeneration.ValueGenerator

	// ValueMutator defines the value provider to use when mutating corpus call sequences.
	ValueMutator valuegeneration.ValueMutator
}

CallSequenceGeneratorConfig defines the configuration for a CallSequenceGenerator to be created and used by a FuzzerWorker to generate call sequences in a fuzzing campaign.

type CallSequenceGeneratorFunc

type CallSequenceGeneratorFunc func(sequenceGenerator *CallSequenceGenerator, sequence calls.CallSequence) error

CallSequenceGeneratorFunc defines a method used to populate a provided call sequence with generated calls. Returns an optional PrefetchModifyCallFunc to be executed prior to the fetching of each element, or an error if one occurs.

type CallSequenceGeneratorMutationStrategy

type CallSequenceGeneratorMutationStrategy struct {
	// CallSequenceGeneratorFunc describes a method used to populate a provided call sequence.
	CallSequenceGeneratorFunc CallSequenceGeneratorFunc

	// PrefetchModifyCallFunc defines a method used to modify a call sequence element before being fetched.
	PrefetchModifyCallFunc PrefetchModifyCallFunc
}

CallSequenceGeneratorMutationStrategy defines a structure for a mutation strategy used by a CallSequenceGenerator.

type CallSequenceTestFunc

type CallSequenceTestFunc func(worker *FuzzerWorker, callSequence calls.CallSequence) ([]ShrinkCallSequenceRequest, error)

CallSequenceTestFunc defines a method called after a fuzzing.FuzzerWorker sends another call in a types.CallSequence during a fuzzing campaign. It returns a ShrinkCallSequenceRequest set, which represents a set of requests for shrunken call sequences alongside verifiers to guide the shrinking process. This signals to the FuzzerWorker that this current call sequence was interesting, and it should stop building on it and find a shrunken sequence that satisfies the conditions specified by the ShrinkCallSequenceRequest, before generating entirely new call sequences. Shrink requests should not be unnecessarily requested, as this will cancel the current call sequence from being further generated and tested.

type Fuzzer

type Fuzzer struct {

	// Events describes the event system for the Fuzzer.
	Events FuzzerEvents

	// Hooks describes the replaceable functions used by the Fuzzer.
	Hooks FuzzerHooks
	// contains filtered or unexported fields
}

Fuzzer represents an Ethereum smart contract fuzzing provider.

func NewFuzzer

func NewFuzzer(config config.ProjectConfig) (*Fuzzer, error)

NewFuzzer returns an instance of a new Fuzzer provided a project configuration, or an error if one is encountered while initializing the code.

func (*Fuzzer) AddCompilationTargets

func (f *Fuzzer) AddCompilationTargets(compilations []compilationTypes.Compilation)

AddCompilationTargets takes a compilation and updates the Fuzzer state with additional Fuzzer.ContractDefinitions definitions and Fuzzer.BaseValueSet values.

func (*Fuzzer) BaseValueSet

func (f *Fuzzer) BaseValueSet() *valuegeneration.ValueSet

BaseValueSet exposes the underlying value set provided to the Fuzzer value generators to aid in generation (e.g. for use in mutation operations).

func (*Fuzzer) Config

func (f *Fuzzer) Config() config.ProjectConfig

Config exposes the underlying project configuration provided to the Fuzzer.

func (*Fuzzer) ContractDefinitions

func (f *Fuzzer) ContractDefinitions() fuzzerTypes.Contracts

ContractDefinitions exposes the contract definitions registered with the Fuzzer.

func (*Fuzzer) DeployerAddress

func (f *Fuzzer) DeployerAddress() common.Address

DeployerAddress exposes the account address from which contracts will be deployed by a FuzzerWorker.

func (*Fuzzer) RegisterTestCase

func (f *Fuzzer) RegisterTestCase(testCase TestCase)

RegisterTestCase registers a new TestCase with the Fuzzer.

func (*Fuzzer) ReportTestCaseFinished

func (f *Fuzzer) ReportTestCaseFinished(testCase TestCase)

ReportTestCaseFinished is used to report a TestCase status as finalized to the Fuzzer.

func (*Fuzzer) SenderAddresses

func (f *Fuzzer) SenderAddresses() []common.Address

SenderAddresses exposes the account addresses from which state changing fuzzed transactions will be sent by a FuzzerWorker.

func (*Fuzzer) Start

func (f *Fuzzer) Start() error

Start begins a fuzzing operation on the provided project configuration. This operation will not return until an error is encountered or the fuzzing operation has completed. Its execution can be cancelled using the Stop method. Returns an error if one is encountered.

func (*Fuzzer) Stop

func (f *Fuzzer) Stop()

Stop stops a running operation invoked by the Start method. This method may return before complete operation teardown occurs.

func (*Fuzzer) TestCases

func (f *Fuzzer) TestCases() []TestCase

TestCases exposes the underlying tests run during the fuzzing campaign.

func (*Fuzzer) TestCasesWithStatus

func (f *Fuzzer) TestCasesWithStatus(status TestCaseStatus) []TestCase

TestCasesWithStatus exposes the underlying tests with the provided status.

type FuzzerEvents

type FuzzerEvents struct {
	// FuzzerStarting emits events when the Fuzzer initialized state and is ready to about to begin the main
	// execution loop for the fuzzing campaign.
	FuzzerStarting events.EventEmitter[FuzzerStartingEvent]

	// FuzzerStopping emits events when the Fuzzer is exiting its main fuzzing loop.
	FuzzerStopping events.EventEmitter[FuzzerStoppingEvent]

	// WorkerCreated emits events when the Fuzzer creates a new FuzzerWorker during the fuzzing campaign.
	WorkerCreated events.EventEmitter[FuzzerWorkerCreatedEvent]

	// WorkerDestroyed emits events when the Fuzzer destroys an existing FuzzerWorker during the fuzzing
	// campaign. This can occur even if a fuzzing campaign is not stopping, if a worker has reached resource limits.
	WorkerDestroyed events.EventEmitter[FuzzerWorkerDestroyedEvent]
}

FuzzerEvents defines event emitters for a Fuzzer.

type FuzzerHooks

type FuzzerHooks struct {
	// NewCallSequenceGeneratorConfigFunc describes the function to use to set up a new CallSequenceGeneratorConfig,
	// defining parameters for a new FuzzerWorker's CallSequenceGenerator.
	// The value generator provided must be either thread safe, or a new instance must be provided per invocation to
	// avoid concurrent access issues between workers.
	NewCallSequenceGeneratorConfigFunc NewCallSequenceGeneratorConfigFunc

	// NewShrinkingValueMutatorFunc describes the function used to set up a value mutator used to shrink call
	// values in the fuzzer's call sequence shrinking process.
	// The value mutator provided must be either thread safe, or a new instance must be provided per invocation to
	// avoid concurrent access issues between workers.
	NewShrinkingValueMutatorFunc NewShrinkingValueMutatorFunc

	// ChainSetupFunc describes the function to use to set up a new test chain's initial state prior to fuzzing.
	ChainSetupFunc TestChainSetupFunc

	// CallSequenceTestFuncs describes a list of functions to be called upon by a FuzzerWorker after every call
	// in a call sequence.
	CallSequenceTestFuncs []CallSequenceTestFunc
}

FuzzerHooks defines the hooks that can be used for the Fuzzer on an API level.

type FuzzerMetrics

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

FuzzerMetrics represents a struct tracking metrics for a Fuzzer run.

func (*FuzzerMetrics) CallsTested

func (m *FuzzerMetrics) CallsTested() *big.Int

CallsTested returns the amount of transactions/calls the fuzzer executed and ran tests against.

func (*FuzzerMetrics) SequencesTested

func (m *FuzzerMetrics) SequencesTested() *big.Int

SequencesTested returns the amount of sequences of transactions the fuzzer executed and ran tests against.

func (*FuzzerMetrics) WorkerStartupCount

func (m *FuzzerMetrics) WorkerStartupCount() *big.Int

WorkerStartupCount describes the amount of times the worker was spawned for this index. Workers are periodically reset.

func (*FuzzerMetrics) WorkersShrinkingCount added in v0.1.3

func (m *FuzzerMetrics) WorkersShrinkingCount() uint64

WorkersShrinkingCount returns the amount of workers currently performing shrinking operations.

type FuzzerStartingEvent

type FuzzerStartingEvent struct {
	// Fuzzer represents the instance of the fuzzing.Fuzzer for which the event occurred.
	Fuzzer *Fuzzer
}

FuzzerStartingEvent describes an event where a fuzzing.Fuzzer has initialized all state variables and is about to begin spinning up instances of FuzzerWorker to start the fuzzing campaign.

type FuzzerStoppingEvent

type FuzzerStoppingEvent struct {
	// Fuzzer represents the instance of the fuzzing.Fuzzer for which the event occurred.
	Fuzzer *Fuzzer
	// contains filtered or unexported fields
}

FuzzerStoppingEvent describes an event where a fuzzing.Fuzzer is exiting the main fuzzing loop.

type FuzzerWorker

type FuzzerWorker struct {

	// Events describes the event system for the FuzzerWorker.
	Events FuzzerWorkerEvents
	// contains filtered or unexported fields
}

FuzzerWorker describes a single thread worker utilizing its own go-ethereum test node to run property tests against Fuzzer-generated transaction sequences.

func (*FuzzerWorker) Chain

func (fw *FuzzerWorker) Chain() *chain.TestChain

Chain returns the Chain used by this worker as the backend for tests.

func (*FuzzerWorker) DeployedContract

func (fw *FuzzerWorker) DeployedContract(address common.Address) *fuzzerTypes.Contract

DeployedContract obtains a contract deployed at the given address. If it does not exist, it returns nil.

func (*FuzzerWorker) DeployedContracts

func (fw *FuzzerWorker) DeployedContracts() map[common.Address]*fuzzerTypes.Contract

DeployedContracts returns a mapping of deployed contract addresses to contract definitions, which are currently known to the fuzzer.

func (*FuzzerWorker) Fuzzer

func (fw *FuzzerWorker) Fuzzer() *Fuzzer

Fuzzer returns the parent Fuzzer which spawned this FuzzerWorker.

func (*FuzzerWorker) ValueGenerator

func (fw *FuzzerWorker) ValueGenerator() valuegeneration.ValueGenerator

ValueGenerator obtains the value generator used by this worker.

func (*FuzzerWorker) ValueMutator added in v0.1.1

func (fw *FuzzerWorker) ValueMutator() valuegeneration.ValueMutator

ValueMutator obtains the value mutator used by this worker.

func (*FuzzerWorker) ValueSet

func (fw *FuzzerWorker) ValueSet() *valuegeneration.ValueSet

ValueSet obtains the value set used to power the value generator for this worker.

func (*FuzzerWorker) WorkerIndex

func (fw *FuzzerWorker) WorkerIndex() int

WorkerIndex returns the index of this FuzzerWorker in relation to its parent Fuzzer.

type FuzzerWorkerCallSequenceTestedEvent

type FuzzerWorkerCallSequenceTestedEvent struct {
	// Worker represents the instance of the fuzzing.FuzzerWorker for which the event occurred.
	Worker *FuzzerWorker
}

FuzzerWorkerCallSequenceTestedEvent describes an event where a fuzzing.FuzzerWorker has finished generating and testing a new call sequence.

type FuzzerWorkerCallSequenceTestingEvent

type FuzzerWorkerCallSequenceTestingEvent struct {
	// Worker represents the instance of the fuzzing.FuzzerWorker for which the event occurred.
	Worker *FuzzerWorker
}

FuzzerWorkerCallSequenceTestingEvent describes an event where a fuzzing.FuzzerWorker is about to generate and test a new call sequence.

type FuzzerWorkerChainCreatedEvent

type FuzzerWorkerChainCreatedEvent struct {
	// Worker represents the instance of the fuzzing.FuzzerWorker for which the event occurred.
	Worker *FuzzerWorker

	// Chain represents the worker's chain.
	Chain *chain.TestChain
}

FuzzerWorkerChainCreatedEvent describes an event where a fuzzing.FuzzerWorker is created its underlying chain. This is an opportune to attach tracers to capture chain setup information.

type FuzzerWorkerChainSetupEvent

type FuzzerWorkerChainSetupEvent struct {
	// Worker represents the instance of the fuzzing.FuzzerWorker for which the event occurred.
	Worker *FuzzerWorker

	// Chain represents the worker's chain.
	Chain *chain.TestChain
}

FuzzerWorkerChainSetupEvent describes an event where a fuzzing.FuzzerWorker set up its underlying chain. This means the chain should have its initial contracts deployed and is ready for the fuzzing campaign to start.

type FuzzerWorkerContractAddedEvent

type FuzzerWorkerContractAddedEvent struct {
	// Worker represents the instance of the fuzzing.FuzzerWorker for which the event occurred.
	Worker *FuzzerWorker

	// ContractAddress describes the address of the deployed contract.
	ContractAddress common.Address

	// ContractDefinition describes the compiled contract artifact definition which the fuzzing.Fuzzer matched to the
	// deployed bytecode. If this could not be resolved, a nil value is provided.
	ContractDefinition *contracts.Contract
}

FuzzerWorkerContractAddedEvent describes an event where a fuzzing.FuzzerWorker detects a newly deployed contract in its underlying test chain.

type FuzzerWorkerContractDeletedEvent

type FuzzerWorkerContractDeletedEvent struct {
	// Worker represents the instance of the fuzzing.FuzzerWorker for which the event occurred.
	Worker *FuzzerWorker

	// ContractAddress describes the address of the deployed contract.
	ContractAddress common.Address

	// ContractDefinition describes the compiled contract artifact definition which the fuzzing.Fuzzer matched to the
	// deployed bytecode. If this could not be resolved, a nil value is provided.
	ContractDefinition *contracts.Contract
}

FuzzerWorkerContractDeletedEvent describes an event where a fuzzing.FuzzerWorker detects a previously reported deployed contract that no longer exists in the underlying test chain.

type FuzzerWorkerCreatedEvent

type FuzzerWorkerCreatedEvent struct {
	// Worker represents the instance of the fuzzing.FuzzerWorker for which the event occurred.
	Worker *FuzzerWorker
}

FuzzerWorkerCreatedEvent describes an event where a fuzzing.FuzzerWorker is created by a fuzzing.Fuzzer.

type FuzzerWorkerDestroyedEvent

type FuzzerWorkerDestroyedEvent struct {
	// Worker represents the instance of the fuzzing.FuzzerWorker for which the event occurred.
	Worker *FuzzerWorker
}

FuzzerWorkerDestroyedEvent describes an event where a fuzzing.FuzzerWorker is destroyed by a fuzzing.Fuzzer.

type FuzzerWorkerEvents

type FuzzerWorkerEvents struct {
	// ContractAdded emits events when the FuzzerWorker detects a newly deployed contract
	// on its underlying chain.
	ContractAdded events.EventEmitter[FuzzerWorkerContractAddedEvent]

	// ContractDeleted emits events when the FuzzerWorker detects a deployed contract no
	// longer exists on its underlying chain.
	ContractDeleted events.EventEmitter[FuzzerWorkerContractDeletedEvent]

	// FuzzerWorkerChainCreated emits events when the FuzzerWorker has created its chain and is about to begin chain
	// setup.
	FuzzerWorkerChainCreated events.EventEmitter[FuzzerWorkerChainCreatedEvent]

	// FuzzerWorkerChainSetup emits events when the FuzzerWorker has set up its chain and is about to begin fuzzing.
	FuzzerWorkerChainSetup events.EventEmitter[FuzzerWorkerChainSetupEvent]

	// CallSequenceTesting emits events when the FuzzerWorker is about to generate and test a new
	// call sequence.
	CallSequenceTesting events.EventEmitter[FuzzerWorkerCallSequenceTestingEvent]

	// CallSequenceTested emits events when the FuzzerWorker has finished generating and testing a
	// new call sequence.
	CallSequenceTested events.EventEmitter[FuzzerWorkerCallSequenceTestedEvent]
}

FuzzerWorkerEvents defines event emitters for a FuzzerWorker.

type NewCallSequenceGeneratorConfigFunc

type NewCallSequenceGeneratorConfigFunc func(fuzzer *Fuzzer, valueSet *valuegeneration.ValueSet, randomProvider *rand.Rand) (*CallSequenceGeneratorConfig, error)

NewCallSequenceGeneratorConfigFunc defines a method is called to create a new CallSequenceGeneratorConfig, defining the parameters for the new FuzzerWorker to use when creating its CallSequenceGenerator used to power fuzzing. Returns a new CallSequenceGeneratorConfig, or an error if one is encountered.

type NewShrinkingValueMutatorFunc added in v0.1.1

type NewShrinkingValueMutatorFunc func(fuzzer *Fuzzer, valueSet *valuegeneration.ValueSet, randomProvider *rand.Rand) (valuegeneration.ValueMutator, error)

NewShrinkingValueMutatorFunc describes the function used to set up a value mutator used to shrink call values in the fuzzer's call sequence shrinking process. Returns a new value mutator, or an error if one occurred.

type OptimizationTestCase added in v0.1.1

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

OptimizationTestCase describes a test being run by a OptimizationTestCaseProvider.

func (*OptimizationTestCase) CallSequence added in v0.1.1

func (t *OptimizationTestCase) CallSequence() *calls.CallSequence

CallSequence describes the calls.CallSequence of calls sent to the EVM which resulted in this TestCase result. This should be nil if the result is not related to the CallSequence.

func (*OptimizationTestCase) ID added in v0.1.1

func (t *OptimizationTestCase) ID() string

ID obtains a unique identifier for a test result.

func (*OptimizationTestCase) LogMessage added in v0.1.1

func (t *OptimizationTestCase) LogMessage() *logging.LogBuffer

LogMessage obtains a buffer that represents the result of the AssertionTestCase. This buffer can be passed to a logger for console or file logging.

func (*OptimizationTestCase) Message added in v0.1.1

func (t *OptimizationTestCase) Message() string

Message obtains a text-based printable message which describes the result of the OptimizationTestCase.

func (*OptimizationTestCase) Name added in v0.1.1

func (t *OptimizationTestCase) Name() string

Name describes the name of the test case.

func (*OptimizationTestCase) Status added in v0.1.1

Status describes the TestCaseStatus used to define the current state of the test.

func (*OptimizationTestCase) Value added in v0.1.1

func (t *OptimizationTestCase) Value() *big.Int

Value obtains the maximum value returned by the test method found till now

type OptimizationTestCaseProvider added in v0.1.1

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

OptimizationTestCaseProvider is a provider for on-chain optimization tests. Optimization tests are represented as publicly-accessible functions which have a name prefix specified by a config.FuzzingConfig. They take no input arguments and return an integer value that needs to be maximized.

type PrefetchModifyCallFunc

type PrefetchModifyCallFunc func(sequenceGenerator *CallSequenceGenerator, element *calls.CallSequenceElement) error

PrefetchModifyCallFunc defines a method used to modify a call sequence element before being fetched from this provider for use. Returns an error if one occurs.

type PropertyTestCase

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

PropertyTestCase describes a test being run by a PropertyTestCaseProvider.

func (*PropertyTestCase) CallSequence

func (t *PropertyTestCase) CallSequence() *calls.CallSequence

CallSequence describes the types.CallSequence of calls sent to the EVM which resulted in this TestCase result. This should be nil if the result is not related to the CallSequence.

func (*PropertyTestCase) ID

func (t *PropertyTestCase) ID() string

ID obtains a unique identifier for a test result.

func (*PropertyTestCase) LogMessage added in v0.1.1

func (t *PropertyTestCase) LogMessage() *logging.LogBuffer

LogMessage obtains a buffer that represents the result of the PropertyTestCase. This buffer can be passed to a logger for console or file logging.

func (*PropertyTestCase) Message

func (t *PropertyTestCase) Message() string

Message obtains a text-based printable message which describes the result of the PropertyTestCase.

func (*PropertyTestCase) Name

func (t *PropertyTestCase) Name() string

Name describes the name of the test case.

func (*PropertyTestCase) Status

func (t *PropertyTestCase) Status() TestCaseStatus

Status describes the TestCaseStatus used to define the current state of the test.

type PropertyTestCaseProvider

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

PropertyTestCaseProvider is a provider for on-chain property tests. Property tests are represented as publicly-accessible view functions which have a name prefix specified by a config.FuzzingConfig. They take no input arguments and return a boolean indicating whether the test passed. If a call to any on-chain property test returns false, the test signals a failed status. If no failure is found before the fuzzing campaign ends, the test signals a passed status.

type ShrinkCallSequenceRequest

type ShrinkCallSequenceRequest struct {
	// VerifierFunction is a method is called upon by a FuzzerWorker to check if a shrunken call sequence satisfies
	// the needs of an original method.
	VerifierFunction func(worker *FuzzerWorker, callSequence calls.CallSequence) (bool, error)
	// FinishedCallback is a method called upon when the shrink request has concluded. It provides the finalized
	// shrunken call sequence.
	FinishedCallback func(worker *FuzzerWorker, shrunkenCallSequence calls.CallSequence) error
	// RecordResultInCorpus indicates whether the shrunken call sequence should be recorded in the corpus. If so, when
	// the shrinking operation is completed, the sequence will be added to the corpus if it doesn't already exist.
	RecordResultInCorpus bool
}

ShrinkCallSequenceRequest is a structure signifying a request for a shrunken call sequence from the FuzzerWorker.

type TestCase

type TestCase interface {
	// Status describes the TestCaseStatus used to define the current state of the test.
	Status() TestCaseStatus

	// CallSequence describes the types.CallSequence of calls sent to the EVM which resulted in this TestCase result.
	// This should be nil if the result is not related to the CallSequence.
	CallSequence() *calls.CallSequence

	// Name describes the name of the test case.
	Name() string

	// LogMessage obtains a logging.LogBuffer that represents the result of the TestCase. This buffer can be passed to a logger for
	// console or file logging.
	LogMessage() *logging.LogBuffer

	// Message obtains a text-based printable message which describes the result of the AssertionTestCase.
	Message() string

	// ID obtains a unique identifier for a test result. If the same test fails, this ID should match for both
	// TestResult instances (even if the CallSequence differs or has not been shrunk).
	ID() string
}

TestCase describes a test which is being conducted by a test provider attached to the Fuzzer.

type TestCaseStatus

type TestCaseStatus string

TestCaseStatus defines the status of a TestCase as a string-represented enum.

const (
	// TestCaseStatusNotStarted describes a test status where conditions have not yet been tested.
	TestCaseStatusNotStarted TestCaseStatus = "NOT STARTED"
	// TestCaseStatusRunning describes a test status where conditions have been tested for but no result
	// has been reported.
	TestCaseStatusRunning TestCaseStatus = "RUNNING"
	// TestCaseStatusPassed describes a test status where testing has concluded and the test passed.
	TestCaseStatusPassed TestCaseStatus = "PASSED"
	// TestCaseStatusFailed describes a test status where testing has concluded and the test failed.
	TestCaseStatusFailed TestCaseStatus = "FAILED"
)

type TestChainSetupFunc

type TestChainSetupFunc func(fuzzer *Fuzzer, testChain *chain.TestChain) error

TestChainSetupFunc describes a function which sets up a test chain's initial state prior to fuzzing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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