testing

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPeriodicCommitDelay = time.Millisecond

DefaultPeriodicCommitDelay the default delay to running the commit function on the simulated network.

View Source
const EVMTestNetworkChainID = 1337

EVMTestNetworkChainID the test EVM network chain ID.

Variables

View Source
var ErrTimeout = errors.New("timeout")
View Source
var NodeEVMPrivateKey, _ = crypto.HexToECDSA("64a1d6f0e760a8d62b4afdde4096f16f51b401eaaecc915740f71770ea76a8ad")

NodeEVMPrivateKey the key used to initialize the test node validator. Its corresponding address is: "0x9c2B12b5a07FC6D719Ed7646e5041A7E85758329".

Functions

func NewEVMClient

func NewEVMClient(ks *keystore.KeyStore, acc *accounts.Account) *evm.Client

func NewOrchestrator

func NewOrchestrator(
	t *testing.T,
	node *TestNode,
) *orchestrator.Orchestrator

func NewRelayer

func NewRelayer(
	t *testing.T,
	node *TestNode,
) *relayer.Relayer

func NewTestDHT

func NewTestDHT(ctx context.Context, bootstrappers []peer.AddrInfo) (host.Host, ds.Batching, *p2p.BlobstreamDHT)

NewTestDHT creates a test DHT not connected to any peers.

func RegisterEVMAddress

func RegisterEVMAddress(
	t *testing.T,
	input celestiatestnode.Context,
	valAddr sdk.ValAddress,
	evmAddr gethcommon.Address,
)

func SetDataCommitmentWindowParams

func SetDataCommitmentWindowParams(codec codec.Codec, params types.Params) celestiatestnode.GenesisOption

SetDataCommitmentWindowParams will set the provided data commitment window as genesis state.

func WaitForPeerTableToUpdate

func WaitForPeerTableToUpdate(ctx context.Context, dhts []*p2p.BlobstreamDHT, timeout time.Duration) error

WaitForPeerTableToUpdate waits for nodes to have updated their peers list

Types

type CelestiaNetwork

type CelestiaNetwork struct {
	celestiatestnode.Context
	Accounts []string
	RPCAddr  string
	GRPCAddr string
}

CelestiaNetwork is a Celestia-app validator running in-process. The EVM key that was used to create this network's single validator can be retrieved using: `celestiatestnode.NodeEVMPrivateKey`

func NewCelestiaNetwork

func NewCelestiaNetwork(ctx context.Context, t *testing.T, params CelestiaNetworkParams) *CelestiaNetwork

NewCelestiaNetwork creates a new CelestiaNetwork. Uses `testing.T` to fail if an error happens. Only supports the creation of a single validator currently.

func (*CelestiaNetwork) SetDataCommitmentWindow

func (cn *CelestiaNetwork) SetDataCommitmentWindow(t *testing.T, window uint64)

SetDataCommitmentWindow will use the validator account to set the data commitment window param. It assumes that the governance params have been set to allow for fast acceptance of proposals, and will fail the test if the parameters are not set as expected.

type CelestiaNetworkParams

type CelestiaNetworkParams struct {
	GenesisOpts   []celestiatestnode.GenesisOption
	TimeIotaMs    int64
	Pruning       string
	TimeoutCommit time.Duration
}

func DefaultCelestiaNetworkParams

func DefaultCelestiaNetworkParams() CelestiaNetworkParams

type DHTNetwork

type DHTNetwork struct {
	Context context.Context
	Hosts   []host.Host
	Stores  []ds.Batching
	DHTs    []*p2p.BlobstreamDHT
}

DHTNetwork is a test DHT network that can be used for tests.

func NewDHTNetwork

func NewDHTNetwork(ctx context.Context, count int) *DHTNetwork

NewDHTNetwork creates a new DHT test network running in-memory. The stores are in-memory stores. The hosts listen on real ports. The nodes are all connected to `hosts[0]` node. The `count` parameter specifies the number of nodes that the network will run. This function doesn't return any errors, and panics in case any unexpected happened.

func (DHTNetwork) Stop

func (tn DHTNetwork) Stop()

Stop tears down the test network and stops all the services. Panics if an error occurs.

type EVMChain

type EVMChain struct {
	Auth         *bind.TransactOpts
	GenesisAlloc core.GenesisAlloc
	Backend      *backends.SimulatedBackend
	Key          *ecdsa.PrivateKey // TODO provide the keystore directly here
	ChainID      uint64
}

EVMChain is a wrapped Geth simulated backend which will be used to simulate an EVM chain. The resulting test chain has always 1337 as a chain ID.

func NewEVMChain

func NewEVMChain(key *ecdsa.PrivateKey) *EVMChain

func (*EVMChain) Close

func (e *EVMChain) Close()

Close stops the EVM chain backend.

func (*EVMChain) PeriodicCommit

func (e *EVMChain) PeriodicCommit(ctx context.Context, delay time.Duration)

PeriodicCommit periodically run `commit()` on the simulated network to mine the hanging blocks. If there are no hanging transactions, the chain will not advance.

type TestNode

type TestNode struct {
	Context         context.Context
	DHTNetwork      *DHTNetwork
	CelestiaNetwork *CelestiaNetwork
	EVMChain        *EVMChain
}

TestNode contains a DHTNetwork along with a test Celestia network and a simulated EVM chain.

func NewTestNode

func NewTestNode(ctx context.Context, t *testing.T, celestiaParams CelestiaNetworkParams) *TestNode

func (TestNode) Close

func (tn TestNode) Close()

Jump to

Keyboard shortcuts

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