tests

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestAdminPrivateKey          string = "6aea45ee1273170fb525da34015e4f20ba39fe792f486ba74020bcacc9badfc1"
	SmartContractsRelativeFolder string = "bridge"
)

Test admin private key. DONT USE THIS ON MAINNET!!!!

Variables

This section is empty.

Functions

func AdvanceTo

func AdvanceTo(eth layer1.Client, target uint64)

AdvanceTo advances to a certain block number.

func CreateAccounts

func CreateAccounts(unitTestDirectory string, numAccounts int) (string, string, []accounts.Account)

CreateAccounts creates the privateKeys and accounts for a given number of accounts. The first created account will be always the hardhat admin account.

func FundAccounts

func FundAccounts(eth layer1.Client, watcher transaction.Watcher, logger *logrus.Entry) error

func GenerateHardhatConfig

func GenerateHardhatConfig(tempDir, hardhatPath, endPoint string) string

func GetAccountsWithoutOutKeyStore

func GetAccountsWithoutOutKeyStore(n int) ([]ecdsa.PublicKey, []common.Address)

func GetAdminAccount

func GetAdminAccount() (common.Address, *ecdsa.PrivateKey)

GetAdminAccount gets the admin account for the hardhat node. If that admin account is changed in the hardhat configs change this.

func GetHardhatBinPath

func GetHardhatBinPath() string

func GetHardhatPackagePath

func GetHardhatPackagePath() string

GetHardhatPackagePath return the bridge folder path.

func GetProjectRootPath

func GetProjectRootPath() string

func InitializePrivateKeys

func InitializePrivateKeys(n int) []*ecdsa.PrivateKey

func MineBlocks

func MineBlocks(endPoint string, blocksToMine uint64)

MineBlocks mines a certain number of hardhat blocks.

func MineFinalityDelayBlocks

func MineFinalityDelayBlocks(client layer1.Client)

Mine finality delay blocks + 1.

func ResetHardhatConfigs

func ResetHardhatConfigs(endPoint string)

ResetHardhatConfigs resets the hardhat configs to automine true and basefee 100GWei.

func ResetHardhatNode

func ResetHardhatNode(endPoint string)

ResetHardhatNode resets hardhat node from scratch.

func SendCommandViaRPC

func SendCommandViaRPC(url, command string, params ...interface{}) error

SendCommandViaRPC sends a command to the hardhat server via an RPC call.

func SetAutoMine

func SetAutoMine(endPoint string, autoMine bool)

SetAutoMine enables/disables hardhat autoMine.

func SetBlockInterval

func SetBlockInterval(endPoint string, intervalInMilliSeconds uint64)

SetBlockInterval sets the interval between hardhat blocks. In case interval is 0, we enter in manual mode and blocks can only be mined explicitly by calling `MineBlocks`. This function disables autoMine.

func SetCommandStdOut

func SetCommandStdOut(cmd *exec.Cmd)

SetCommandStdOut If ENABLE_SCRIPT_LOG env variable is set as 'true' the command will show scripts logs.

func SetNextBlockBaseFee

func SetNextBlockBaseFee(endPoint string, target uint64)

SetNextBlockBaseFee sets the the Base fee for the next hardhat block. Can be used to make tx stale.

func SetupPrivateKeys

func SetupPrivateKeys(n int) []*ecdsa.PrivateKey

SetupPrivateKeys computes deterministic private keys for testing.

func WaitGroupReceipts

func WaitGroupReceipts(t *testing.T, client layer1.Client, receiptResponses []transaction.ReceiptResponse)

Types

type ClientFixture

type ClientFixture struct {
	Client         layer1.Client
	Contracts      layer1.AllSmartContracts
	Watcher        transaction.Watcher
	MonitorDb      *db.Database
	FactoryAddress string
	TempDir        string
	KeyStorePath   string
	PassCodePath   string
	Logger         *logrus.Entry
}

func NewClientFixture

func NewClientFixture(hardhat *Hardhat, finalityDelay uint64, numAccounts int, logger *logrus.Entry, unlockAllAccounts, deployContracts, registerValidators bool) *ClientFixture

func (*ClientFixture) Close

func (c *ClientFixture) Close()

type Hardhat

type Hardhat struct {
	// contains filtered or unexported fields
}

func StartHardHatNode

func StartHardHatNode(hostname, port string) (*Hardhat, error)

func StartHardHatNodeWithDefaultHost

func StartHardHatNodeWithDefaultHost() (*Hardhat, error)

func (*Hardhat) Close

func (h *Hardhat) Close() error

func (*Hardhat) DeployFactoryAndContracts

func (h *Hardhat) DeployFactoryAndContracts(tmpDir, baseFilesDir string) (string, error)

func (*Hardhat) IsHardHatRunning

func (h *Hardhat) IsHardHatRunning() (bool, error)

func (*Hardhat) RegisterValidators

func (h *Hardhat) RegisterValidators(factoryAddress string, validators []string) error

func (*Hardhat) WaitForHardHatNode

func (h *Hardhat) WaitForHardHatNode(ctx context.Context) error

Jump to

Keyboard shortcuts

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