Documentation ¶
Index ¶
- func GenerateReport(compilations []types.Compilation, coverageMaps *CoverageMaps, ...) error
- func RemoveCoverageTracerResults(messageResults *types.MessageResults)
- type ContractCoverageMap
- type CoverageMapBytecodeData
- type CoverageMaps
- func (cm *CoverageMaps) Equal(b *CoverageMaps) bool
- func (cm *CoverageMaps) GetContractCoverageMap(bytecode []byte, init bool) (*ContractCoverageMap, error)
- func (cm *CoverageMaps) Reset()
- func (cm *CoverageMaps) RevertAll() (bool, error)
- func (cm *CoverageMaps) SetAt(codeAddress common.Address, codeLookupHash common.Hash, codeSize int, ...) (bool, error)
- func (cm *CoverageMaps) Update(coverageMaps *CoverageMaps) (bool, bool, error)
- type CoverageTracer
- func (t *CoverageTracer) CaptureEnd(output []byte, gasUsed uint64, err error)
- func (t *CoverageTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, ...)
- func (t *CoverageTracer) CaptureExit(output []byte, gasUsed uint64, err error)
- func (t *CoverageTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, ...)
- func (t *CoverageTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, ...)
- func (t *CoverageTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, ...)
- func (t *CoverageTracer) CaptureTxEnd(restGas uint64)
- func (t *CoverageTracer) CaptureTxEndSetAdditionalResults(results *types.MessageResults)
- func (t *CoverageTracer) CaptureTxStart(gasLimit uint64)
- type SourceAnalysis
- type SourceFileAnalysis
- type SourceLineAnalysis
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateReport ¶ added in v0.1.1
func GenerateReport(compilations []types.Compilation, coverageMaps *CoverageMaps, htmlReportPath string) error
GenerateReport takes a set of CoverageMaps and compilations, and produces a coverage report using them, detailing all source mapped ranges of the source files which were covered or not. Returns an error if one occurred.
func RemoveCoverageTracerResults ¶
func RemoveCoverageTracerResults(messageResults *types.MessageResults)
RemoveCoverageTracerResults removes CoverageMaps stored by a CoverageTracer from message results.
Types ¶
type ContractCoverageMap ¶ added in v0.1.1
type ContractCoverageMap struct {
// contains filtered or unexported fields
}
ContractCoverageMap represents a data structure used to identify instruction execution coverage of a contract.
func (*ContractCoverageMap) Equal ¶ added in v0.1.1
func (cm *ContractCoverageMap) Equal(b *ContractCoverageMap) bool
Equal checks whether the provided ContractCoverageMap contains the same data as the current one. Returns a boolean indicating whether the two maps match.
type CoverageMapBytecodeData ¶ added in v0.1.1
type CoverageMapBytecodeData struct {
// contains filtered or unexported fields
}
CoverageMapBytecodeData represents a data structure used to identify instruction execution coverage of some init or runtime bytecode.
func (*CoverageMapBytecodeData) Equal ¶ added in v0.1.1
func (cm *CoverageMapBytecodeData) Equal(b *CoverageMapBytecodeData) bool
Equal checks whether the provided CoverageMapBytecodeData contains the same data as the current one. Returns a boolean indicating whether the two maps match.
func (*CoverageMapBytecodeData) IsCovered ¶ added in v0.1.1
func (cm *CoverageMapBytecodeData) IsCovered(pc int) bool
IsCovered checks if a given program counter location is covered by the map. Returns a boolean indicating if the program counter was executed on this map.
func (*CoverageMapBytecodeData) Reset ¶ added in v0.1.1
func (cm *CoverageMapBytecodeData) Reset()
Reset resets the bytecode coverage map data to be empty.
type CoverageMaps ¶
type CoverageMaps struct {
// contains filtered or unexported fields
}
CoverageMaps represents a data structure used to identify instruction execution coverage of various smart contracts across a transaction or multiple transactions.
func GetCoverageTracerResults ¶
func GetCoverageTracerResults(messageResults *types.MessageResults) *CoverageMaps
GetCoverageTracerResults obtains CoverageMaps stored by a CoverageTracer from message results. This is nil if no CoverageMaps were recorded by a tracer (e.g. CoverageTracer was not attached during this message execution).
func NewCoverageMaps ¶
func NewCoverageMaps() *CoverageMaps
NewCoverageMaps initializes a new CoverageMaps object.
func (*CoverageMaps) Equal ¶ added in v0.1.1
func (cm *CoverageMaps) Equal(b *CoverageMaps) bool
Equal checks whether two coverage maps are the same. Equality is determined if the keys and values are all the same.
func (*CoverageMaps) GetContractCoverageMap ¶ added in v0.1.1
func (cm *CoverageMaps) GetContractCoverageMap(bytecode []byte, init bool) (*ContractCoverageMap, error)
GetContractCoverageMap obtains a total coverage map representing coverage for the provided bytecode. If the provided bytecode could not find coverage maps, nil is returned. Returns the total coverage map, or an error if one occurs.
func (*CoverageMaps) Reset ¶
func (cm *CoverageMaps) Reset()
Reset clears the coverage state for the CoverageMaps.
func (*CoverageMaps) RevertAll ¶ added in v0.1.1
func (cm *CoverageMaps) RevertAll() (bool, error)
RevertAll sets all coverage in the coverage map as reverted coverage. Reverted coverage is updated with successful coverage, the successful coverage is cleared. Returns a boolean indicating whether reverted coverage increased, and an error if one occurred.
func (*CoverageMaps) SetAt ¶ added in v0.1.1
func (cm *CoverageMaps) SetAt(codeAddress common.Address, codeLookupHash common.Hash, codeSize int, pc uint64) (bool, error)
SetAt sets the coverage state of a given program counter location within code coverage data.
func (*CoverageMaps) Update ¶
func (cm *CoverageMaps) Update(coverageMaps *CoverageMaps) (bool, bool, error)
Update updates the current coverage maps with the provided ones. Returns two booleans indicating whether successful or reverted coverage changed, or an error if one occurred.
type CoverageTracer ¶
type CoverageTracer struct {
// contains filtered or unexported fields
}
CoverageTracer implements vm.EVMLogger to collect information such as coverage maps for fuzzing campaigns from EVM execution traces.
func NewCoverageTracer ¶
func NewCoverageTracer() *CoverageTracer
NewCoverageTracer returns a new CoverageTracer.
func (*CoverageTracer) CaptureEnd ¶
func (t *CoverageTracer) CaptureEnd(output []byte, gasUsed uint64, err error)
CaptureEnd is called after a call to finalize tracing completes for the top of a call frame, as defined by vm.EVMLogger.
func (*CoverageTracer) CaptureEnter ¶
func (t *CoverageTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int)
CaptureEnter is called upon entering of the call frame, as defined by vm.EVMLogger.
func (*CoverageTracer) CaptureExit ¶
func (t *CoverageTracer) CaptureExit(output []byte, gasUsed uint64, err error)
CaptureExit is called upon exiting of the call frame, as defined by vm.EVMLogger.
func (*CoverageTracer) CaptureFault ¶
func (t *CoverageTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error)
CaptureFault records an execution fault, as defined by vm.EVMLogger.
func (*CoverageTracer) CaptureStart ¶
func (t *CoverageTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int)
CaptureStart initializes the tracing operation for the top of a call frame, as defined by vm.EVMLogger.
func (*CoverageTracer) CaptureState ¶
func (t *CoverageTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, vmErr error)
CaptureState records data from an EVM state update, as defined by vm.EVMLogger.
func (*CoverageTracer) CaptureTxEnd ¶
func (t *CoverageTracer) CaptureTxEnd(restGas uint64)
CaptureTxEnd is called upon the end of transaction execution, as defined by vm.EVMLogger.
func (*CoverageTracer) CaptureTxEndSetAdditionalResults ¶
func (t *CoverageTracer) CaptureTxEndSetAdditionalResults(results *types.MessageResults)
CaptureTxEndSetAdditionalResults can be used to set additional results captured from execution tracing. If this tracer is used during transaction execution (block creation), the results can later be queried from the block. This method will only be called on the added tracer if it implements the extended TestChainTracer interface.
func (*CoverageTracer) CaptureTxStart ¶
func (t *CoverageTracer) CaptureTxStart(gasLimit uint64)
CaptureTxStart is called upon the start of transaction execution, as defined by vm.EVMLogger.
type SourceAnalysis ¶ added in v0.1.1
type SourceAnalysis struct { // Files describes the analysis results for a given source file path. Files map[string]*SourceFileAnalysis }
SourceAnalysis describes source code coverage across a list of compilations, after analyzing associated CoverageMaps.
func AnalyzeSourceCoverage ¶ added in v0.1.1
func AnalyzeSourceCoverage(compilations []types.Compilation, coverageMaps *CoverageMaps) (*SourceAnalysis, error)
AnalyzeSourceCoverage takes a list of compilations and a set of coverage maps, and performs source analysis to determine source coverage information. Returns a SourceAnalysis object, or an error if one occurs.
func (*SourceAnalysis) ActiveLineCount ¶ added in v0.1.1
func (s *SourceAnalysis) ActiveLineCount() int
ActiveLineCount returns the count of lines that are marked executable/active across all source files.
func (*SourceAnalysis) CoveredLineCount ¶ added in v0.1.1
func (s *SourceAnalysis) CoveredLineCount() int
CoveredLineCount returns the count of lines that were covered across all source files.
func (*SourceAnalysis) LineCount ¶ added in v0.1.1
func (s *SourceAnalysis) LineCount() int
LineCount returns the count of lines across all source files.
func (*SourceAnalysis) SortedFiles ¶ added in v0.1.1
func (s *SourceAnalysis) SortedFiles() []*SourceFileAnalysis
SortedFiles returns a list of Files within the SourceAnalysis, sorted by source file path in alphabetical order.
type SourceFileAnalysis ¶ added in v0.1.1
type SourceFileAnalysis struct { // Path describes the file path of the source file. This is kept here for access during report generation. Path string // Lines describes information about a given source line and its coverage. Lines []*SourceLineAnalysis }
SourceFileAnalysis describes coverage information for a given source file.
func (*SourceFileAnalysis) ActiveLineCount ¶ added in v0.1.1
func (s *SourceFileAnalysis) ActiveLineCount() int
ActiveLineCount returns the count of lines that are marked executable/active within the source file.
func (*SourceFileAnalysis) CoveredLineCount ¶ added in v0.1.1
func (s *SourceFileAnalysis) CoveredLineCount() int
CoveredLineCount returns the count of lines that were covered within the source file.
type SourceLineAnalysis ¶ added in v0.1.1
type SourceLineAnalysis struct { // IsActive indicates the given source line was executable. IsActive bool // Start describes the starting byte offset of the line in its parent source file. Start int // End describes the ending byte offset of the line in its parent source file. End int // Contents describe the bytes associated with the given source line. Contents []byte // IsCovered indicates whether the source line has been executed without reverting. IsCovered bool // IsCoveredReverted indicates whether the source line has been executed before reverting. IsCoveredReverted bool }
SourceLineAnalysis describes coverage information for a specific source file line.