Skip to content

Commit

Permalink
fix lint and lower chance of generating random address, bytes, or string
Browse files Browse the repository at this point in the history
  • Loading branch information
anishnaik committed Jan 14, 2025
1 parent 96b83ed commit 163eda8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fuzzing/calls/call_sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (cse *CallSequenceElement) DecodedReturnValues() ([]any, error) {

// Retrieve the ABI-encoded return data
encodedReturnData := cse.ChainReference.Block.MessageResults[cse.ChainReference.TransactionIndex].ExecutionResult.ReturnData
if encodedReturnData == nil || len(encodedReturnData) == 0 {
if len(encodedReturnData) == 0 {
return nil, nil
}

Expand Down
6 changes: 3 additions & 3 deletions fuzzing/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,10 @@ func defaultCallSequenceGeneratorConfigFunc(fuzzer *Fuzzer, valueSet *valuegener
mutationalGeneratorConfig := &valuegeneration.MutationalValueGeneratorConfig{
MinMutationRounds: 0,
MaxMutationRounds: 1,
GenerateRandomAddressBias: 0.5,
GenerateRandomAddressBias: 0.05,
GenerateRandomIntegerBias: 0.5,
GenerateRandomStringBias: 0.5,
GenerateRandomBytesBias: 0.1,
GenerateRandomStringBias: 0.05,
GenerateRandomBytesBias: 0.05,
MutateAddressProbability: 0.1,
MutateArrayStructureProbability: 0.1,
MutateBoolProbability: 0.1,
Expand Down
4 changes: 2 additions & 2 deletions fuzzing/fuzzer_worker_sequence_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ func (g *CallSequenceGenerator) generateNewElement() (*calls.CallSequenceElement
}

// Select a random method
// There is a 1/100 chance that a pure method will be invoked or if there are only pure functions that are callable
// There is a 1/1000 chance that a pure method will be invoked or if there are only pure functions that are callable
var selectedMethod *contracts.DeployedContractMethod
if (len(g.worker.pureMethods) > 0 && g.worker.randomProvider.Intn(100) == 0) || callOnlyPureFunctions {
if (len(g.worker.pureMethods) > 0 && g.worker.randomProvider.Intn(1000) == 0) || callOnlyPureFunctions {
selectedMethod = &g.worker.pureMethods[g.worker.randomProvider.Intn(len(g.worker.pureMethods))]
} else {
selectedMethod = &g.worker.stateChangingMethods[g.worker.randomProvider.Intn(len(g.worker.stateChangingMethods))]
Expand Down

0 comments on commit 163eda8

Please sign in to comment.