testutil

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: LGPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Copyright 2022 Evmos Foundation This file is part of the Evmos Network packages.

Evmos is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Evmos packages are distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the Evmos packages. If not, see https://github.com/evmos/evmos/blob/main/LICENSE

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastTxBytes

func BroadcastTxBytes(app *app.App, txEncoder sdk.TxEncoder, tx sdk.Tx) (abci.ResponseDeliverTx, error)

BroadcastTxBytes encodes a transaction and calls DeliverTx on the app.

func CheckEthTx

func CheckEthTx(
	appEvmos *app.App,
	priv cryptotypes.PrivKey,
	msgs ...sdk.Msg,
) (abci.ResponseCheckTx, error)

CheckEthTx checks a Ethereum tx for a given set of msgs

func CheckEthTxResponse

func CheckEthTxResponse(r abci.ResponseDeliverTx, cdc codec.Codec) (*evm.MsgEthereumTxResponse, error)

CheckEthTxResponse checks that the transaction was executed successfully

func CheckTx

func CheckTx(
	ctx sdk.Context,
	appEvmos *app.App,
	priv cryptotypes.PrivKey,
	gasPrice *sdkmath.Int,
	msgs ...sdk.Msg,
) (abci.ResponseCheckTx, error)

CheckTx checks a cosmos tx for a given set of msgs

func Commit

func Commit(ctx sdk.Context, app *app.App, t time.Duration, vs *tmtypes.ValidatorSet) (sdk.Context, error)

Commit commits a block at a given time. Reminder: At the end of each Tendermint Consensus round the following methods are run

  1. BeginBlock
  2. DeliverTx
  3. EndBlock
  4. Commit

func Delegate

func Delegate(
	ctx sdk.Context,
	appEvmos *app.App,
	priv *ethsecp256k1.PrivKey,
	delegateAmount sdk.Coin,
	validator stakingtypes.Validator,
) (abci.ResponseDeliverTx, error)

Delegate delivers a delegate tx

func DeliverEthTx

func DeliverEthTx(
	appEvmos *app.App,
	priv cryptotypes.PrivKey,
	msgs ...sdk.Msg,
) (abci.ResponseDeliverTx, error)

DeliverEthTx generates and broadcasts a Cosmos Tx populated with MsgEthereumTx messages. If a private key is provided, it will attempt to sign all messages with the given private key, otherwise, it will assume the messages have already been signed.

func DeliverTx

func DeliverTx(
	ctx sdk.Context,
	appEvmos *app.App,
	priv cryptotypes.PrivKey,
	gasPrice *sdkmath.Int,
	msgs ...sdk.Msg,
) (abci.ResponseDeliverTx, error)

DeliverTx delivers a cosmos tx for a given set of msgs

func DeployContract

func DeployContract(
	ctx sdk.Context,
	evmosApp *app.App,
	priv cryptotypes.PrivKey,
	queryClientEvm evm.QueryClient,
	contract evm.CompiledContract,
	constructorArgs ...interface{},
) (common.Address, error)

DeployContract deploys a contract with the provided private key, compiled contract data and constructor arguments

func DeployContractWithFactory

func DeployContractWithFactory(
	ctx sdk.Context,
	evmosApp *app.App,
	priv cryptotypes.PrivKey,
	factoryAddress common.Address,
) (common.Address, abci.ResponseDeliverTx, error)

DeployContractWithFactory deploys a contract using a contract factory with the provided factoryAddress

func NewHeader

func NewHeader(
	height int64,
	blockTime time.Time,
	chainID string,
	proposer sdk.ConsAddress,
	appHash,
	validatorHash []byte,
) tmproto.Header

NewHeader creates a new Tendermint header for testing purposes.

func NewStateDB

func NewStateDB(ctx sdk.Context, evmKeeper evm.EVMKeeper) *statedb.StateDB

NewStateDB returns a new StateDB for testing purposes.

func NextFn

func NextFn(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error)

NextFn is a no-op function that returns the context and no error in order to mock the next function in the AnteHandler chain.

It can be used in unit tests when calling a decorator's AnteHandle method, e.g. `dec.AnteHandle(ctx, tx, false, NextFn)`

func SubmitProposal

func SubmitProposal(
	ctx sdk.Context,
	appEvmos *app.App,
	pk *ethsecp256k1.PrivKey,
	content govv1beta1.Content,
	eventNum int,
) (id uint64, err error)

SubmitProposal delivers a submit proposal tx for a given gov content. Depending on the content type, the eventNum needs to specify submit_proposal event.

func ValidateAnteForMsgs

func ValidateAnteForMsgs(ctx sdk.Context, dec sdk.AnteDecorator, msgs ...sdk.Msg) error

ValidateAnteForMsgs is a helper function, which takes in an AnteDecorator as well as 1 or more messages, builds a transaction containing these messages, and returns any error that the AnteHandler might return.

func Vote

func Vote(
	ctx sdk.Context,
	appEvmos *app.App,
	priv *ethsecp256k1.PrivKey,
	proposalID uint64,
	voteOption govv1beta1.VoteOption,
) (abci.ResponseDeliverTx, error)

Vote delivers a vote tx with the VoteOption "yes"

Types

This section is empty.

Directories

Path Synopsis
Package network implements and exposes a fully operational in-process Tendermint test network that consists of at least one or potentially many validators.
Package network implements and exposes a fully operational in-process Tendermint test network that consists of at least one or potentially many validators.

Jump to

Keyboard shortcuts

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