icon

package
v0.1.0-alpha.12 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GOLOOP_IMAGE_ENV     = "GOLOOP_IMAGE"
	GOLOOP_IMAGE         = "iconloop/goloop-icon"
	GOLOOP_IMAGE_TAG_ENV = "GOLOOP_IMAGE_TAG"
	GOLOOP_IMAGE_TAG     = "latest"
)

Variables

View Source
var ContainerEnvs = [9]string{
	"GOCHAIN_CONFIG=/goloop/data/config.json",
	"GOCHAIN_GENESIS=/goloop/data/genesis.json",
	"GOCHAIN_DATA=/goloop/chain/iconee",
	"GOCHAIN_LOGFILE=/goloop/chain/iconee.log",
	"GOCHAIN_DB_TYPE=rocksdb",
	"GOCHAIN_CLEAN_DATA=true",
	"JAVAEE_BIN=/goloop/execman/bin/execman",
	"PYEE_VERIFY_PACKAGE=true",
	"ICON_CONFIG=/goloop/data/icon_config.json",
}

Functions

func NewIconChain

func NewIconChain(t *testing.T, ctx context.Context, environment string, chainConfig chains.ChainConfig, nid string, keystorePath string, keyPassword string, url string, scorePaths map[string]string, logger *zap.Logger) (chains.Chain, error)

func NewIconLocalnet

func NewIconLocalnet(testName string, log *zap.Logger, chainConfig ibc.ChainConfig, numValidators int, numFullNodes int, keystorePath string, keyPassword string, scorePaths map[string]string) chains.Chain

func NewWallet

func NewWallet(keyname string, address []byte, mnemonic string, chainCfg ibc.ChainConfig) ibc.Wallet

Types

type IconLocalnet

type IconLocalnet struct {
	FullNodes IconNodes

	IBCAddresses map[string]string
	// contains filtered or unexported fields
}

func (*IconLocalnet) Acknowledgements

func (c *IconLocalnet) Acknowledgements(ctx context.Context, height uint64) ([]ibc.PacketAcknowledgement, error)

Acknowledgements returns all acknowledgements in a block at height.

func (*IconLocalnet) BuildRelayerWallet

func (c *IconLocalnet) BuildRelayerWallet(ctx context.Context, keyName string) (ibc.Wallet, error)

BuildRelayerWallet will return a chain-specific wallet populated with the mnemonic so that the wallet can be restored in the relayer node using the mnemonic. After it is built, that address is included in genesis with some funds.

func (*IconLocalnet) BuildWallet

func (c *IconLocalnet) BuildWallet(ctx context.Context, keyName string, mnemonic string) (ibc.Wallet, error)

func (*IconLocalnet) BuildWallets

func (c *IconLocalnet) BuildWallets(ctx context.Context, keyName string) error

func (*IconLocalnet) CheckForKeyStore

func (c *IconLocalnet) CheckForKeyStore(ctx context.Context, keyName string) string

func (*IconLocalnet) Config

func (c *IconLocalnet) Config() ibc.ChainConfig

Config fetches the chain configuration.

func (*IconLocalnet) ConfigureBaseConnection

func (c *IconLocalnet) ConfigureBaseConnection(ctx context.Context, connection chains.XCallConnection) (context.Context, error)

func (*IconLocalnet) CreateKey

func (c *IconLocalnet) CreateKey(ctx context.Context, password string) error

CreateKey creates a test key in the "user" node (either the first fullnode or the first validator if no fullnodes).

func (*IconLocalnet) DeployContract

func (c *IconLocalnet) DeployContract(ctx context.Context, keyName string) (context.Context, error)

DeployContract implements chains.Chain

func (*IconLocalnet) DeployXCallMockApp

func (c *IconLocalnet) DeployXCallMockApp(ctx context.Context, connection chains.XCallConnection) error

func (*IconLocalnet) EOAXCall

func (c *IconLocalnet) EOAXCall(ctx context.Context, targetChain chains.Chain, keyName, _to string, data []byte, sources, destinations []string) (string, string, string, error)

func (*IconLocalnet) Exec

