testutils

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// Local RPCs
	DefaultInternalFullNodeUrl     = "http://host.docker.internal:16667/wallet"
	DefaultInternalSolidityNodeUrl = "http://host.docker.internal:16668/walletsolidity"
	FullNodePort                   = "16667"
	SolidityNodePort               = "16668"

	// Testnet RPCs
	// Urls can be found at https://developers.tron.network/reference/background
	ShastaFullNodeUrl     = "https://api.shasta.trongrid.io/wallet"
	ShastaSolidityNodeUrl = "https://api.shasta.trongrid.io/walletsolidity"

	NileFullNodeUrl     = "https://nile.trongrid.io/wallet"
	NileSolidityNodeUrl = "https://nile.trongrid.io/walletsolidity"

	// Configs for TXM
	DevnetFeeLimit                  = 1_000_000_000
	DevnetMaxWaitTime               = 30 //seconds
	DevnetPollFrequency             = 1  //seconds
	DevnetOcrTransmissionFrequency  = 5 * time.Second
	TestnetFeeLimit                 = 10_000_000_000
	TestnetMaxWaitTime              = 90 //seconds
	TestnetPollFrequency            = 5  //seconds
	TestnetOcrTransmissionFrequency = 10 * time.Second

	// Testing network names
	Shasta = "shasta"
	Nile   = "nile"
	Devnet = "devnet"
)
View Source
const TRON_OCR2_AGGREGATOR_ABI = "" /* 18826-byte string literal not displayed */

todo: import and parse from elsewhere (manifest?)

Variables

This section is empty.

Functions

func CheckContractDeployed

func CheckContractDeployed(t *testing.T, fullnodeClient sdk.FullNodeClient, address address.Address) (contractDeployed bool)

func FindGitRoot

func FindGitRoot() (string, error)

Finds the closest git repo root, assuming that a directory with a .git directory is a git repo.

func GetTronNodeIpAddress

func GetTronNodeIpAddress() string

func SignAndDeployContract

func SignAndDeployContract(t *testing.T, fullnodeClient sdk.FullNodeClient, keystore loop.Keystore, fromAddress address.Address, contractName string, abiJson string, codeHex string, feeLimit int, params []interface{}) string

func StartTronNode

func StartTronNode(genesisAddress string) error

func StopTronNode

func StopTronNode() error

func WaitForInflightTxs

func WaitForInflightTxs(logger logger.Logger, txmgr *txm.TronTxm, timeout time.Duration)

func WaitForTransactionInfo

func WaitForTransactionInfo(t *testing.T, client sdk.FullNodeClient, txHash string, waitSecs int) *soliditynode.TransactionInfo

Types

type TestKey

type TestKey struct {
	ID uuid.UUID // Version 4 "random" for unique id not derived from key data
	// to simplify lookups we also store the address
	Address address.Address
	// we only store privkey as pubkey/address can be derived from it
	// privkey in this struct is always in plaintext
	PrivateKey *ecdsa.PrivateKey
}

func CreateKey

func CreateKey(rand io.Reader) *TestKey

func NewKeyFromECDSA

func NewKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *TestKey

type TestKeystore

type TestKeystore struct {
	Keys map[string]*ecdsa.PrivateKey
}

func NewTestKeystore

func NewTestKeystore(address string, privateKey *ecdsa.PrivateKey) *TestKeystore

func (*TestKeystore) Accounts

func (tk *TestKeystore) Accounts(ctx context.Context) ([]string, error)

func (*TestKeystore) Sign

func (tk *TestKeystore) Sign(ctx context.Context, id string, hash []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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