icon

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 46 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 MakeCodec

func MakeCodec() *codec.ProtoCodec

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, scorePaths map[string]string) chains.Chain

func NewWallet

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

func RegisterInterfaces

func RegisterInterfaces(registry codectypes.InterfaceRegistry)

Types

type DebugTrace

type DebugTrace struct {
	Logs []struct {
		Level   uint   `json:"level"`
		Message string `json:"msg"`
		Ts      int    `json:"ts"`
	} `json:"logs"`
	Status icontypes.HexInt `json:"status"`
}

type IconLocalnet

type IconLocalnet struct {
	FullNodes IconNodes

	IBCAddresses map[string]string     `json:"addresses"`
	Wallets      map[string]ibc.Wallet `json:"wallets"`
	// 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) BackupConfig

func (c *IconLocalnet) BackupConfig() ([]byte, error)

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) (ibc.Wallet, error)

func (*IconLocalnet) CheckForKeyStore

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

func (*IconLocalnet) CheckForTimeout

func (c *IconLocalnet) CheckForTimeout(ctx context.Context, target chains.Chain, params map[string]interface{}, listener chains.EventListener) (context.Context, error)

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, keyName string) error

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 string, params map[string]interface{}) (context.Context, error)

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 uint64, from, to, sn string) (string, string, error)

func (*IconLocalnet) FindCallResponse

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

func (*IconLocalnet) FindEvent

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

func (*IconLocalnet) FindTargetXCallMessage

func (c *IconLocalnet) FindTargetXCallMessage(ctx context.Context, target chains.Chain, height uint64, to string) (*chains.XCallResponse, error)

FindTargetXCallMessage returns the request id and the data of the message sent to the target chain

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) GetChannel

func (c *IconLocalnet) GetChannel(ctx context.Context, channelSuffix int, portID string) (*chantypes.Channel, error)

func (*IconLocalnet) GetClientName

func (c *IconLocalnet) GetClientName(suffix int) string

func (*IconLocalnet) GetClientState

func (c *IconLocalnet) GetClientState(ctx context.Context, clientSuffix int) (any, error)

func (*IconLocalnet) GetClientsCount

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

GetClientsCount returns the next sequence number for the client

func (*IconLocalnet) GetConnectionState

func (c *IconLocalnet) GetConnectionState(ctx context.Context, clientSuffix int) (*conntypes.ConnectionEnd, error)

GetConnectionState returns the next sequence number for the client

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) GetNextChannelSequence

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

GetNextChannelSequence returns the next sequence number for the client

func (*IconLocalnet) GetNextConnectionSequence

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

GetNextConnectionSequence returns the next sequence number for the client

func (*IconLocalnet) GetQueryParam

func (c *IconLocalnet) GetQueryParam(method string, params map[string]interface{}) Query

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) InitEventListener

func (c *IconLocalnet) InitEventListener(ctx context.Context, contract string) chains.EventListener

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) IsPacketReceived

func (c *IconLocalnet) IsPacketReceived(ctx context.Context, params map[string]interface{}, order ibc.Order) bool

HasPacketReceipt returns the receipt of the packet sent to the target 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) PauseNode

func (c *IconLocalnet) PauseNode(ctx context.Context) error

PauseNode pauses the node

func (*IconLocalnet) PreGenesis

func (c *IconLocalnet) PreGenesis() error

func (*IconLocalnet) QueryContract

func (c *IconLocalnet) QueryContract(ctx context.Context, contractAddress, methodName string, params map[string]interface{}) (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) RestoreConfig

func (c *IconLocalnet) RestoreConfig(backup []byte) error

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) SendPacketMockDApp

func (c *IconLocalnet) SendPacketMockDApp(ctx context.Context, targetChain chains.Chain, keyName string, params map[string]interface{}) (chains.PacketTransferResponse, error)

func (*IconLocalnet) SendPacketXCall

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

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) UnpauseNode

func (c *IconLocalnet) UnpauseNode(ctx context.Context) error

UnpauseNode starts the paused node

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) (*chains.XCallResponse, 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) CopyConfig added in v1.1.0

func (in *IconNode) CopyConfig(ctx context.Context, err error, cc container.CreateResponse)

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) CopyFileToContainer

func (in *IconNode) CopyFileToContainer(ctx context.Context, content []byte, containerID, target string) error

func (*IconNode) CreateNodeContainer

func (in *IconNode) CreateNodeContainer(ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) 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) GetDebugTrace

func (in *IconNode) GetDebugTrace(ctx context.Context, hash icontypes.HexBytes) (*DebugTrace, 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) ([]byte, error)

func (*IconNode) RestoreKeystore

func (in *IconNode) RestoreKeystore(ctx context.Context, ks []byte, keyName 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

type Query

type Query struct {
	MethodName string
	Value      Value
}

type Value

type Value struct {
	Params map[string]interface{} `json:"params,omitempty"`
}

type WebSocketListener

type WebSocketListener struct {
	Shutdown chan struct{}
	Events   []map[string][]string
	// contains filtered or unexported fields
}

func NewIconEventListener

func NewIconEventListener(c *IconLocalnet, contract string) *WebSocketListener

func (*WebSocketListener) FindEvent

func (w *WebSocketListener) FindEvent(filters chains.Filter) (chains.Event, error)

func (*WebSocketListener) Start

func (w *WebSocketListener) Start()

func (*WebSocketListener) Stop

func (w *WebSocketListener) Stop()

Jump to

Keyboard shortcuts

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