func (c *IconLocalnet) Exec(ctx context.Context, cmd []string, env []string) (stdout []byte, stderr []byte, err error)

Exec runs an arbitrary command using Chain's docker environment. Whether the invoked command is run in a one-off container or execing into an already running container is up to the chain implementation.

"env" are environment variables in the format "MY_ENV_VAR=value"

func (*IconLocalnet) ExecuteCall

func (c *IconLocalnet) ExecuteCall(ctx context.Context, reqId, data string) (context.Context, error)

func (*IconLocalnet) ExecuteContract

func (c *IconLocalnet) ExecuteContract(ctx context.Context, contractAddress, keyName, methodName, param string) (context.Context, error)

ExecuteContract implements chains.Chain

func (*IconLocalnet) ExecuteRollback

func (c *IconLocalnet) ExecuteRollback(ctx context.Context, sn string) (context.Context, error)

func (*IconLocalnet) ExportState

func (c *IconLocalnet) ExportState(ctx context.Context, height int64) (string, error)

ExportState exports the chain state at specific height.

func (*IconLocalnet) FindCallMessage

func (c *IconLocalnet) FindCallMessage(ctx context.Context, startHeight int64, from, to, sn string) (string, string, error)

func (*IconLocalnet) FindCallResponse

func (c *IconLocalnet) FindCallResponse(ctx context.Context, startHeight int64, sn string) (string, string, error)

func (*IconLocalnet) FindEvent

func (c *IconLocalnet) FindEvent(ctx context.Context, startHeight int64, contract, signature string, index []*string) (*icontypes.EventNotification, error)

func (*IconLocalnet) FindTxs

func (c *IconLocalnet) FindTxs(ctx context.Context, height uint64) ([]blockdb.Tx, error)

func (*IconLocalnet) GetAddress

func (c *IconLocalnet) GetAddress(ctx context.Context, keyName string) ([]byte, error)

GetAddress fetches the bech32 address for a test key on the "user" node (either the first fullnode or the first validator if no fullnodes).

func (*IconLocalnet) GetBalance

func (c *IconLocalnet) GetBalance(ctx context.Context, address string, denom string) (int64, error)

GetBalance fetches the current balance for a specific account address and denom.

func (*IconLocalnet) GetBlockByHeight

func (c *IconLocalnet) GetBlockByHeight(ctx context.Context) (context.Context, error)

GetBlockByHeight implements chains.Chain

func (*IconLocalnet) GetExecuteParam

func (c *IconLocalnet) GetExecuteParam(ctx context.Context, methodName, params string) (context.Context, string, string)

func (*IconLocalnet) GetGRPCAddress

func (c *IconLocalnet) GetGRPCAddress() string

GetGRPCAddress retrieves the grpc address that can be reached by other containers in the docker network. Not Applicable for Icon

func (*IconLocalnet) GetGasFeesInNativeDenom

func (c *IconLocalnet) GetGasFeesInNativeDenom(gasPaid int64) int64

GetGasFeesInNativeDenom gets the fees in native denom for an amount of spent gas.

func (*IconLocalnet) GetHostGRPCAddress

func (c *IconLocalnet) GetHostGRPCAddress() string

GetHostGRPCAddress returns the grpc address that can be reached by processes on the host machine. Note that this will not return a valid value until after Start returns. Not applicable for Icon

func (*IconLocalnet) GetHostRPCAddress

func (c *IconLocalnet) GetHostRPCAddress() string

GetHostRPCAddress returns the rpc address that can be reached by processes on the host machine. Note that this will not return a valid value until after Start returns.

func (*IconLocalnet) GetIBCAddress

func (c *IconLocalnet) GetIBCAddress(key string) string

func (*IconLocalnet) GetLastBlock

func (c *IconLocalnet) GetLastBlock(ctx context.Context) (context.Context, error)

GetLastBlock implements chains.Chain

func (*IconLocalnet) GetQueryParam

func (c *IconLocalnet) GetQueryParam(methodName string) string

func (*IconLocalnet) GetRPCAddress

func (c *IconLocalnet) GetRPCAddress() string

GetRPCAddress retrieves the rpc address that can be reached by other containers in the docker network.

