fuzzcommon

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 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
	InitialSetup      InitialSetup
}

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"`
	InitialSetup      InitialSetup      `json:"initialSetup"`
}

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

type InitialSetup

type InitialSetup struct {
	NumAdminWhitelist        int `json:"numAdminWhitelist"`
	NumGlobalWhitelist       int `json:"numGlobalWhitelist"`
	NumTopicCreatorWhitelist int `json:"numTopicCreatorWhitelist"`
}

InitialSetup holds configuration elements for the initial setup

func GetHardCodedInitialSetup

func GetHardCodedInitialSetup() InitialSetup

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"`
	AddToAdminWhitelist                  uint8 `json:"addToAdminWhitelist"`
	RemoveFromAdminWhitelist             uint8 `json:"removeFromAdminWhitelist"`
	AddToGlobalWhitelist                 uint8 `json:"addToGlobalWhitelist"`
	RemoveFromGlobalWhitelist            uint8 `json:"removeFromGlobalWhitelist"`
	AddToTopicCreatorWhitelist           uint8 `json:"addToTopicCreatorWhitelist"`
	RemoveFromTopicCreatorWhitelist      uint8 `json:"removeFromTopicCreatorWhitelist"`
	EnableTopicWorkerWhitelist           uint8 `json:"enableTopicWorkerWhitelist"`
	DisableTopicWorkerWhitelist          uint8 `json:"disableTopicWorkerWhitelist"`
	EnableTopicReputerWhitelist          uint8 `json:"enableTopicReputerWhitelist"`
	DisableTopicReputerWhitelist         uint8 `json:"disableTopicReputerWhitelist"`
	AddToTopicWorkerWhitelist            uint8 `json:"addToTopicWorkerWhitelist"`
	RemoveFromTopicWorkerWhitelist       uint8 `json:"removeFromTopicWorkerWhitelist"`
	AddToTopicReputerWhitelist           uint8 `json:"addToTopicReputerWhitelist"`
	RemoveFromTopicReputerWhitelist      uint8 `json:"removeFromTopicReputerWhitelist"`
	AddToGlobalWorkerWhitelist           uint8 `json:"addToGlobalWorkerWhitelist"`
	RemoveFromGlobalWorkerWhitelist      uint8 `json:"removeFromGlobalWorkerWhitelist"`
	AddToGlobalReputerWhitelist          uint8 `json:"addToGlobalReputerWhitelist"`
	RemoveFromGlobalReputerWhitelist     uint8 `json:"removeFromGlobalReputerWhitelist"`
	AddToGlobalAdminWhitelist            uint8 `json:"addToGlobalAdminWhitelist"`
	RemoveFromGlobalAdminWhitelist       uint8 `json:"removeFromGlobalAdminWhitelist"`
	BulkAddToGlobalWorkerWhitelist       uint8 `json:"bulkAddToGlobalWorkerWhitelist"`
	BulkRemoveFromGlobalWorkerWhitelist  uint8 `json:"bulkRemoveFromGlobalWorkerWhitelist"`
	BulkAddToGlobalReputerWhitelist      uint8 `json:"bulkAddToGlobalReputerWhitelist"`
	BulkRemoveFromGlobalReputerWhitelist uint8 `json:"bulkRemoveFromGlobalReputerWhitelist"`
	BulkAddToTopicWorkerWhitelist        uint8 `json:"bulkAddToTopicWorkerWhitelist"`
	BulkRemoveFromTopicWorkerWhitelist   uint8 `json:"bulkRemoveFromTopicWorkerWhitelist"`
	BulkAddToTopicReputerWhitelist       uint8 `json:"bulkAddToTopicReputerWhitelist"`
	BulkRemoveFromTopicReputerWhitelist  uint8 `json:"bulkRemoveFromTopicReputerWhitelist"`
}

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