fuzzcommon

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IterateAndCheckSum

func IterateAndCheckSum(structToCheck interface{}) (fieldsSum uint64, ok bool)

Iterate over a struct and check that the sum of its fields is 100

Types

type FuzzConfig

type FuzzConfig struct {
	Seed              int
	RpcMode           testcommon.RpcConnectionType
	RpcEndpoints      []string
	MaxIterations     int
	NumActors         int
	EpochLength       int
	Mode              SimulationMode
	AlternateWeight   int
	TestConfig        *testcommon.TestConfig
	TransitionWeights TransitionWeights
}

struct that holds the config for fuzz tests which includes slightly different config from integration/stress tests

func GetFuzzConfig

func GetFuzzConfig(t *testing.T) FuzzConfig

Return a FuzzConfig struct for this fuzz session The order of priority is as follows: 1. env vars 2. test/fuzz/config.json 3. default values hard coded in this function

type FuzzConfigJson

type FuzzConfigJson struct {
	TransitionWeights TransitionWeights `json:"transitionWeights"`
	Seed              int               `json:"seed"`
	RpcMode           string            `json:"rpcMode"`
	RpcUrls           []string          `json:"rpcUrls"`
	MaxIterations     int               `json:"maxIterations"`
	Mode              SimulationMode    `json:"mode"`
	AlternateWeight   int               `json:"alternateWeight"`
	NumActors         int               `json:"numActors"`
	EpochLength       int               `json:"epochLength"`
}

struct that holds config from test/fuzz/.config.json

type SimulationMode

type SimulationMode string
const (
	Behave    SimulationMode = "behave"
	Fuzz      SimulationMode = "fuzz"
	Alternate SimulationMode = "alternate"
	Manual    SimulationMode = "manual"
)

type TransitionWeights

type TransitionWeights struct {
	CreateTopic                uint8 `json:"createTopic"`
	FundTopic                  uint8 `json:"fundTopic"`
	RegisterWorker             uint8 `json:"registerWorker"`
	RegisterReputer            uint8 `json:"registerReputer"`
	StakeAsReputer             uint8 `json:"stakeAsReputer"`
	DelegateStake              uint8 `json:"delegateStake"`
	CollectDelegatorRewards    uint8 `json:"collectDelegatorRewards"`
	DoInferenceAndReputation   uint8 `json:"doInferenceAndReputation"`
	UnregisterWorker           uint8 `json:"unregisterWorker"`
	UnregisterReputer          uint8 `json:"unregisterReputer"`
	UnstakeAsReputer           uint8 `json:"unstakeAsReputer"`
	UndelegateStake            uint8 `json:"undelegateStake"`
	CancelStakeRemoval         uint8 `json:"cancelStakeRemoval"`
	CancelDelegateStakeRemoval uint8 `json:"cancelDelegateStakeRemoval"`
}

full list of all possible transitions

func GetHardCodedTransitionWeights

func GetHardCodedTransitionWeights() TransitionWeights

Return the "weight" aka, the percentage probability of each transition assuming a perfectly random distribution when picking transitions i.e. below, the probability of picking createTopic is 2%

Jump to

Keyboard shortcuts

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