{"modulePath":"github.com/RAMPAGEXP/ethermint","version":"v0.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package network\n\nPackage network implements and exposes a fully operational in-process Tendermint test network that consists of at least one or potentially many validators. This test network can be used primarily for integration tests or unit test suites.\n\nThe test network utilizes SimApp as the ABCI application and uses all the modules defined in the Cosmos SDK. An in-process test network can be configured with any number of validators as well as account funds and even custom genesis state.\n\nWhen creating a test network, a series of Validator objects are returned. Each Validator object has useful information such as their address and public key. A Validator will also provide its RPC, P2P, and API addresses that can be useful for integration testing. In addition, a Tendermint local RPC client is also provided which can be handy for making direct RPC calls to Tendermint.\n\nNote, due to limitations in concurrency and the design of the RPC layer in Tendermint, only the first Validator object will have an RPC and API client exposed. Due to this exact same limitation, only a single test network can exist at a time. A caller must be certain it calls Cleanup after it no longer needs the network.\n\nA typical testing flow might look like the following:\n\n\ttype IntegrationTestSuite struct {\n\t\tsuite.Suite\n\n\t\tcfg     testutil.Config\n\t\tnetwork *testutil.Network\n\t}\n\n\tfunc (s *IntegrationTestSuite) SetupSuite() {\n\t\ts.T().Log(\"setting up integration test suite\")\n\n\t\tcfg := testutil.DefaultConfig()\n\t\tcfg.NumValidators = 1\n\n\t\ts.cfg = cfg\n\t\ts.network = testutil.New(s.T(), cfg)\n\n\t\t_, err := s.network.WaitForHeight(1)\n\t\ts.Require().NoError(err)\n\t}\n\n\tfunc (s *IntegrationTestSuite) TearDownSuite() {\n\t\ts.T().Log(\"tearing down integration test suite\")\n\n\t\t// This is important and must be called to ensure other tests can create\n\t\t// a network!\n\t\ts.network.Cleanup()\n\t}\n\n\tfunc (s *IntegrationTestSuite) TestQueryBalancesRequestHandlerFn() {\n\t\tval := s.network.Validators[0]\n\t\tbaseURL := val.APIAddress\n\n\t\t// Use baseURL to make API HTTP requests or use val.RPCClient to make direct\n\t\t// Tendermint RPC calls.\n\t\t// ...\n\t}\n\n\tfunc TestIntegrationTestSuite(t *testing.T) {\n\t\tsuite.Run(t, new(IntegrationTestSuite))\n\t}\n\n## Functions\n\n```go\nfunc WriteFile(name string, dir string, contents []byte) error\n```\n\n## Types\n\n```go\ntype AppConstructor = func(val Validator) servertypes.Application\n```\nAppConstructor defines a function which accepts a network configuration and creates an ABCI Application to provide to Tendermint.\n\n```go\nfunc NewAppConstructor(encodingCfg params.EncodingConfig) AppConstructor\n```\nNewAppConstructor returns a new simapp AppConstructor\n\n```go\ntype CLILogger struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewCLILogger(cmd *cobra.Command) CLILogger\n```\n\n```go\nfunc (s CLILogger) Log(args ...interface{})\n```\n\n```go\nfunc (s CLILogger) Logf(format string, args ...interface{})\n```\n\n```go\ntype Config struct {\n\tKeyringOptions    []keyring.Option // keyring configuration options\n\tCodec             codec.Codec\n\tLegacyAmino       *codec.LegacyAmino // TODO: Remove!\n\tInterfaceRegistry codectypes.InterfaceRegistry\n\tTxConfig          client.TxConfig\n\tAccountRetriever  client.AccountRetriever\n\tAppConstructor    AppConstructor      // the ABCI application constructor\n\tGenesisState      simapp.GenesisState // custom gensis state to provide\n\tTimeoutCommit     time.Duration       // the consensus commitment timeout\n\tAccountTokens     sdk.Int             // the amount of unique validator tokens (e.g. 1000node0)\n\tStakingTokens     sdk.Int             // the amount of tokens each validator has available to stake\n\tBondedTokens      sdk.Int             // the amount of tokens each validator stakes\n\tNumValidators     int                 // the total number of validators to create and bond\n\tChainID           string              // the network chain-id\n\tBondDenom         string              // the staking bond denomination\n\tMinGasPrices      string              // the minimum gas prices each validator will accept\n\tPruningStrategy   string              // the pruning strategy each validator will have\n\tSigningAlgo       string              // signing algorithm for keys\n\tRPCAddress        string              // RPC listen address (including port)\n\tJSONRPCAddress    string              // JSON-RPC listen address (including port)\n\tAPIAddress        string              // REST API listen address (including port)\n\tGRPCAddress       string              // GRPC server listen address (including port)\n\tEnableTMLogging   bool                // enable Tendermint logging to STDOUT\n\tCleanupDir        bool                // remove base temporary directory during cleanup\n\tPrintMnemonic     bool                // print the mnemonic of first validator as log output for testing\n}\n```\nConfig defines the necessary configuration used to bootstrap and start an in-process local testing network.\n\n```go\nfunc DefaultConfig() Config\n```\nDefaultConfig returns a sane default configuration suitable for nearly all testing requirements.\n\n```go\ntype Logger interface {\n\tLog(args ...interface{})\n\tLogf(format string, args ...interface{})\n}\n```\nLogger is a network logger interface that exposes testnet-level Log() methods for an in-process testing network This is not to be confused with logging that may happen at an individual node or validator level\n\n```go\ntype Network struct {\n\tLogger     Logger\n\tBaseDir    string\n\tValidators []*Validator\n\n\tConfig Config\n}\n```\nNetwork defines a local in-process testing network using SimApp. It can be configured to start any number of validators, each with its own RPC and API clients. Typically, this test network would be used in client and integration testing where user input is expected.\n\nNote, due to Tendermint constraints in regards to RPC functionality, there may only be one test network running at a time. Thus, any caller must be sure to Cleanup after testing is finished in order to allow other tests to create networks. In addition, only the first validator will have a valid RPC and API server/client.\n\n```go\nfunc New(l Logger, baseDir string, cfg Config) (*Network, error)\n```\nNew creates a new Network for integration tests or in-process testnets run via the CLI\n\n```go\nfunc (n *Network) Cleanup()\n```\nCleanup removes the root testing (temporary) directory and stops both the Tendermint and API services. It allows other callers to create and start test networks. This method must be called when a test is finished, typically in a defer.\n\n```go\nfunc (n *Network) LatestHeight() (int64, error)\n```\nLatestHeight returns the latest height of the network or an error if the query fails or no validators exist.\n\n```go\nfunc (n *Network) WaitForHeight(h int64) (int64, error)\n```\nWaitForHeight performs a blocking check where it waits for a block to be committed after a given block. If that height is not reached within a timeout, an error is returned. Regardless, the latest height queried is returned.\n\n```go\nfunc (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, error)\n```\nWaitForHeightWithTimeout is the same as WaitForHeight except the caller can provide a custom timeout.\n\n```go\nfunc (n *Network) WaitForNextBlock() error\n```\nWaitForNextBlock waits for the next block to be committed, returning an error upon failure.\n\n```go\ntype Validator struct {\n\tAppConfig     *config.Config\n\tClientCtx     client.Context\n\tCtx           *server.Context\n\tDir           string\n\tNodeID        string\n\tPubKey        cryptotypes.PubKey\n\tMoniker       string\n\tAPIAddress    string\n\tRPCAddress    string\n\tP2PAddress    string\n\tAddress       sdk.AccAddress\n\tValAddress    sdk.ValAddress\n\tRPCClient     tmclient.Client\n\tJSONRPCClient *ethclient.Client\n\t// contains filtered or unexported fields\n}\n```\nValidator defines an in-process Tendermint validator node. Through this object, a client can make RPC and API calls and interact with any client command or handler.\n\n","path":"github.com/RAMPAGEXP/ethermint/testutil/network","name":"network","synopsis":"Package network implements and exposes a fully operational in-process Tendermint test network that consists of at least one or potentially many validators.","isRedistributable":true}
