generator

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MULTI_PEER_BISECTION_PATH = "./tests/json/bisection/multi_peer/"
View Source
const SINGLE_PEER_BISECTION_PATH = "./tests/json/bisection/single_peer/"
View Source
const (
	SINGLE_STEP_SEQ_PATH = "./tests/json/single_step/sequential/"
)
View Source
const (
	SINGLE_STEP_SKIPPING_PATH = "./tests/json/single_step/skipping/"
)
View Source
const (
	TRUSTING_PERIOD = 3 * time.Hour
)

Variables

This section is empty.

Functions

func GenerateManyHeaderBisectionCases

func GenerateManyHeaderBisectionCases(jsonValList string)

func GenerateSingleStepSequentialCases

func GenerateSingleStepSequentialCases(jsonValList string)

GenerateSingleStepSequentialCases creates three json files each for validator set, commit and header cases These cases are categorized according to the data structure it is trying to test (e.g. Validator set, Commit, etc...) It produces cases that test the single step sequential verification what this means is, given a trusted state and height can the lite node verify the next block height?

func GenerateSingleStepSkippingCases

func GenerateSingleStepSkippingCases(jsonValList string)

GenerateSingleStepSkippingCases creates three json files each for validator set, commit and header cases These cases test the single step skipping verification which means, given a trusted height and state can the lite node jump to a certain block height?

func GenerateValList

func GenerateValList(numVals int, votingPower int64)

GenerateValList produces a val_list.json file which contains a list validators and privVals of given number abd voting power

func NewState

func NewState(chainID string, valSet *types.ValidatorSet, nextValSet *types.ValidatorSet) st.State

NewState is used to initiate a state that will be used and manipulated by functions to create blocks for the "simulated" blockchain It creates an INITIAL state with the given parameters

func ReadFile

func ReadFile(file string) []byte

ReadFile returns the byte slice of the content in the given file "file" parameter is the path to the file to be read

Types

type Initial

type Initial struct {
	SignedHeader     types.SignedHeader `json:"signed_header"`
	NextValidatorSet types.ValidatorSet `json:"next_validator_set"`
	TrustingPeriod   time.Duration      `json:"trusting_period"`
	Now              time.Time          `json:"now"`
}

Initial stores the data required by a test case to set the context i.e. the initial state to begin the test from

type LiteBlock

type LiteBlock struct {
	SignedHeader     types.SignedHeader `json:"signed_header"`
	ValidatorSet     types.ValidatorSet `json:"validator_set"`
	NextValidatorSet types.ValidatorSet `json:"next_validator_set"`
}

LiteBlock refers to the minimum data a lite client interacts with. Essentially, it only requires a SignedHeader and Validator Set for current and next height

type MockProvider

type MockProvider struct {
	ChainId    string      `json:"chain_id"`
	LiteBlocks []LiteBlock `json:"lite_blocks"`
}

func (MockProvider) ChainID

func (mp MockProvider) ChainID() string

func (MockProvider) Copy

func (mp MockProvider) Copy() MockProvider

func (MockProvider) New

func (mp MockProvider) New(chainID string, liteBlocks []LiteBlock) MockProvider

func (MockProvider) SignedHeader

func (mp MockProvider) SignedHeader(height int64) (*types.SignedHeader, error)

func (MockProvider) ValidatorSet

func (mp MockProvider) ValidatorSet(height int64) (*types.ValidatorSet, error)

type TestBisection

type TestBisection struct {
	Description        string              `json:"description"`
	TrustOptions       TrustOptions        `json:"trust_options"`
	Primary            MockProvider        `json:"primary"`
	Witnesses          []provider.Provider `json:"witnesses"`
	HeightToVerify     int64               `json:"height_to_verify"`
	Now                time.Time           `json:"now"`
	ExpectedOutput     string              `json:"expected_output"`
	ExpectedBisections int32               `json:"expected_num_of_bisections"`
}

type TestCase

type TestCase struct {
	Description    string      `json:"description"`
	Initial        Initial     `json:"initial"`
	Input          []LiteBlock `json:"input"`
	ExpectedOutput string      `json:"expected_output"`
}

TestCase stores all the necessary information for single step test cases to perform verification test on the data given

type TrustOptions

type TrustOptions struct {
	// Trusting Period
	Period time.Duration `json:"period"`
	// Trusted Header Height
	Height int64 `json:"height"`
	// Trusted Header Hash
	Hash       tmbytes.HexBytes `json:"hash"`
	TrustLevel tmmath.Fraction  `json:"trust_level"`
}

type ValList

type ValList struct {
	Validators []*types.Validator            `json:"validators"`
	PrivVals   types.PrivValidatorsByAddress `json:"priv_val"`
}

ValList stores a list of validators and privVals It is populated from the lite-client/tests/json/val_list.json It used to have a predefined set of validators for mocking the test data

func GetValList

func GetValList(file string) ValList

GetValList reads the validators and privals list in the file unmarshals it to ValList struct "file" parameter specifies the path to the val_list.json file

func (ValList) Copy

func (valList ValList) Copy() (vl ValList)

Copy is essentially used to dereference the pointer ValList contains valSet pointer and privVal interface So to avoid manipulating the original list, we better copy it!

type ValSetChanges

type ValSetChanges []ValList

Jump to

Keyboard shortcuts

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