vmtest

package
v0.15.4-rc.2 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: GPL-3.0, LGPL-3.0 Imports: 49 Imported by: 0

Documentation

Overview

Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Index

Constants

This section is empty.

Variables

View Source
var SyncerVMTests = []SyncerVMTest{
	{
		Name:     "SkipStateSyncTest",
		TestFunc: SkipStateSyncTest,
	},
	{
		Name:     "StateSyncFromScratchTest",
		TestFunc: StateSyncFromScratchTest,
	},
	{
		Name:     "StateSyncFromScratchExceedParentTest",
		TestFunc: StateSyncFromScratchExceedParentTest,
	},
	{
		Name:     "StateSyncToggleEnabledToDisabledTest",
		TestFunc: StateSyncToggleEnabledToDisabledTest,
	},
	{
		Name:     "VMShutdownWhileSyncingTest",
		TestFunc: VMShutdownWhileSyncingTest,
	},
}

Functions

func ForkToRules

func ForkToRules(fork upgradetest.Fork) *extras.Rules

func GenesisJSON

func GenesisJSON(cfg *params.ChainConfig) string

GenesisJSON returns the JSON representation of the genesis block for the given chain configuration, with pre-funded accounts.

func NewPrefundedGenesis

func NewPrefundedGenesis(
	balance int,
	addresses ...common.Address,
) *core.Genesis

func NewTestGenesis

func NewTestGenesis(cfg *params.ChainConfig) *core.Genesis

func OverrideSchemeConfig

func OverrideSchemeConfig(scheme string, configJSON string) (string, error)

func ResetMetrics

func ResetMetrics(snowCtx *snow.Context)

ResetMetrics resets the vm avalanchego metrics, and allows for the VM to be re-initialized in tests.

func SetupGenesis

func SetupGenesis(
	t *testing.T,
	fork upgradetest.Fork,
) (*snow.Context,
	*prefixdb.Database,
	[]byte,
	*avalancheatomic.Memory,
)

SetupGenesis sets up the genesis

func SkipStateSyncTest

func SkipStateSyncTest(t *testing.T, testSetup *SyncTestSetup)

func StateSyncFromScratchExceedParentTest

func StateSyncFromScratchExceedParentTest(t *testing.T, testSetup *SyncTestSetup)

func StateSyncFromScratchTest

func StateSyncFromScratchTest(t *testing.T, testSetup *SyncTestSetup)

func StateSyncToggleEnabledToDisabledTest

func StateSyncToggleEnabledToDisabledTest(t *testing.T, testSetup *SyncTestSetup)

func VMShutdownWhileSyncingTest

func VMShutdownWhileSyncingTest(t *testing.T, testSetup *SyncTestSetup)

Types

type SyncTestParams

type SyncTestParams struct {
	StateSyncMinBlocks uint64
	SyncableInterval   uint64
	SyncMode           block.StateSyncMode
	// contains filtered or unexported fields
}

SyncTestParams contains both the actual VMs as well as the parameters with the expected output.

type SyncTestSetup

type SyncTestSetup struct {
	NewVM             func() (extension.InnerVM, dummy.ConsensusCallbacks) // should not be initialized
	AfterInit         func(t *testing.T, testParams SyncTestParams, vmSetup SyncVMSetup, isServer bool)
	GenFn             func(i int, vm extension.InnerVM, gen *core.BlockGen)
	ExtraSyncerVMTest func(t *testing.T, syncerVM SyncVMSetup)
}

type SyncVMSetup

type SyncVMSetup struct {
	VM                 extension.InnerVM
	SnowCtx            *snow.Context
	ConsensusCallbacks dummy.ConsensusCallbacks
	DB                 avalanchedatabase.Database
	AtomicMemory       *avalancheatomic.Memory
	AppSender          *enginetest.Sender
}

type SyncerVMTest

type SyncerVMTest struct {
	Name     string
	TestFunc func(
		t *testing.T,
		testSetup *SyncTestSetup,
	)
}

type TestVMConfig

type TestVMConfig struct {
	IsSyncing bool
	Fork      *upgradetest.Fork
	// If genesisJSON is empty, defaults to the genesis corresponding to the
	// fork.
	GenesisJSON string
	ConfigJSON  string
	// DB scheme, defaults to HashScheme
	Scheme string
}

type TestVMSuite

type TestVMSuite struct {
	VM           commoneng.VM
	DB           *prefixdb.Database
	AtomicMemory *avalancheatomic.Memory
	AppSender    *enginetest.Sender
	Ctx          *snow.Context
}

func SetupTestVM

func SetupTestVM(t *testing.T, vm commoneng.VM, config TestVMConfig) *TestVMSuite

SetupTestVM initializes a VM for testing. It sets up the genesis and returns the issuer channel, database, atomic memory, app sender, and context. Expects the passed VM to be a uninitialized VM.

Jump to

Keyboard shortcuts

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