testcommon

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SignerPrivKey = "e0aa6db5a833531da4d259fb5df210bae481b276dc4c2ab6ab9771569375aed5"

	// NewVoteHardcoded needs to be a constructor, since multiple tests will
	// modify its value. We need a different pointer for each test.
	NewVoteHardcoded = func() *state.Vote {
		vp, _ := base64.StdEncoding.DecodeString("eyJ0eXBlIjoicG9sbC12b3RlIiwibm9uY2UiOiI1NTkyZjFjMThlMmExNTk1M2YzNTVjMzRiMjQ3ZDc1MWRhMzA3MzM4Yzk5NDAwMGI5YTY1ZGIxZGMxNGNjNmMwIiwidm90ZXMiOlsxLDIsMV19")
		return &state.Vote{
			ProcessID:   testutil.Hex2byte(nil, "e9d5e8d791f51179e218c606f83f5967ab272292a6dbda887853d81f7a1d5105"),
			Nullifier:   testutil.Hex2byte(nil, "5592f1c18e2a15953f355c34b247d751da307338c994000b9a65db1dc14cc6c0"),
			VotePackage: vp,
		}
	}

	ProcessHardcoded = &models.Process{
		ProcessId:     testutil.Hex2byte(nil, "e9d5e8d791f51179e218c606f83f5967ab272292a6dbda887853d81f7a1d5105"),
		EntityId:      testutil.Hex2byte(nil, "180dd5765d9f7ecef810b565a2e5bd14a3ccd536c442b3de74867df552855e85"),
		CensusRoot:    testutil.Hex2byte(nil, "0a975f5cf517899e6116000fd366dc0feb34a2ea1b64e9b213278442dd9852fe"),
		CensusOrigin:  models.CensusOrigin_OFF_CHAIN_TREE,
		BlockCount:    1000,
		EnvelopeType:  &models.EnvelopeType{},
		Mode:          &models.ProcessMode{},
		Status:        models.ProcessStatus_READY,
		VoteOptions:   &models.ProcessVoteOptions{MaxCount: 16, MaxValue: 16},
		MaxCensusSize: 1000,
	}

	StateDBProcessHardcoded = &models.StateDBProcess{
		Process:   ProcessHardcoded,
		VotesRoot: make([]byte, 32),
	}
)

Functions

func NewMockIndexer added in v1.4.0

func NewMockIndexer(tb testing.TB, vnode *vochain.BaseApplication) *indexer.Indexer

func NewVochainState added in v1.3.0

func NewVochainState(tb testing.TB) *state.State

func NewVochainStateWithProcess

func NewVochainStateWithProcess(tb testing.TB) *state.State

func NewVochainStateWithValidators

func NewVochainStateWithValidators(tb testing.TB) *state.State

Types

type APIserver added in v1.4.0

type APIserver struct {
	Account     *ethereum.SignKeys
	ListenAddr  *url.URL
	Storage     data.Storage
	VochainAPP  *vochain.BaseApplication
	Indexer     *indexer.Indexer
	VochainInfo *vochaininfo.VochainInfo
	ChainID     string
}

APIserver contains all the required pieces for running a mock API server. It is used for testing purposes only. The server starts a Vochain instance, the Indexer, the IPFS storage and the API router. The blockchain is advanced by calling the APIserver.VochainAPP.AdvanceTestBlock() method.

func (*APIserver) Start added in v1.4.0

func (d *APIserver) Start(t testing.TB, apis ...string)

Start starts a basic URL API server for testing

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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