func (*IconLocalnet) Height

func (c *IconLocalnet) Height(ctx context.Context) (uint64, error)

Height returns the current block height or an error if unable to get current height.

func (*IconLocalnet) HomeDir

func (c *IconLocalnet) HomeDir() string

HomeDir is the home directory of a node running in a docker container. Therefore, this maps to the container's filesystem (not the host).

func (*IconLocalnet) Initialize

func (c *IconLocalnet) Initialize(ctx context.Context, testName string, cli *client.Client, networkID string) error

Initialize initializes node structs so that things like initializing keys can be done before starting the chain

func (*IconLocalnet) NewChainNode

func (c *IconLocalnet) NewChainNode(
	ctx context.Context,
	testName string,
	cli *client.Client,
	networkID string,
	image ibc.DockerImage,
	validator bool,
) (*IconNode, error)

func (*IconLocalnet) OverrideConfig

func (c *IconLocalnet) OverrideConfig(key string, value any)

func (*IconLocalnet) QueryContract

func (c *IconLocalnet) QueryContract(ctx context.Context, contractAddress, methodName, params string) (context.Context, error)

QueryContract implements chains.Chain

func (*IconLocalnet) RecoverKey

func (c *IconLocalnet) RecoverKey(ctx context.Context, name string, mnemonic string) error

RecoverKey recovers an existing user from a given mnemonic.

func (*IconLocalnet) SendFunds

func (c *IconLocalnet) SendFunds(ctx context.Context, keyName string, amount ibc.WalletAmount) error

SendFunds sends funds to a wallet from a user account.

func (*IconLocalnet) SendIBCTransfer

func (c *IconLocalnet) SendIBCTransfer(ctx context.Context, channelID string, keyName string, amount ibc.WalletAmount, options ibc.TransferOptions) (ibc.Tx, error)

SendIBCTransfer sends an IBC transfer returning a transaction or an error if the transfer failed.

func (*IconLocalnet) SetAdminParams

func (c *IconLocalnet) SetAdminParams(ctx context.Context, methodaName, keyName string) (context.Context, string, string)

func (*IconLocalnet) SetupIBC

func (c *IconLocalnet) SetupIBC(ctx context.Context, keyName string) (context.Context, error)

func (*IconLocalnet) SetupXCall

func (c *IconLocalnet) SetupXCall(ctx context.Context, portId string, keyName string) error

func (*IconLocalnet) Start

func (c *IconLocalnet) Start(testName string, ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) error

Start sets up everything needed (validators, gentx, fullnodes, peering, additional accounts) for chain to start from genesis.

func (*IconLocalnet) Timeouts

func (c *IconLocalnet) Timeouts(ctx context.Context, height uint64) ([]ibc.PacketTimeout, error)

Timeouts returns all timeouts in a block at height.

func (*IconLocalnet) UpdateAdminParams

func (c *IconLocalnet) UpdateAdminParams(ctx context.Context, methodaName, keyName string) (context.Context, string, string)

func (*IconLocalnet) XCall

func (c *IconLocalnet) XCall(ctx context.Context, targetChain chains.Chain, keyName, _to string, data, rollback []byte) (string, string, string, error)

type IconNode

type IconNode struct {
	VolumeName   string
	Index        int
	Chain        ibc.Chain
	NetworkID    string
	DockerClient *dockerclient.Client
	Client       iconclient.Client
	TestName     string
	Image        ibc.DockerImage

	ContainerID string
	// Ports set during StartContainer.
	HostRPCPort string
	Validator   bool

	Address string
	// contains filtered or unexported fields
}

func (*IconNode) BinCommand

func (in *IconNode) BinCommand(command ...string) []string

func (*IconNode) Bind

func (in *IconNode) Bind() []string

func (*IconNode) CopyFile

func (tn *IconNode) CopyFile(ctx context.Context, srcPath, dstPath string) error

CopyFile adds a file from the host filesystem to the docker filesystem relPath describes the location of the file in the docker volume relative to the home directory

func (*IconNode) CreateKey

func (in *IconNode) CreateKey(ctx context.Context, password string) error

func (*IconNode) CreateNodeContainer

func (in *IconNode) CreateNodeContainer(ctx context.Context) error

Create Node Container with ports exposed and published for host to communicate with

func (*IconNode) DeployContract

func (in *IconNode) DeployContract(ctx context.Context, scorePath, keystorePath, initMessage string) (string, error)

func (*IconNode) Exec

func (in *IconNode) Exec(ctx context.Context, cmd []string, env []string) ([]byte, []byte, error)

func (*IconNode) ExecBin

func (in *IconNode) ExecBin(ctx context.Context, command ...string) ([]byte, []byte, error)

func (*IconNode) ExecCallTx

func (in *IconNode) ExecCallTx(ctx context.Context, scoreAddress, methodName, keystorePath, params string) (string, error)

func (*IconNode) ExecCallTxCommand

func (in *IconNode) ExecCallTxCommand(ctx context.Context, scoreAddress, methodName, keystorePath, params string) []string

func (*IconNode) ExecTx

func (in *IconNode) ExecTx(ctx context.Context, initMessage string, filePath string, keystorePath string, command ...string) (string, error)

ExecTx executes a transaction, waits for 2 blocks if successful, then returns the tx hash.

func (*IconNode) ExecuteContract

func (in *IconNode) ExecuteContract(ctx context.Context, scoreAddress, methodName, keyStorePath, params string) (string, error)

func (*IconNode) FindTxs

func (in *IconNode) FindTxs(ctx context.Context, height uint64) ([]blockdb.Tx, error)

func (*IconNode) GetBalance

func (in *IconNode) GetBalance(ctx context.Context, address string) (int64, error)

func (*IconNode) GetBlockByHeight

func (in *IconNode) GetBlockByHeight(ctx context.Context, height int64) (string, error)

func (*IconNode) Height

func (in *IconNode) Height(ctx context.Context) (uint64, error)

func (*IconNode) HomeDir

func (in *IconNode) HomeDir() string

func (*IconNode) HostName

func (in *IconNode) HostName() string

func (*IconNode) Name

func (in *IconNode) Name() string

Name of the test node container

func (*IconNode) NodeCommand

func (in *IconNode) NodeCommand(command ...string) []string

NodeCommand is a helper to retrieve a full command for a chain node binary. when interactions with the RPC endpoint are necessary. For example, if chain node binary is `gaiad`, and desired command is `gaiad keys show key1`, pass ("keys", "show", "key1") for command to return the full command. Will include additional flags for node URL, home directory, and chain ID.

func (*IconNode) QueryContract

func (in *IconNode) QueryContract(ctx context.Context, scoreAddress, methodName, params string) (string, error)

func (*IconNode) StartContainer

func (in *IconNode) StartContainer(ctx context.Context) error

func (*IconNode) TransactionResult

func (in *IconNode) TransactionResult(ctx context.Context, hash string) (icontypes.TransactionResult, error)

Get Transaction result when hash is provided after executing a transaction

func (*IconNode) TxCommand

func (in *IconNode) TxCommand(ctx context.Context, initMessage, filePath, keystorePath string, command ...string) []string

TxCommand is a helper to retrieve a full command for broadcasting a tx with the chain node binary.

func (*IconNode) WriteFile

func (tn *IconNode) WriteFile(ctx context.Context, content []byte, relPath string) error

WriteFile accepts file contents in a byte slice and writes the contents to the docker filesystem. relPath describes the location of the file in the docker volume relative to the home directory

type IconNodes

type IconNodes []*IconNode

type IconWallet

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

func (*IconWallet) Address

func (w *IconWallet) Address() []byte

Get Address with chain's prefix

func (*IconWallet) FormattedAddress

func (w *IconWallet) FormattedAddress() string

Get formatted address, passing in a prefix

func (*IconWallet) FormattedAddressWithPrefix

func (w *IconWallet) FormattedAddressWithPrefix(prefix string) string

func (*IconWallet) KeyName

func (w *IconWallet) KeyName() string

func (*IconWallet) Mnemonic

func (w *IconWallet) Mnemonic() string

Get mnemonic, only used for relayer wallets

Jump to

Keyboard shortcuts

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